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

private static void defaultImage(ImageView imageView, int placeholderImageResource) {
    Log.v(THIS_FILE, "No uri, just display placeholder.");
    PhotoViewTag photoTag = new PhotoViewTag();
    photoTag.uri = null;//from   www  .j a  va 2  s  .co m
    imageView.setTag(TAG_PHOTO_INFOS, photoTag);
    imageView.setVisibility(View.VISIBLE);
    imageView.setImageResource(placeholderImageResource);
}

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

/**
 * Cancels any pending work attached to the provided ImageView.
 * @param imageView//from ww  w . j a v  a2s.  c o m
 */
public static void cancelWork(ImageView imageView, boolean isTag) {
    final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView, isTag);
    if (bitmapWorkerTask != null) {
        bitmapWorkerTask.cancel(true);
        if (BuildConfig.DEBUG) {
            final Object bitmapData = bitmapWorkerTask.data;
            Log.d(TAG, "cancelWork - cancelled work for " + bitmapData);
        }
    }

    // ?tag
    if (isTag) {
        imageView.setTag(R.id.load_bitmap_tag_task, null);
    }
}

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

/**
 * AQuery internal use only. Please uses AQuery image() methods instead. Optimize memory usage if mem hit and
 * there's no custom callback./*from   w  w  w. ja v a2 s .  c  o m*/
 */
public static void async(Activity act, Context context, ImageView iv, String url, boolean memCache,
        boolean fileCache, int targetWidth, int fallbackId, Bitmap preset, int animation, float ratio,
        float anchor, Object progress, AccountHandle ah, int policy, int round, HttpHost proxy,
        String networkUrl) {
    Bitmap bm = null;
    if (memCache) {
        bm = memGet(url, targetWidth, round);
    }
    if (bm != null) {
        iv.setTag(Constants.TAG_URL, url);
        Common.showProgress(progress, url, false);
        setBmAnimate(iv, bm, preset, fallbackId, animation, ratio, anchor, AjaxStatus.MEMORY);
    } else {
        BitmapAjaxCallback cb = new BitmapAjaxCallback();
        cb.url(url).imageView(iv).memCache(memCache).fileCache(fileCache).targetWidth(targetWidth)
                .fallback(fallbackId).preset(preset).animation(animation).ratio(ratio).anchor(anchor)
                .progress(progress).auth(ah).policy(policy).round(round).networkUrl(networkUrl);
        if (proxy != null) {
            cb.proxy(proxy.getHostName(), proxy.getPort());
        }
        if (act != null) {
            cb.async(act);
        } else {
            cb.async(context);
        }
    }
}

From source file:com.swater.meimeng.activity.oomimg.SimpleThumbnailCursorAdapter.java

private void setViewImageAndTag(ImageView v, String value, Drawable defaultImage) {
    v.setImageDrawable(defaultImage);//from  ww w . j a  va2  s .c o m
    if (value != null && value.length() > 0) {
        v.setTag(R.id.ic__uri, Uri.parse(value));
    } else {
        v.setTag(R.id.ic__uri, null);
    }
}

From source file:com.jbirdvegas.mgerrit.cards.PatchSetPropertiesCard.java

private void setClicksToActionViews(Cursor cursor, ImageView share, ImageView browser) {

    String webAddress = getWebAddress(cursor.getString(changenum_index));

    share.setTag(R.id.webAddress, webAddress);
    share.setTag(R.id.changeID, cursor.getString(changeid_index));
    browser.setTag(R.id.webAddress, webAddress);

    share.setOnClickListener(new View.OnClickListener() {
        @Override//from  w  ww  . jav a2 s.  co m
        public void onClick(View view) {
            String changeId = (String) view.getTag(R.id.changeID);
            String webAddress = (String) view.getTag(R.id.webAddress);

            Intent intent = new Intent(android.content.Intent.ACTION_SEND);
            intent.setType("text/plain");
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
            intent.putExtra(Intent.EXTRA_SUBJECT,
                    String.format(view.getContext().getString(R.string.commit_shared_from_mgerrit), changeId));
            intent.putExtra(Intent.EXTRA_TEXT, webAddress + " #mGerrit");
            view.getContext().startActivity(intent);
        }
    });
    browser.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            String webAddress = (String) view.getTag(R.id.webAddress);

            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(webAddress));
            view.getContext().startActivity(browserIntent);
        }
    });
}

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

/**
 * AQuery internal use only. Please uses AQuery image() methods instead.
 * /*from   w  w  w.  ja v  a  2s.  c o  m*/
 * Optimize memory usage if mem hit and there's no custom callback.
 *
 *
 */

public static void async(Activity act, Context context, ImageView iv, String url, boolean memCache,
        boolean fileCache, int targetWidth, int fallbackId, Bitmap preset, int animation, float ratio,
        float anchor, Object progress, AccountHandle ah, int policy, int round, HttpHost proxy,
        String networkUrl) {

    Bitmap bm = null;

    if (memCache) {
        bm = memGet(url, targetWidth, round);
    }

    if (bm != null) {
        iv.setTag(AQuery.TAG_URL, url);
        Common.showProgress(progress, url, false);
        setBmAnimate(iv, bm, preset, fallbackId, animation, ratio, anchor, AjaxStatus.MEMORY);
    } else {
        BitmapAjaxCallback cb = new BitmapAjaxCallback();
        cb.url(url).imageView(iv).memCache(memCache).fileCache(fileCache).targetWidth(targetWidth)
                .fallback(fallbackId).preset(preset).animation(animation).ratio(ratio).anchor(anchor)
                .progress(progress).auth(ah).policy(policy).round(round).networkUrl(networkUrl);
        if (proxy != null) {
            cb.proxy(proxy.getHostName(), proxy.getPort());
        }
        if (act != null) {
            cb.async(act);
        } else {
            cb.async(context);
        }
    }

}

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)
        {/*from   www.  jav a2  s. 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

/**
 * Draw the grid.//w w  w . j  a  v  a2 s . c  om
 */
private void drawGrid() {
    //draw the grid based on project info
    thisMeasure = theproject.track(trackNum).measure(measureNum);
    TableLayout notedraw = (TableLayout) findViewById(R.id.notedraw);
    int notedrawlen = notedraw.getChildCount();

    //get note scale
    final float dscale = getApplicationContext().getResources().getDisplayMetrics().density;
    int notewidth = (int) (144 * dscale + 0.5f);
    int noteheight = (int) (75 * dscale + 0.5f);

    for (int x = 0; x < notedrawlen; x++) {
        TableRow noterow = (TableRow) notedraw.getChildAt(x);
        List<List<Integer>> rangelist = numNotesFromGuiSnap();
        for (int i = 0; i < rangelist.size(); i++) {
            ImageView note = new ImageView(getApplicationContext());
            note.setLayoutParams(new TableRow.LayoutParams(notewidth, noteheight));

            note.setTag(R.id.TAG_ROW, x);
            note.setTag(R.id.TAG_COLUMN, i);
            note.setTag(R.id.TAG_NOTE, notesdisplay[x]);

            note.setTag(R.id.TAG_GUISNAPRANGE, rangelist.get(i));

            note.setImageResource(R.drawable.measure_outline);
            if (filledNotesFromIntent.size() > 0) {
                for (int z = 0; z < filledNotesFromIntent.size(); z++) {
                    if ((filledNotesFromIntent.get(z)[0] == x) && (filledNotesFromIntent.get(z)[1] == i)) {
                        note.setImageResource(R.drawable.note_filled);
                    }
                }
            }

            note.setBackgroundColor(getResources().getColor(R.color.note_rest));

            note.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    paintNote(v);

                }
            });

            noterow.addView(note);
        }
    }
}

From source file:com.tomeokin.lspush.biz.home.CollectionListAdapter.java

private void setExplorers(ViewGroup container, @Nullable List<User> explorers) {
    final Context context = container.getContext();
    // // TODO: 2016/10/8 performance improve
    //container.removeAllViews();
    //for (User explorer : explorers) {
    //    final ImageView avatar =
    //        (ImageView) LayoutInflater.from(context).inflate(R.layout.layout_item_explorer, container, false);
    //    ImageLoader.loadAvatar(context, avatar, explorer.getImage());
    //    container.addView(avatar);
    //}/*  w  w w.j  a v  a  2s.co m*/

    final int count = container.getChildCount();
    int targetCount = explorers == null ? 0 : explorers.size();
    targetCount = targetCount >= 5 ? 5 : targetCount;
    final LayoutInflater inflater = LayoutInflater.from(context);
    if (count > targetCount) {
        container.removeViews(targetCount, count - targetCount);
    }
    ImageView avatar;
    for (int i = 0; i < targetCount; i++) {
        if (i > count - 1) { // no cache
            avatar = (ImageView) inflater.inflate(R.layout.layout_item_explorer, container, false);
        } else {
            avatar = (ImageView) container.getChildAt(i);
        }
        ImageLoader.loadAvatar(context, avatar, explorers.get(i).getImage());
        if (avatar.getParent() == null) {
            container.addView(avatar);
        }
        avatar.setTag(R.id.avatar_tag_uid, explorers.get(i).getUid());
        avatar.setOnClickListener(mExplorerListener);
    }
}

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

private void loadImage(Object data, ImageView imageView, boolean isLoadPm, boolean isTag, boolean isRotate) {
    if (data == null) {
        return;/*from www.j a va  2  s.  c om*/
    }

    BitmapDrawable value = null;

    if (mImageCache != null) {
        value = mImageCache.getBitmapFromMemCache(String.valueOf(data));
    }

    if (value != null) {
        // Bitmap found in memory cache
        if (isTag) {
            imageView.setTag(R.id.load_bitmap_tag_task, null);
        }
        imageView.setImageDrawable(value);
    } else if (cancelPotentialWork(data, imageView, isTag)) {
        final BitmapWorkerTask task = new BitmapWorkerTask(imageView, isTag);
        final AsyncDrawable asyncDrawable = new AsyncDrawable(mResources, mLoadingBitmap, task);
        if (isTag) {
            imageView.setTag(R.id.load_bitmap_tag_task, asyncDrawable);
        } else {
            imageView.setImageDrawable(asyncDrawable);
        }

        Object[] params = new Object[3];
        params[0] = data;
        params[1] = isLoadPm;
        params[2] = isRotate;

        // NOTE: This uses a custom VERSION of AsyncTask that has been pulled from the
        // framework and slightly modified. Refer to the docs at the top of the class
        // for more info on what was changed.
        task.executeOnExecutor(AsyncTask.DUAL_THREAD_EXECUTOR, params);
    }
}