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

@ViewDebug.ExportedProperty
public Object getTag() 

Source Link

Document

Returns this view's tag.

Usage

From source file:com.roach.framework.http.bitmap.ImageWorker.java

public void recycleBitmap(ImageView iv) {
    BitmapWorkerTask bitmapWorkerTask = null;
    if (iv.getTag() != null && (iv.getTag() instanceof BitmapWorkerTask)) {
        bitmapWorkerTask = (BitmapWorkerTask) iv.getTag();
    }//from   ww w.j a  v a  2  s  . co  m
    if (bitmapWorkerTask != null) {
        Bitmap bitmap = bitmapWorkerTask.getBitmap();
        iv.setImageBitmap(null);
        if (bitmap != null && !bitmap.isRecycled()) {
            bitmap.recycle();
        }
        iv.setTag(null);
        bitmapWorkerTask = null;
    }
}

From source file:cc.softwarefactory.lokki.android.activities.MainActivity.java

public void showUserInMap(View view) { // Used in Contacts

    if (view == null) {
        return;//from   w  w w.j ava 2 s  . co  m
    }
    ImageView image = (ImageView) view;
    String email = (String) image.getTag();
    showUserInMap(email);
}

From source file:com.conferenceengineer.android.iosched.util.ImageLoader.java

public ImageContainer get(String requestUrl, ImageView imageView, Drawable placeHolder, int maxWidth,
        int maxHeight) {

    // Find any old image load request pending on this ImageView (in case this view was
    // recycled)//  w  w  w.j  a  v  a 2 s .c  o  m
    ImageContainer imageContainer = imageView.getTag() != null && imageView.getTag() instanceof ImageContainer
            ? (ImageContainer) imageView.getTag()
            : null;

    // Find image url from prior request
    String recycledImageUrl = imageContainer != null ? imageContainer.getRequestUrl() : null;

    // If the new requestUrl is null or the new requestUrl is different to the previous
    // recycled requestUrl
    if (requestUrl == null || !requestUrl.equals(recycledImageUrl)) {
        if (imageContainer != null) {
            // Cancel previous image request
            imageContainer.cancelRequest();
            imageView.setTag(null);
        }
        if (requestUrl != null) {
            // Queue new request to fetch image
            imageContainer = get(requestUrl, getImageListener(mResources, imageView, placeHolder, mFadeInImage),
                    maxWidth, maxHeight);
            // Store request in ImageView tag
            imageView.setTag(imageContainer);
        } else {
            imageView.setImageDrawable(placeHolder);
            imageView.setTag(null);
        }
    }

    return imageContainer;
}

From source file:com.baseproject.image.ImageWorker.java

/**
 * Called when the processing is complete and the final bitmap should be set
 * on the ImageView./* w w  w  .j  a v  a2  s. c  om*/
 * 
 * @param imageView
 * @param bitmap
 */
@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
private void setImageBitmap(ImageView imageView, Bitmap bitmap) {
    if (mFadeInBitmap) {
        if (imageView.getTag() instanceof String && "no_animation".equals(String.valueOf(imageView.getTag()))) {
            imageView.setImageBitmap(bitmap);
        } else {
            // Transition drawable with a transparent drwabale and the final
            // bitmap
            TransitionDrawable td = new TransitionDrawable(
                    new Drawable[] { new ColorDrawable(android.R.color.transparent),
                            new BitmapDrawable(mContext.getResources(), bitmap) });
            final WeakReference<TransitionDrawable> tdReference = new WeakReference<TransitionDrawable>(td);
            td = null;
            // Set background to loading bitmap
            final BitmapDrawable bd = new BitmapDrawable(mContext.getResources(), mLoadingBitmap);
            if (Build.VERSION.SDK_INT >= 16) {
                imageView.setBackground(bd);
            } else {
                imageView.setBackgroundDrawable(bd);

            }
            if (null != tdReference.get()) {
                imageView.setImageDrawable(tdReference.get());
                tdReference.get().startTransition(FADE_IN_TIME);
            }
        }
    } else {
        imageView.setImageBitmap(bitmap);
    }

}

From source file:com.likou.util.NImageLoader.java

public ImageContainer get(String requestUrl, ImageView imageView, Drawable placeHolder, int maxWidth,
        int maxHeight) {

    // Find any old image load request pending on this ImageView (in case
    // this view was
    // recycled)/*from www.  j  a v  a  2  s  .  c o  m*/
    ImageContainer imageContainer = imageView.getTag() != null && imageView.getTag() instanceof ImageContainer
            ? (ImageContainer) imageView.getTag()
            : null;

    // Find image url from prior request
    String recycledImageUrl = imageContainer != null ? imageContainer.getRequestUrl() : null;

    // If the new requestUrl is null or the new requestUrl is different to
    // the previous
    // recycled requestUrl
    if (requestUrl == null || !requestUrl.equals(recycledImageUrl)) {
        if (imageContainer != null) {
            // Cancel previous image request
            imageContainer.cancelRequest();
            imageView.setTag(null);
        }
        if (requestUrl != null) {
            // Queue new request to fetch image
            imageContainer = get(requestUrl, getImageListener(mResources, imageView, placeHolder, mFadeInImage),
                    maxWidth, maxHeight);
            // Store request in ImageView tag
            imageView.setTag(imageContainer);
        } else {
            imageView.setImageDrawable(placeHolder);
            imageView.setTag(null);
        }
    }

    return imageContainer;
}

From source file:com.app.secnodhand.imageutil.ImageWorker.java

/**
 * Load an image specified by the data parameter into an ImageView (override
 * {@link com.app.secnodhand.imageutil.ImageWorker#processBitmap(Object)} to define the processing
 * logic). A memory and disk cache will be used if an {@link ImageCache} has
 * been added using/*w w  w  .  j ava2 s. c  om*/
 *
  * . If the image is found in the memory cache, it is set immediately,
 * otherwise an {@link AsyncTask} will be created to asynchronously load the
 * bitmap.
 * 
 * @param data
 *            The URL of the image to download.
 * @param imageView
 *            The ImageView to bind the downloaded image to.
 */
public void loadImage(Object data, ImageView imageView) {
    Log.d("MyMain", "tag=" + imageView.getTag());
    loadImage(data, imageView, null);
}

From source file:mobisocial.musubi.ImageGalleryActivity.java

void injectImage(Uri fileUri, final ImageView imageView, final DbObj mObj) {
    try {/*from w  w w.j a va  2 s  .c  om*/
        if ((Long) imageView.getTag() == mObj.getLocalId()) {
            if (DBG)
                Log.d(TAG, "Opening HD file " + fileUri);

            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    if ((Long) imageView.getTag() == mObj.getLocalId()) {
                        cleanCorralImage();
                    }
                }
            });

            final BitmapDrawable image = getBitmap(fileUri);
            if (image == null) {
                return;
            }

            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    if ((Long) imageView.getTag() == mObj.getLocalId()) {
                        mCorralImage = image;
                        mOriginalImage = (BitmapDrawable) imageView.getDrawable();
                        mCorralView = imageView;
                        imageView.setImageDrawable(image);
                    }
                }
            });
        }
    } catch (OutOfMemoryError e) {
        App.getUsageMetrics(this).report(e);
        Log.e(TAG, "error loading data from corral", e);
    }
}

From source file:com.android.volley.cache.plus.SimpleImageLoader.java

public ImageContainer get(String requestUrl, ImageView imageView, Drawable placeHolder, int maxWidth,
        int maxHeight) {

    // Find any old image load request pending on this ImageView (in case this view was
    // recycled)// ww w. j ava 2  s  .co  m
    ImageContainer imageContainer = imageView.getTag() != null && imageView.getTag() instanceof ImageContainer
            ? (ImageContainer) imageView.getTag()
            : null;

    // Find image url from prior request
    String recycledImageUrl = imageContainer != null ? imageContainer.getRequestUrl() : null;

    // If the new requestUrl is null or the new requestUrl is different to the previous
    // recycled requestUrl
    if (requestUrl == null || !requestUrl.equals(recycledImageUrl)) {
        if (imageContainer != null) {
            // Cancel previous image request
            imageContainer.cancelRequest();
            imageView.setTag(null);
        }
        if (requestUrl != null) {
            // Queue new request to fetch image
            imageContainer = get(requestUrl,
                    getImageListener(getResources(), imageView, placeHolder, mFadeInImage), maxWidth,
                    maxHeight);
            // Store request in ImageView tag
            imageView.setTag(imageContainer);
        } else {
            if (!(imageView instanceof PhotoView)) {
                imageView.setImageDrawable(placeHolder);
            }
            imageView.setTag(null);
        }
    }

    return imageContainer;
}

From source file:com.android.volley.cache.plus.SimpleImageLoader.java

public ImageContainer set(String requestUrl, ImageView imageView, Drawable placeHolder, int maxWidth,
        int maxHeight, Bitmap bitmap) {

    // Find any old image load request pending on this ImageView (in case this view was
    // recycled)//  w w  w .j a  va 2s.com
    ImageContainer imageContainer = imageView.getTag() != null && imageView.getTag() instanceof ImageContainer
            ? (ImageContainer) imageView.getTag()
            : null;

    // Find image url from prior request
    //String recycledImageUrl = imageContainer != null ? imageContainer.getRequestUrl() : null;

    if (imageContainer != null) {
        // Cancel previous image request
        imageContainer.cancelRequest();
        imageView.setTag(null);
    }
    if (requestUrl != null) {
        // Queue new request to fetch image
        imageContainer = set(requestUrl, getImageListener(getResources(), imageView, placeHolder, mFadeInImage),
                maxWidth, maxHeight, bitmap);
        // Store request in ImageView tag
        imageView.setTag(imageContainer);
    } else {
        if (!(imageView instanceof PhotoView)) {
            imageView.setImageDrawable(placeHolder);
        }
        imageView.setTag(null);
    }

    return imageContainer;
}

From source file:com.android.volley.cache.SimpleImageLoader.java

public ImageContainer get(String requestUrl, ImageView imageView, Drawable placeHolder, int maxWidth,
        int maxHeight) {

    // Find any old image load request pending on this ImageView (in case this view was
    // recycled)//from  w  w  w.j  av a2s  . c  om
    ImageContainer imageContainer = imageView.getTag() != null && imageView.getTag() instanceof ImageContainer
            ? (ImageContainer) imageView.getTag()
            : null;

    // Find image url from prior request
    String recycledImageUrl = imageContainer != null ? imageContainer.getRequestUrl() : null;

    // If the new requestUrl is null or the new requestUrl is different to the previous
    // recycled requestUrl
    if (requestUrl == null || !requestUrl.equals(recycledImageUrl)) {
        if (imageContainer != null) {
            // Cancel previous image request
            imageContainer.cancelRequest();
            imageView.setTag(null);
        }
        if (requestUrl != null) {
            // Queue new request to fetch image
            imageContainer = get(requestUrl,
                    getImageListener(getResources(), imageView, placeHolder, mFadeInImage), maxWidth, maxHeight,
                    imageView.getScaleType());
            // Store request in ImageView tag
            imageView.setTag(imageContainer);
        } else {
            if (!(imageView instanceof PhotoView)) {
                imageView.setImageDrawable(placeHolder);
            }
            imageView.setTag(null);
        }
    }

    return imageContainer;
}