Example usage for android.widget ImageView getTag

List of usage examples for android.widget ImageView getTag

Introduction

In this page you can find the example usage for android.widget ImageView getTag.

Prototype

public Object getTag(int key) 

Source Link

Document

Returns the tag associated with this view and the specified key.

Usage

From source file:com.retroteam.studio.retrostudio.EditorLandscape.java

/**
 * Iterate through all the measures and return a list of measure tag group objects.
 * The list is serialized out to the .retro project file.
 * @return ArrayList<MeasureTagGroup>
 *///from   w w w. j a va2  s. c  om

private ArrayList<MeasureTagGroup> getMeasureTags() {

    ArrayList<MeasureTagGroup> mtaglist = new ArrayList<>();

    LinearLayout track_layout = (LinearLayout) findViewById(R.id.track_layout);

    //iterate through all the measures
    for (int t = 0; t < track_layout.getChildCount(); t++) {
        //get hscrollview
        HorizontalScrollView hchild = (HorizontalScrollView) track_layout.getChildAt(t);
        for (int h = 0; h < hchild.getChildCount(); h++) {
            //get gridlayout
            GridLayout gchild = (GridLayout) hchild.getChildAt(h);
            for (int g = 0; g < gchild.getChildCount(); g++) {
                //get measure
                if (gchild.getChildAt(g) instanceof ImageView) {
                    ImageView ivchild = (ImageView) gchild.getChildAt(g);
                    Drawable measureFill = ivchild.getDrawable();
                    if (measureFill.getConstantState()
                            .equals(ContextCompat
                                    .getDrawable(getApplicationContext(), R.drawable.measure_new_empty)
                                    .getConstantState())) {
                        mtaglist.add(new MeasureTagGroup((int) ivchild.getTag(R.id.TAG_ROW),
                                (int) ivchild.getTag(R.id.TAG_COLUMN), false,
                                (int) ivchild.getTag(R.id.TAG_GUISNAP),
                                (ArrayList<int[]>) ivchild.getTag(R.id.TAG_FILLED_NOTES)));
                    } else if (measureFill.getConstantState()
                            .equals(ContextCompat
                                    .getDrawable(getApplicationContext(), R.drawable.measure_new_filled)
                                    .getConstantState())) {
                        mtaglist.add(new MeasureTagGroup((int) ivchild.getTag(R.id.TAG_ROW),
                                (int) ivchild.getTag(R.id.TAG_COLUMN), true,
                                (int) ivchild.getTag(R.id.TAG_GUISNAP),
                                (ArrayList<int[]>) ivchild.getTag(R.id.TAG_FILLED_NOTES)));
                    }
                }

            }
        }
    }

    return mtaglist;
}