Example usage for android.widget ImageView setTag

List of usage examples for android.widget ImageView setTag

Introduction

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

Prototype

public void setTag(int key, final Object tag) 

Source Link

Document

Sets a tag associated with this view and a key.

Usage

From source file:com.benefit.buy.library.http.query.callback.BitmapAjaxCallback.java

private void presetBitmap(String url, ImageView v) {
    if (!url.equals(v.getTag(Constants.TAG_URL)) || (preset != null)) {
        v.setTag(Constants.TAG_URL, url);
        if ((preset != null) && !cacheAvailable(v.getContext())) {
            setBitmap(url, v, preset, true);
        } else {//from ww  w  .  ja  v  a  2s.c o  m
            setBitmap(url, v, null, true);
        }
    }
}

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

/**
 * Process information returned from the MeasureEditor.
 * @param hasNotes/* w  w w  . j a v  a2 s.c o  m*/
 * @param row
 * @param column
 * @param guiSNAP
 * @param filledNotes
 */

private void updateMe(boolean hasNotes, int row, int column, int guiSNAP, ArrayList<int[]> filledNotes) {
    //mark the views that contain notes and remember the guiSNAP
    ImageView clickedmeasure = (ImageView) findMeasureByCoords(row, column);
    if (hasNotes) {
        clickedmeasure.setImageResource(R.drawable.measure_new_filled);
    }
    clickedmeasure.setTag(R.id.TAG_GUISNAP, guiSNAP);
    clickedmeasure.setTag(R.id.TAG_FILLED_NOTES, filledNotes);
}

From source file:info.papdt.blacklight.support.adapter.WeiboAdapter.java

private void bindMultiPicLayout(ViewHolder h, MessageModel msg, boolean showPic) {
    if (showPic && h.getItemViewType() % 10 > 0) {
        LinearLayout container = h.pics;

        int numChilds = h.getItemViewType() % 10;

        for (int i = 0; i < numChilds; i++) {
            ImageView iv = (ImageView) container.getChildAt(i);

            String url = null;//  www.ja  v  a  2s  .co m
            if (msg.hasMultiplePictures()) {
                url = msg.pic_urls.get(i).getThumbnail();
            } else if (i == 0) {
                url = msg.thumbnail_pic;
            }

            Picasso.with(iv.getContext()).load(url).fit().centerCrop().into(iv);

            iv.setTag(TAG_MSG, msg);
        }
    }
}

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

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_editor_landscape);

    //get display size
    Display display = getWindowManager().getDefaultDisplay();
    display.getSize(displaysize);/*from w w w  .ja  v  a2 s  . c  om*/

    //check where we're coming from, if we have an intent
    if (getIntent().getStringExtra("SourceActivity") != null && getIntent() != null) {
        Intent intent = getIntent();
        if (intent.getStringExtra("SourceActivity").equals("MainActivity")) {
            ProjectWrapper projwrapper = (ProjectWrapper) intent.getSerializableExtra("project");
            if (projwrapper != null) {
                // We are loading the project from a file.
                PROJECT_TITLE = projwrapper.title;
                PROJECT_TEMPO = projwrapper.tempo;
                TS_BEATS = projwrapper.tSig.beats();
                TS_NOTES = projwrapper.tSig.notes();
                theproject = projwrapper.project;
                ArrayList<MeasureTagGroup> mTagList = projwrapper.mTagList;
                //redraw project
                redrawMe(theproject);
                //re-apply measure tags
                for (int m = 0; m < mTagList.size(); m++) {
                    ImageView measure = (ImageView) findMeasureByCoords(mTagList.get(m).row,
                            mTagList.get(m).column);
                    measure.setTag(R.id.TAG_ROW, mTagList.get(m).row);
                    measure.setTag(R.id.TAG_COLUMN, mTagList.get(m).column);
                    measure.setTag(R.bool.TAG_HASNOTES, mTagList.get(m).hasNotes);
                    measure.setTag(R.id.TAG_GUISNAP, mTagList.get(m).guiSNAP);
                    measure.setTag(R.id.TAG_FILLED_NOTES, mTagList.get(m).filledNotes);
                    if (mTagList.get(m).hasNotes) {
                        measure.setImageResource(R.drawable.measure_new_filled);
                    }
                }
                Toast.makeText(this, "Opened project " + PROJECT_TITLE, Toast.LENGTH_SHORT).show();
            } else {
                // We're making a new project or coming from the main menu
                Toast.makeText(this, "Created new project.", Toast.LENGTH_SHORT).show();
                TS_BEATS = intent.getIntExtra("TimeSigBeats", 4);
                TS_NOTES = intent.getIntExtra("TimeSigNotes", 4);
                theproject = new Project(new TimeSignature(TS_BEATS, TS_NOTES));
            }
        }
    }

    // Put the project title in the actionbar.
    if (PROJECT_TITLE != "") {
        setupActionBar("'" + PROJECT_TITLE + "' Project Editor (" + Integer.toString(TS_BEATS) + "/"
                + Integer.toString(TS_NOTES) + " Time)");
    } else {
        setupActionBar(
                "Project Editor (" + Integer.toString(TS_BEATS) + "/" + Integer.toString(TS_NOTES) + " Time)");
    }

    //add buttons to the floating action menu
    FloatingActionsMenu menuAddTrack = (FloatingActionsMenu) findViewById(R.id.add_track_menu);
    FloatingActionButton addSineTrack = new FloatingActionButton(getBaseContext());
    addSineTrack.setTitle("Add Sine Wave Track");
    addSineTrack.setIcon(R.drawable.sine_wave);
    addSineTrack.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            SineWave wave = new SineWave();
            theproject.addTrack(wave);
            addTrack(R.drawable.sine_wave, false);
        }
    });
    FloatingActionButton addSquareTrack = new FloatingActionButton(getBaseContext());
    addSquareTrack.setTitle("Add Square Wave Track");
    addSquareTrack.setIcon(R.drawable.square_wave);
    addSquareTrack.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            SquareWave wave = new SquareWave();
            theproject.addTrack(wave);
            addTrack(R.drawable.square_wave, false);
        }
    });
    FloatingActionButton addNoiseTrack = new FloatingActionButton(getBaseContext());
    addNoiseTrack.setTitle("Add Noise Wave Track");
    addNoiseTrack.setIcon(R.drawable.noise_wave);
    addNoiseTrack.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            NoiseWave wave = new NoiseWave();
            theproject.addTrack(wave);
            addTrack(R.drawable.noise_wave, false);
        }
    });

    FloatingActionButton addSawTrack = new FloatingActionButton(getBaseContext());
    addSawTrack.setTitle("Add Saw Wave Track");
    addSawTrack.setIcon(R.drawable.saw_wave);
    addSawTrack.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            SawtoothWave wave = new SawtoothWave();
            theproject.addTrack(wave);
            addTrack(R.drawable.saw_wave, false);
        }
    });

    FloatingActionButton addInvSawTrack = new FloatingActionButton(getBaseContext());
    addInvSawTrack.setTitle("Add Inverse Saw Wave Track");
    addInvSawTrack.setIcon(R.drawable.inv_saw_wave);
    addInvSawTrack.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            InverseSawtoothWave wave = new InverseSawtoothWave();
            theproject.addTrack(wave);
            addTrack(R.drawable.inv_saw_wave, false);
        }
    });

    FloatingActionButton addTriangleTrack = new FloatingActionButton(getBaseContext());
    addTriangleTrack.setTitle("Add Triangle Wave Track");
    addTriangleTrack.setIcon(R.drawable.triangle_wave);
    addTriangleTrack.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            TriangleWave wave = new TriangleWave();
            theproject.addTrack(wave);
            addTrack(R.drawable.triangle_wave, false);
        }
    });

    menuAddTrack.addButton(addSineTrack);
    menuAddTrack.addButton(addSquareTrack);
    menuAddTrack.addButton(addNoiseTrack);
    menuAddTrack.addButton(addSawTrack);
    menuAddTrack.addButton(addInvSawTrack);
    menuAddTrack.addButton(addTriangleTrack);

    // Set the project tempo.
    theproject.tempo(PROJECT_TEMPO);
}

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

/**
 * Create all the views associated with a measure.
 * @param v//from w w w .j  a va2 s.  c o m
 * @param projectLoad
 */

private void addMeasure(View v, boolean projectLoad) {
    int whichtrack = (int) v.getTag(R.id.TAG_ROW);
    int whichmeasure = (int) v.getTag(R.id.TAG_COLUMN);

    if (!projectLoad) {
        theproject.track(whichtrack).addMeasure();
    }
    GridLayout myparent = (GridLayout) v.getParent();

    ImageView measure = new ImageView(getApplicationContext());
    measure.setImageResource(R.drawable.measure_new_empty);
    measure.setLayoutParams(new LinearLayout.LayoutParams((int) (displaysize.x / 3.32),
            LinearLayout.LayoutParams.MATCH_PARENT));
    measure.setTag(R.id.TAG_ROW, whichtrack);
    measure.setTag(R.id.TAG_COLUMN, whichmeasure);
    measure.setTag(R.bool.TAG_HASNOTES, false);
    measure.setTag(R.id.TAG_GUISNAP, 0);
    measure.setTag(R.id.TAG_FILLED_NOTES, new ArrayList<int[]>());
    measure.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ///
            int whichtrack = (int) v.getTag(R.id.TAG_ROW);
            int whichmeasure = (int) v.getTag(R.id.TAG_COLUMN);
            editMeasure(v);
        }
    });
    myparent.addView(measure, whichmeasure + 1);

    v.setTag(R.id.TAG_COLUMN, whichmeasure + 1);
}

From source file:com.benefit.buy.library.http.query.callback.BitmapAjaxCallback.java

@Override
public void async(Context context) {
    String url = getUrl();/*from  w  ww.j  a  va 2s . c  o  m*/
    ImageView v = this.v.get();
    if (url == null) {
        showProgress(false);
        setBitmap(url, v, null, false);
        return;
    }
    Bitmap bm = memGet(url);
    if (bm != null) {
        v.setTag(Constants.TAG_URL, url);
        status = new AjaxStatus().source(AjaxStatus.MEMORY).done();
        callback(url, bm, status);
        return;
    }
    presetBitmap(url, v);
    if (!queueMap.containsKey(url)) {
        addQueue(url, v);
        super.async(v.getContext());
    } else {
        showProgress(true);
        addQueue(url, v);
    }
}

From source file:com.appbase.androidquery.callback.BitmapAjaxCallback.java

private void presetBitmap(String url, ImageView v) {

    if (!url.equals(v.getTag(AQuery.TAG_URL)) || preset != null) {

        v.setTag(AQuery.TAG_URL, url);

        if (preset != null && !cacheAvailable(v.getContext())) {
            setBitmap(url, v, preset, true);
        } else {//from   w ww.ja  va  2  s . co  m

            setBitmap(url, v, null, true);
        }
    }

}

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

/**
 * Create all the views associated with a track.
 * @param waveDrawableID/*from ww w  . j av a  2 s .co  m*/
 * @param projectLoad
 * @return
 */

private ImageView addTrack(int waveDrawableID, boolean projectLoad) {
    //add the track with the measure adder to the view
    //get layout
    LinearLayout track_layout = (LinearLayout) findViewById(R.id.track_layout);

    //create track container
    HorizontalScrollView track_container = new HorizontalScrollView(getApplicationContext());
    track_container.setLayoutParams(new HorizontalScrollView.LayoutParams(
            HorizontalScrollView.LayoutParams.MATCH_PARENT, displaysize.y / 4));
    track_container.setBackground(getResources().getDrawable(R.color.track_container_bg));

    //create grid layout
    GridLayout track_grid = new GridLayout(getApplicationContext());
    track_grid.setColumnCount(100);
    track_grid.setRowCount(1);
    track_grid.setOrientation(GridLayout.HORIZONTAL);
    track_grid.setId(R.id.track_grid);

    //create linear layout for track id and wave
    LinearLayout track_identifier = new LinearLayout(getApplicationContext());
    track_identifier.setLayoutParams(new LinearLayout.LayoutParams(displaysize.x / 14, displaysize.y / 4));
    track_identifier.setOrientation(LinearLayout.VERTICAL);
    track_identifier.setBackgroundColor(getResources().getColor(R.color.black_overlay));

    //create textview for linear layout
    TextView track_num = new TextView(getApplicationContext());
    track_num.setText("1");
    track_num.setTextSize(45);
    track_num.setGravity(Gravity.CENTER | Gravity.CENTER_VERTICAL);

    //create imageview for linear layout
    ImageView track_type = new ImageView(getApplicationContext());
    track_type.setImageResource(waveDrawableID);
    track_type.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.MATCH_PARENT));

    //create "add measure" for grid layout
    ImageView add_measure = new ImageView(getApplicationContext());
    add_measure.setImageResource(R.drawable.measure_new);
    add_measure.setLayoutParams(new LinearLayout.LayoutParams((int) (displaysize.x / 3.32),
            LinearLayout.LayoutParams.MATCH_PARENT));
    if (projectLoad) {
        add_measure.setTag(R.id.TAG_ROW, trackReloadCounter);
        add_measure.setId(trackReloadCounter + 4200);
    } else {
        add_measure.setTag(R.id.TAG_ROW, theproject.size() - 1);
        add_measure.setId(theproject.size() - 1 + 4200);
    }

    add_measure.setTag(R.id.TAG_COLUMN, 0);
    add_measure.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            addMeasure(v, false);

        }
    });

    track_identifier.addView(track_num);
    if (projectLoad) {
        track_num.setText(Integer.toString(trackReloadCounter + 1));
        trackReloadCounter += 1;
    } else {
        track_num.setText(Integer.toString(theproject.size()));
    }
    track_num.setTextSize(45);
    track_identifier.addView(track_type);

    track_grid.addView(track_identifier);
    track_grid.addView(add_measure);

    track_container.addView(track_grid);

    track_layout.addView(track_container);

    return add_measure;

}

From source file:com.appbase.androidquery.callback.BitmapAjaxCallback.java

@Override
public void async(Context context) {

    String url = getUrl();//w w  w .  java2 s  . c  o m

    ImageView v = this.v.get();

    if (url == null) {
        showProgress(false);
        setBitmap(url, v, null, false);
        return;
    }

    Bitmap bm = memGet(url);
    if (bm != null) {
        v.setTag(AQuery.TAG_URL, url);
        status = new AjaxStatus().source(AjaxStatus.MEMORY).done();
        callback(url, bm, status);
        return;
    }

    presetBitmap(url, v);

    if (!queueMap.containsKey(url)) {
        addQueue(url, v);
        super.async(v.getContext());
    } else {
        showProgress(true);
        addQueue(url, v);
    }

}

From source file:com.musenkishi.atelier.Atelier.java

private static void applyColorToView(final ImageView imageView, int color, boolean fromCache,
        boolean shouldMask) {
    if (fromCache) {
        if (shouldMask) {
            if (imageView.getDrawable() != null) {
                imageView.getDrawable().mutate().setColorFilter(color, PorterDuff.Mode.MULTIPLY);
            } else if (imageView.getBackground() != null) {
                imageView.getBackground().mutate().setColorFilter(color, PorterDuff.Mode.MULTIPLY);
            }/*from  w  w w .j av a  2s.  co m*/
        } else {
            imageView.setBackgroundColor(color);
        }
    } else {
        if (shouldMask) {
            Integer colorFrom;
            ValueAnimator.AnimatorUpdateListener imageAnimatorUpdateListener = new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator valueAnimator) {
                    if (imageView.getDrawable() != null) {
                        imageView.getDrawable().mutate().setColorFilter(
                                (Integer) valueAnimator.getAnimatedValue(), PorterDuff.Mode.MULTIPLY);
                    } else if (imageView.getBackground() != null) {
                        imageView.getBackground().mutate().setColorFilter(
                                (Integer) valueAnimator.getAnimatedValue(), PorterDuff.Mode.MULTIPLY);
                    }
                }
            };
            ValueAnimator.AnimatorUpdateListener animatorUpdateListener;

            PaletteTag paletteTag = (PaletteTag) imageView.getTag(viewTagKey);
            animatorUpdateListener = imageAnimatorUpdateListener;
            colorFrom = paletteTag.getColor();
            imageView.setTag(viewTagKey, new PaletteTag(paletteTag.getId(), color));

            Integer colorTo = color;
            ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
            colorAnimation.addUpdateListener(animatorUpdateListener);
            colorAnimation.setDuration(300);
            colorAnimation.start();
        } else {
            Drawable preDrawable;

            if (imageView.getBackground() == null) {
                preDrawable = new ColorDrawable(Color.TRANSPARENT);
            } else {
                preDrawable = imageView.getBackground();
            }

            TransitionDrawable transitionDrawable = new TransitionDrawable(
                    new Drawable[] { preDrawable, new ColorDrawable(color) });
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                imageView.setBackground(transitionDrawable);
            } else {
                imageView.setBackgroundDrawable(transitionDrawable);
            }
            transitionDrawable.startTransition(300);
        }
    }
}