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.csipsimple.utils.ContactsAsyncHelper.java

private static boolean isAlreadyProcessed(ImageView imageView, Uri uri) {
    if (imageView != null) {
        PhotoViewTag vt = (PhotoViewTag) imageView.getTag(TAG_PHOTO_INFOS);
        return (vt != null && UriUtils.areEqual(uri, vt.uri));
    }//from   w w w .j  a  v a2 s. c o m
    return true;
}

From source file:my.example.onekeycleaner.imgcache.ImageWorker.java

/**
 * @param imageView Any imageView/*from ww  w . ja v a2  s  .  c  o  m*/
 * @return Retrieve the currently active work task (if any) associated with this imageView.
 * null if there is no such task.
 */
private static BitmapWorkerTask getBitmapWorkerTask(ImageView imageView, boolean isTag) {
    if (imageView != null) {
        final Drawable drawable;
        if (isTag) {
            drawable = (Drawable) imageView.getTag(R.id.load_bitmap_tag_task);
        } else {
            drawable = imageView.getDrawable();
        }
        if (drawable instanceof AsyncDrawable) {
            final AsyncDrawable asyncDrawable = (AsyncDrawable) drawable;
            return asyncDrawable.getBitmapWorkerTask();
        }
    }
    return null;
}

From source file:com.azcltd.android.test.kolesov.DrawableManager.java

public void fetchDrawableOnThreadWithNoImage(final String urlString, final ImageView imageView,
        final boolean isThumbnail) {
    fetchDrawableOnThread(urlString, imageView, false, false);
    if (imageView.getDrawable() == null) {
        //fetchDrawableOnThread(urlString, imageView, false, true);
        //if(imageView.getDrawable() == null)
        {// w  w  w . j  av a  2s  . c  o m
            if (imageView.getTag(0) != isErrorImageKey) {
                fetchDrawableOnThread("http://www.wildcatpad.com/images/wutu.jpg", imageView, false, false);
                imageView.setTag(0, isErrorImageKey);
            }
            //                else
            //                {
            //                    fetchDrawableOnThread(urlString, imageView, false, true);
            //                    imageView.setTag(0, "");
            //                }
        }
    }
}

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

/**
 * Assign a note visually and in the project.
 * @param view/*from w ww .j  a v  a  2 s.  c o m*/
 */
private void paintNote(View view) {
    com.getbase.floatingactionbutton.FloatingActionButton ptool = (com.getbase.floatingactionbutton.FloatingActionButton) findViewById(
            R.id.pencilTool);
    ImageView iview = (ImageView) view;
    Drawable notestatus = iview.getDrawable();
    if (pencil) {
        if (notestatus.getConstantState().equals(ContextCompat
                .getDrawable(getApplicationContext(), R.drawable.note_filled).getConstantState())) {

            //blank all other notes in the column
            TableRow parent = (TableRow) iview.getParent();
            TableLayout layoutparent = (TableLayout) parent.getParent();
            int notedrawlen = layoutparent.getChildCount();
            for (int x = 0; x < notedrawlen; x++) {
                TableRow noterow = (TableRow) layoutparent.getChildAt(x);
                for (int i = 0; i < noterow.getChildCount(); i++) {
                    ImageView note = (ImageView) noterow.getChildAt(i);
                    if (note.getTag(R.id.TAG_COLUMN) == iview.getTag(R.id.TAG_COLUMN)) {
                        note.setImageDrawable(
                                ContextCompat.getDrawable(getApplicationContext(), R.drawable.measure_outline));
                        for (int n = 0; n < filledNotes.size(); n++) {
                            int[] comp = filledNotes.get(n);
                            if (comp[0] == (int) note.getTag(R.id.TAG_ROW)
                                    && comp[1] == (int) note.getTag(R.id.TAG_COLUMN)) {
                                filledNotes.remove(n);
                            }
                        }
                    }
                }
            }
            //set the drawable
            iview.setImageDrawable(
                    ContextCompat.getDrawable(getApplicationContext(), R.drawable.measure_outline));
            filledNotes.remove(
                    new int[] { (int) iview.getTag(R.id.TAG_ROW), (int) iview.getTag(R.id.TAG_COLUMN) });

            // set the other notes to rests
            List<Integer> guiSNAPRange = (List<Integer>) iview.getTag(R.id.TAG_GUISNAPRANGE);
            for (int z = guiSNAPRange.get(0); z <= guiSNAPRange.get(guiSNAPRange.size() - 1); z++) {
                theproject.track(trackNum).measure(measureNum).replace(z, new Note(Note.REST, noteSUB));
            }
        } else {
            //blank all other notes in the column
            TableRow parent = (TableRow) iview.getParent();
            TableLayout layoutparent = (TableLayout) parent.getParent();
            int notedrawlen = layoutparent.getChildCount();
            for (int x = 0; x < notedrawlen; x++) {
                TableRow noterow = (TableRow) layoutparent.getChildAt(x);
                for (int i = 0; i < noterow.getChildCount(); i++) {
                    ImageView note = (ImageView) noterow.getChildAt(i);
                    if (note.getTag(R.id.TAG_COLUMN) == iview.getTag(R.id.TAG_COLUMN)) {
                        note.setImageDrawable(
                                ContextCompat.getDrawable(getApplicationContext(), R.drawable.measure_outline));
                        for (int n = 0; n < filledNotes.size(); n++) {
                            int[] comp = filledNotes.get(n);
                            if (comp[0] == (int) note.getTag(R.id.TAG_ROW)
                                    && comp[1] == (int) note.getTag(R.id.TAG_COLUMN)) {
                                filledNotes.remove(n);
                            }
                        }
                    }
                }
            }
            //set the drawable
            iview.setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.note_filled));
            filledNotes
                    .add(new int[] { (int) iview.getTag(R.id.TAG_ROW), (int) iview.getTag(R.id.TAG_COLUMN) });

            //set the note in the data structure
            double notetype = stringToNoteDouble((String) iview.getTag(R.id.TAG_NOTE));
            List<Integer> guiSNAPRange = (List<Integer>) iview.getTag(R.id.TAG_GUISNAPRANGE);
            for (int z = guiSNAPRange.get(0); z <= guiSNAPRange.get(guiSNAPRange.size() - 1); z++) {
                theproject.track(trackNum).measure(measureNum).replace(z, new Note(notetype, noteSUB));
            }
        }
    }
}

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

/**
 * Start MeasureEditor with an intent with all the data.
 * @param view//from w  ww .j  a  v a  2s  .  c  om
 */

private void editMeasure(View view) {

    Intent intent = new Intent(this, MeasureEditor.class);

    intent.putExtra("Project", theproject);
    ImageView viewi = (ImageView) view;
    intent.putExtra(MEASURE_TRACK, (int) viewi.getTag(R.id.TAG_ROW));
    intent.putExtra(MEASURE, (int) viewi.getTag(R.id.TAG_COLUMN));
    intent.putExtra(MEASURE_TITLE, Integer.toString((int) viewi.getTag(R.id.TAG_COLUMN)) + ","
            + Integer.toString((int) viewi.getTag(R.id.TAG_ROW)));
    intent.putExtra("measureID", viewi.getId());
    intent.putExtra("SourceActivity", "EditorLandscape");
    intent.putExtra("guiSNAP", (int) viewi.getTag(R.id.TAG_GUISNAP));
    intent.putExtra("filledNotes", (ArrayList<int[]>) viewi.getTag(R.id.TAG_FILLED_NOTES));
    intent.putExtra("tsBeats", TS_BEATS);
    intent.putExtra("tsNotes", TS_NOTES);
    startActivityForResult(intent, 123);
}

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   w  w  w.j a  va2s  . c  o m
            setBitmap(url, v, null, true);
        }
    }
}

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

private void checkCb(BitmapAjaxCallback cb, String url, ImageView v, Bitmap bm, AjaxStatus status) {
    if ((v == null) || (cb == null)) {
        return;/* ww w. j ava2s  .  c  om*/
    }
    if (url.equals(v.getTag(Constants.TAG_URL))) {
        if (v instanceof ImageView) {
            cb.callback(url, v, bm, status);
        } else {
            cb.setBitmap(url, v, bm, false);
        }
    }
    cb.showProgress(false);
}

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  w w.  j a v  a 2s .  c  om

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

}

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

private void checkCb(BitmapAjaxCallback cb, String url, ImageView v, Bitmap bm, AjaxStatus status) {

    if (v == null || cb == null)
        return;//from ww w  .  j a  va 2 s  . c  om

    if (url.equals(v.getTag(AQuery.TAG_URL))) {

        if (v instanceof ImageView) {
            cb.callback(url, (ImageView) v, bm, status);
        } else {
            cb.setBitmap(url, v, bm, false);
        }

    }

    cb.showProgress(false);
}

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   ww w .j  a va2  s .  c  om
        } 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);
        }
    }
}