List of usage examples for android.widget ImageView getTag
@ViewDebug.ExportedProperty
public Object getTag()
From source file:com.cleverua.test.thumbs.ImageDownloader.java
/** * @param imageView Any imageView/*from w ww . jav a2 s. co m*/ * @return Retrieve the currently active download task (if any) associated with this imageView. * null if there is no such task. */ @SuppressWarnings("unchecked") private static BitmapDownloaderTask getBitmapDownloaderTask(ImageView imageView) { if (imageView != null) { Object ref = imageView.getTag(); if (ref != null && ref instanceof WeakReference) { WeakReference<BitmapDownloaderTask> taskReference = (WeakReference<BitmapDownloaderTask>) ref; return taskReference.get(); } } return null; }
From source file:com.roach.framework.http.bitmap.ImageWorker.java
/** * Cancels any pending work attached to the provided ImageView. * @param imageView//ww w .j a v a 2 s .com */ public static void cancelWork(ImageView imageView) { // final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView); BitmapWorkerTask bitmapWorkerTask = null; if (imageView.getTag() != null) { bitmapWorkerTask = (BitmapWorkerTask) imageView.getTag(); } if (bitmapWorkerTask != null) { bitmapWorkerTask.cancel(true); if (BuildConfig.DEBUG) { final Object bitmapData = bitmapWorkerTask.data; Log.d(TAG, "cancelWork - cancelled work for " + bitmapData); } } }
From source file:com.roach.framework.http.bitmap.ImageWorker.java
/** * Returns true if the current work has been canceled or if there was no work in * progress on this image view.//from w ww .j a v a 2s .c o m * Returns false if the work in progress deals with the same data. The work is not * stopped in that case. */ public static boolean cancelPotentialWork(Object data, ImageView imageView) { // final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView); BitmapWorkerTask bitmapWorkerTask = null; if (imageView.getTag() != null && (imageView.getTag() instanceof BitmapWorkerTask)) { bitmapWorkerTask = (BitmapWorkerTask) imageView.getTag(); } if (bitmapWorkerTask != null) { final Object bitmapData = bitmapWorkerTask.data; if (bitmapData == null || !bitmapData.equals(data)) { bitmapWorkerTask.cancel(true); if (BuildConfig.DEBUG) { Log.d(TAG, "cancelPotentialWork - cancelled work for " + data); } } else { // The same work is already in progress. return false; } } return true; }
From source file:Main.java
public static void unbindImageView(ImageView imageView) { if (imageView == null) { return;//from w w w .j a v a2s.c o m } if (imageView.getBackground() != null) { imageView.getBackground().setCallback(null); } if (imageView.getDrawable() == null) return; if (!(imageView.getDrawable() instanceof BitmapDrawable)) return; if (((BitmapDrawable) imageView.getDrawable()).getBitmap() == null) return; BitmapDrawable drawable = (BitmapDrawable) imageView.getDrawable(); try { if (drawable != null && imageView.getTag() != null && !drawable.getBitmap().isRecycled()) { if (!imageView.getTag().toString().equalsIgnoreCase("resource") && !usingMemoryCache) { drawable.getBitmap().recycle(); } } } catch (RuntimeException e) { e.printStackTrace(); } drawable.setCallback(null); imageView.setImageBitmap(null); imageView.setImageDrawable(null); }
From source file:com.travel.ac.utils.ImageWorker.java
/** * @param imageView//from w w w . j a v a2 s . c o m * Any imageView * @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) { if (imageView != null) { /* * ? */ final Drawable drawable = (Drawable) imageView.getTag(); // Log.e(TAG, "=====================================================getBitmapWorkerTask:" + drawable); if (drawable instanceof AsyncDrawable) { final AsyncDrawable asyncDrawable = (AsyncDrawable) drawable; return asyncDrawable.getBitmapWorkerTask(); } } return null; }
From source file:com.geeker.door.imgcache.ImageDownloader.java
/** * @param imageView//from w w w . j a v a 2s. c o m * Any imageView * @return Retrieve the currently active download task (if any) associated * with this imageView. null if there is no such task. */ private static BitmapDownloaderTask getBitmapDownloaderTask(ImageView imageView) { if (imageView != null) { Object objDrawable = imageView.getTag(); if (objDrawable != null && objDrawable instanceof DownloadedDrawable) { DownloadedDrawable downloadedDrawable = (DownloadedDrawable) objDrawable; return downloadedDrawable.getBitmapDownloaderTask(); } } return null; }
From source file:com.DGSD.DGUtils.ImageDownloader.ImageLoader.java
private static void start(String imageUrl, ImageView imageView, ImageLoaderHandler handler, Drawable dummyDrawable, Drawable errorDrawable) { if (imageView != null) { if (imageUrl == null) { // In a ListView views are reused, so we must be sure to remove the tag that could // have been set to the ImageView to prevent that the wrong image is set. imageView.setTag(null);/* w w w. jav a 2 s .c om*/ imageView.setImageDrawable(dummyDrawable); return; } String oldImageUrl = (String) imageView.getTag(); if (imageUrl.equals(oldImageUrl)) { // nothing to do return; } else { // Set the dummy image while waiting for the actual image to be downloaded. imageView.setImageDrawable(dummyDrawable); imageView.setTag(imageUrl); } } if (imageCache.containsKeyInMemory(imageUrl)) { // do not go through message passing, handle directly instead handler.handleImageLoaded(imageCache.getBitmap(imageUrl), null); } else { executor.execute(new ImageLoader(imageUrl, handler)); } }
From source file:org.montanafoodhub.app.utils.ImageCache.java
private AsyncImageLoader getAsyncLoader(ImageView imageView) { AsyncImageLoader loader = null;/*from w w w . j a va 2s. c om*/ Object tag = imageView.getTag(); if (tag instanceof AsyncImageLoader) { loader = (AsyncImageLoader) tag; } return loader; }
From source file:info.shibafu528.gallerymultipicker.ThumbnailAsyncTask.java
ThumbnailAsyncTask(ImageView imageView) { this.imageView = new WeakReference<>(imageView); this.tag = (String) imageView.getTag(); }
From source file:info.shibafu528.gallerymultipicker.ThumbnailAsyncTask.java
@Override protected void onPostExecute(Bitmap bitmap) { ImageView imageView = this.imageView != null ? this.imageView.get() : null; if (imageView != null && tag.equals(imageView.getTag())) { imageView.setImageBitmap(bitmap); }//from w w w . ja v a 2s. c o m }