Example usage for android.widget ImageView setBackgroundDrawable

List of usage examples for android.widget ImageView setBackgroundDrawable

Introduction

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

Prototype

@Deprecated
public void setBackgroundDrawable(Drawable background) 

Source Link

Usage

From source file:com.ccz.viewimages.displayingbitmaps.util.ImageWorker.java

private void setImageDrawable(ImageView imageView, Drawable drawable, Bitmap transbitmap) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td = new TransitionDrawable(new Drawable[] {
                new ColorDrawable(mResources.getColor(android.R.color.transparent)), drawable });
        // Set background to loading bitmap
        if (null != transbitmap) {
            imageView.setBackgroundDrawable(new BitmapDrawable(mResources, transbitmap));
        }//w ww  .ja  v a2s.c o m

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageDrawable(drawable);
    }
}

From source file:haipeng.myalbum.imageload.ImageWorker.java

/**
 * Called when the processing is complete and the final bitmap should be set
 * on the ImageView./*from  w  w  w  .  ja  v  a 2s .  co m*/
 * 
 * @param imageView
 * @param bitmap
 */
@SuppressWarnings("deprecation")
private void setImageBitmap(ImageView imageView, Bitmap bitmap) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drwabale and the final
        // bitmap
        final TransitionDrawable td = new TransitionDrawable(new Drawable[] {
                new ColorDrawable(Color.TRANSPARENT), new BitmapDrawable(mResources, bitmap) });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageBitmap(bitmap);
    }
}

From source file:com.travel.ac.utils.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be
 * set on the ImageView.//from  www .j  a  v a  2  s  .co m
 *
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable) {
    /*
     * ??
     */
    if (mFadeInBitmap && mCircleImageView == null) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td = new TransitionDrawable(
                new Drawable[] { new ColorDrawable(android.R.color.transparent), drawable });
        // Set background to loading bitmap
        //

        if (mCircleImageView == null) {
            imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap));
            imageView.setImageDrawable(td);
        } else {
            ((CircleImageView) imageView).setImage(new BitmapDrawable(mResources, mLoadingBitmap));
            ((CircleImageView) imageView).setImage(td);
        }
        td.startTransition(FADE_IN_TIME);
    } else {
        if (mCircleImageView == null) {
            imageView.setImageDrawable(drawable);
        } else {
            ((CircleImageView) imageView).setImage(drawable);
        }
    }
}

From source file:com.gokuai.yunkuandroidsdk.imageutils.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be
 * set on the ImageView.//from   w  w w  .java 2s .  c o  m
 *
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td = new TransitionDrawable(
                new Drawable[] { new ColorDrawable(android.R.color.transparent),
                        isRoundDrawable
                                ? new BitmapDrawable(mResources,
                                        Util.makeRoundDrawable(drawable, GKApplication.getInstance(), false))
                                : drawable });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(isRoundDrawable
                ? new BitmapDrawable(mResources,
                        Util.makeRoundDrawable(drawable, GKApplication.getInstance(), false))
                : new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        if (isRoundDrawable) {

            imageView.setImageBitmap(Util.makeRoundDrawable(drawable, GKApplication.getInstance(), false));
        } else {

            imageView.setImageDrawable(drawable);
        }
    }
}

From source file:com.bitmaphandler.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be 
 * set on the ImageView.//from   w w  w. j  a v a 2s . co m
 *
 * @param imageView
 * @param drawable
 */
@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void setImageDrawable(ImageView imageView, Drawable drawable) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td = new TransitionDrawable(
                new Drawable[] { new ColorDrawable(android.R.color.transparent), drawable });
        if (useLoadingImage && mLoadingBitmap != null) {
            // Set background to loading bitmap
            if (imageView instanceof CircleImageView) {
                if (!Utils.hasJellyBean()) {
                    imageView.setBackgroundDrawable(new BitmapDrawable(mResources,
                            CircleImageView.getCroppedBitmap(mLoadingBitmap, mLoadingBitmap.getWidth())));
                } else {
                    imageView.setBackground(new BitmapDrawable(mResources,
                            CircleImageView.getCroppedBitmap(mLoadingBitmap, mLoadingBitmap.getWidth())));
                }
            } else if (imageView instanceof RoundedBitmapDisplayer) {
                if (!Utils.hasJellyBean()) {
                    imageView.setBackgroundDrawable(
                            new BitmapDrawable(mResources, RoundedBitmapDisplayer.roundCorners(mLoadingBitmap,
                                    imageView, ((RoundedBitmapDisplayer) imageView).getRoundPixle())));
                } else {
                    imageView.setBackground(new BitmapDrawable(mResources, RoundedBitmapDisplayer.roundCorners(
                            mLoadingBitmap, imageView, ((RoundedBitmapDisplayer) imageView).getRoundPixle())));
                }
            } else {
                if (!Utils.hasJellyBean()) {
                    imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap));
                } else {
                    imageView.setBackground(new BitmapDrawable(mResources, mLoadingBitmap));
                }
            }
        }

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageDrawable(drawable);
    }
}

From source file:com.alex.develop.cache.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be 
 * set on the ImageView./*from   w w  w  .jav a 2  s .  co m*/
 *
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td = new TransitionDrawable(new Drawable[] {

                // Edit by alex
                // before
                new ColorDrawable(android.R.color.transparent),
                // after
                //                            new ColorDrawable(Color.parseColor("#00000000")),
                // end

                drawable });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageDrawable(drawable);
    }
}

From source file:wb.android.workers.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be 
 * set on the ImageView.//from  w  w  w .  j a v  a 2s .  com
 *
 * @param imageView
 * @param drawable
 */
@SuppressWarnings("deprecation")
private void setImageDrawable(ImageView imageView, ProgressBar progressBar, Drawable drawable) {
    if (progressBar != null) {
        progressBar.setVisibility(View.GONE);
    }
    imageView.setVisibility(View.VISIBLE);
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td = new TransitionDrawable(
                new Drawable[] { new ColorDrawable(android.R.color.transparent), drawable });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageDrawable(drawable);
    }
}

From source file:cz.appvision.ebookreader.image.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be 
 * set on the ImageView./*from   w ww. java2  s  . c  o  m*/
 *
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td = new TransitionDrawable(
                new Drawable[] { new ColorDrawable(android.R.color.transparent), drawable });
        // Set background to loading bitmap
        Drawable currentDrawable = imageView.getDrawable();
        if (currentDrawable.getClass().equals(AsyncDrawable.class)) {
            String placeholderKey = ((AsyncDrawable) currentDrawable).getPlaceholderKey();
            imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap.get(placeholderKey)));
        }

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageDrawable(drawable);
    }
}

From source file:cn.com.wo.bitmap.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be 
 * set on the ImageView./*from  w  w  w .j  av  a2  s  .  c om*/
 *
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable, boolean isBackground) {
    if (mFadeInBitmap && !isBackground) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td = new TransitionDrawable(
                new Drawable[] { new ColorDrawable(android.R.color.transparent), drawable });
        // Set background to loading bitmap
        int index = 0;
        if (imageView.getTag() != null)
            index = (Integer) imageView.getTag();
        imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap[index]));
        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
        if (ImageFetcher.isDebug)
            Log.i(ImageFetcher.TAG, "setImageDrawable src");
    } else {
        if (isBackground) {
            if (ImageFetcher.isDebug)
                Log.i(ImageFetcher.TAG, "setImageDrawable isBackground");
            imageView.setBackgroundDrawable(null);
            imageView.setBackgroundDrawable(drawable);
        } else {
            if (ImageFetcher.isDebug)
                Log.i(ImageFetcher.TAG, "setImageDrawable src");
            imageView.setImageDrawable(drawable);
        }
    }
}

From source file:cn.com.wo.bitmap.ImageWorker.java

public void loadImage(String url, ImageView imageView, int radian, boolean isBackground) {
    if (url == null || url.trim().length() == 0 || !url.startsWith("http"))
        return;//  w  w  w. ja v a2 s.c om
    BitmapDrawable value = null;

    if (ImageFetcher.isDebug)
        Log.i(ImageFetcher.TAG, "loadImage " + url + "; isBg=" + isBackground);

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

    if (value != null) {
        // Bitmap found in memory cache
        //            imageView.setImageDrawable(value);
        if (isBackground) {
            imageView.setBackgroundDrawable(null);
            imageView.setBackgroundDrawable(value);
        } else
            imageView.setImageDrawable(value);
    } else if (cancelPotentialWork(url, imageView, isBackground)) {
        imageView.setTag(0);
        final BitmapWorkerTask task = new BitmapWorkerTask(imageView, radian, isBackground);
        final AsyncDrawable asyncDrawable = new AsyncDrawable(mResources, mLoadingBitmap[0], task);
        //            imageView.setImageDrawable(asyncDrawable);
        if (isBackground) {
            imageView.setBackgroundDrawable(null);
            imageView.setBackgroundDrawable(asyncDrawable);
        } else
            imageView.setImageDrawable(asyncDrawable);

        // 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, url);
    }
}