Example usage for android.widget ImageView getDrawable

List of usage examples for android.widget ImageView getDrawable

Introduction

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

Prototype

public Drawable getDrawable() 

Source Link

Document

Gets the current Drawable, or null if no Drawable has been assigned.

Usage

From source file:org.alfresco.mobile.android.application.managers.RenditionManagerImpl.java

private static urlRetrieverThread getBitmapThread(ImageView imageView) {
    if (imageView != null) {
        final Drawable drawable = imageView.getDrawable();
        if (drawable instanceof AsyncDrawable) {
            final AsyncDrawable asyncDrawable = (AsyncDrawable) drawable;
            return asyncDrawable.getBitmapWorkerTask();
        }/*  w w  w. j a  va 2  s  .  c  o  m*/
    }
    return null;
}

From source file:com.nf2m.util.ImageWorker.java

/**
 * @param imageView Any imageView/*from   w  ww .  j av a  2 s. c  om*/
 * @return Retrieve the currently active work task (if any) associated with this imageView.
 * null if there is no such task.
 */
@Nullable
private static BitmapWorkerTask getBitmapWorkerTask(@Nullable ImageView imageView) {
    if (imageView != null) {
        final Drawable drawable = imageView.getDrawable();
        if (drawable instanceof AsyncDrawable) {
            final AsyncDrawable asyncDrawable = (AsyncDrawable) drawable;
            return asyncDrawable.getBitmapWorkerTask();
        }
    }
    return null;
}

From source file:com.aapbd.utils.image.CacheImageDownloader.java

/**
 * @param imageView//www. java2s. 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(final ImageView imageView) {
    if (imageView != null) {
        final Drawable drawable = imageView.getDrawable();
        if (drawable instanceof DownloadedDrawable) {
            final DownloadedDrawable downloadedDrawable = (DownloadedDrawable) drawable;
            return downloadedDrawable.getBitmapDownloaderTask();
        }
    }
    return null;
}

From source file:air.com.snagfilms.utils.ImageWorker.java

/**
 * @param imageView//from ww  w .j a v  a  2 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 = imageView.getDrawable();
        if (drawable instanceof AsyncDrawable) {
            final AsyncDrawable asyncDrawable = (AsyncDrawable) drawable;
            return asyncDrawable.getBitmapWorkerTask();
        }
    }
    return null;
}

From source file:com.developer4droid.contactslister.backend.image_load.EnhancedImageDownloader.java

/**
 * @param imageView Any imageView/*from   ww  w . j  ava 2s.  c  o m*/
 * @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) {
        Drawable drawable = imageView.getDrawable();
        if (drawable instanceof EnhDownloadedDrawable) {
            EnhDownloadedDrawable downloadedDrawable = (EnhDownloadedDrawable) drawable;
            return downloadedDrawable.getBitmapDownloaderTask();
        }
    }
    return null;
}

From source file:com.example.ustc_pc.myapplication.heightPerformanceImageView.ImageWorker.java

/**
 * @param imageView Any imageView/*from  w  ww . j  a va  2  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 BitmapWorkerTaskImageView getBitmapWorkerTask(ImageView imageView) {
    if (imageView != null) {
        final Drawable drawable = imageView.getDrawable();
        if (drawable instanceof AsyncDrawable) {
            final AsyncDrawable asyncDrawable = (AsyncDrawable) drawable;
            return asyncDrawable.getBitmapWorkerTask();
        }
    }
    return null;
}

From source file:Main.java

/**
 * @see "http://blog.peterkuterna.net/2011/09/simple-crossfade-on-imageview.html"
 * with modifications by Thomas Suarez./*from  w  ww.  j av a 2s. c  o m*/
 */
public static void setImageDrawableWithFade(final Activity context, final ImageView imageView,
        final String drawableName, final int durationMillis) {
    int resId = getDrawableId(context, drawableName); // get new drawable resource
    Drawable drawable;
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        drawable = context.getResources().getDrawable(resId, context.getTheme());
    } else {
        drawable = context.getResources().getDrawable(resId); // this is deprecated starting in Android 5.0 Lollipop
    }

    final Drawable currentDrawable = imageView.getDrawable();
    final Drawable newDrawable = drawable;

    Runnable r = new Runnable() {
        @Override
        public void run() {
            if (currentDrawable != null) {
                Drawable[] arrayDrawable = new Drawable[2];
                arrayDrawable[0] = currentDrawable;
                arrayDrawable[1] = newDrawable;
                TransitionDrawable transitionDrawable = new TransitionDrawable(arrayDrawable);
                transitionDrawable.setCrossFadeEnabled(true);
                imageView.setImageDrawable(transitionDrawable);
                transitionDrawable.startTransition(durationMillis);
            } else {
                imageView.setImageDrawable(newDrawable);
            }
        }
    };
    context.runOnUiThread(r);
}

From source file:com.appeaser.sublimepickerlibrary.utilities.SUtils.java

public static void setImageTintList(ImageView imageView, ColorStateList colorStateList) {
    if (isApi_21_OrHigher()) {
        imageView.setImageTintList(colorStateList);
    } else {/*w  w w  . j a  va 2  s.co  m*/
        Drawable drawable = imageView.getDrawable();

        if (drawable != null) {
            Drawable wrapped = DrawableCompat.wrap(drawable);
            DrawableCompat.setTintList(wrapped, colorStateList);
            imageView.setImageDrawable(wrapped);
        }
    }
}

From source file:com.sky.drovik.player.bitmapfun.ImageWorker.java

private static ImageLoaderTask getVideoThumbnailWorkerTask(ImageView imageView) {
    if (imageView != null) {
        final Drawable drawable = imageView.getDrawable();
        if (drawable instanceof AsyncThumbnailDrawable) {
            final AsyncThumbnailDrawable asyncDrawable = (AsyncThumbnailDrawable) drawable;
            return asyncDrawable.getBitmapWorkerTask();
        }//w  w  w  .j  a v a 2  s.  c o m
    }
    return null;
}

From source file:com.vinay.volley.lazyload.ImageLoader.java

/**
 * Sets a {@link android.graphics.Bitmap} to an {@link android.widget.ImageView} using a fade-in animation. If there
 * is a {@link android.graphics.drawable.Drawable} already set on the ImageView then use that as the image to fade
 * from. Otherwise fade in from a transparent Drawable.
 *//*w w  w  .  ja v  a 2  s .co m*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
private static void setImageBitmap(final ImageView imageView, final Bitmap bitmap, Resources resources,
        boolean fadeIn) {

    // If we're fading in and on HC MR1+
    if (fadeIn && hasHoneycombMR1()) {
        // Use ViewPropertyAnimator to run a simple fade in + fade out animation to update the
        // ImageView
        imageView.animate().scaleY(0.95f).scaleX(0.95f).alpha(0f)
                .setDuration(imageView.getDrawable() == null ? 0 : HALF_FADE_IN_TIME)
                .setListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        imageView.setImageBitmap(bitmap);
                        imageView.animate().alpha(1f).scaleY(1f).scaleX(1f).setDuration(HALF_FADE_IN_TIME)
                                .setListener(null);
                    }
                });
    } else if (fadeIn) {
        // Otherwise use a TransitionDrawable to fade in
        Drawable initialDrawable;
        if (imageView.getDrawable() != null) {
            initialDrawable = imageView.getDrawable();
        } else {
            initialDrawable = transparentDrawable;
        }
        BitmapDrawable bitmapDrawable = new BitmapDrawable(resources, bitmap);
        // Use TransitionDrawable to fade in
        final TransitionDrawable td = new TransitionDrawable(
                new Drawable[] { initialDrawable, bitmapDrawable });
        imageView.setImageDrawable(td);
        td.startTransition(ANIMATION_FADE_IN_TIME);
    } else {
        // No fade in, just set bitmap directly
        imageView.setImageBitmap(bitmap);
    }
}