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.ruoogle.base.imgload.ImageWorker.java

/**
 * Called when the processing is complete and the final bitmap should be set on the ImageView.
 *
 * @param imageView//from   w w  w. ja va  2 s  .  co  m
 * @param bitmap
 */
private void setImageBitmap(ImageView imageView, Drawable aDrawable) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drwabale and the final bitmap
        final TransitionDrawable td = new TransitionDrawable(
                new Drawable[] { new ColorDrawable(android.R.color.transparent), aDrawable });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap));
        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {

        /*aDrawable??*/
        if (aDrawable == null) {
            imageView.setImageBitmap(mLoadingBitmap);
        } else {
            imageView.setImageDrawable(aDrawable);
        }
    }
}

From source file:com.vstar.lib.io.ImageWorker.java

/**
 * Called when the processing is complete and the final bitmap should be set
 * on the ImageView./*from  w  w  w . java 2  s .  c  o  m*/
 * 
 * @param imageView
 * @param bitmap
 */
private void setImageBitmap(ImageView imageView, Bitmap bitmap) {
    if (mFadeInBitmap) {
        // Use TransitionDrawable to fade in
        final TransitionDrawable td = new TransitionDrawable(new Drawable[] {
                new ColorDrawable(android.R.color.transparent), new BitmapDrawable(mResources, bitmap) });
        // noinspection deprecation
        imageView.setBackgroundDrawable(imageView.getDrawable());
        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageBitmap(bitmap);
    }
}

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

/**
 * Called when the processing is complete and the final drawable should be
 * set on the ImageView.//from  ww w  . ja  v  a2 s  . co  m
 *
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(@NonNull ImageView imageView, Drawable drawable) {
    if (mFadeInBitmap) {
        // Transition drawable with UriObserver transparent drawable and the final drawable
        final TransitionDrawable td = new TransitionDrawable(new Drawable[] {
                new ColorDrawable(ContextCompat.getColor(mContext, 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);
    }
    if (ImageDetailFragment.mProgress != null) {
        ImageDetailFragment.mProgress.setVisibility(View.GONE);
    }
}

From source file:com.androidpi.bricks.gallery.lru.cache.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be set on the ImageView.
 *
 * @param imageView// ww  w  . j a  v a2s .  com
 * @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(imageView.getResources().getColor(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:com.example.mohmurtu.registration.imagesUtil.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be 
 * set on the ImageView.//from   ww  w . j  ava  2  s  . co m
 *
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable) {
    if (mFadeInBitmap) {
        System.out.println("Doing some thing here");
        // 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 {
        System.out.println("Bitmap is getting drawable");
        imageView.setImageDrawable(drawable);
    }
}

From source file:org.zywx.wbpalmstar.plugin.uexscrawl.PhotoScrawlActivity.java

private View getColorImageView(int color) {
    final ImageView imageView = new ImageView(this);
    int width = EUExUtil.dipToPixels(32);
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(width, width);
    int margin = EUExUtil.dipToPixels(4);
    lp.leftMargin = margin;/*ww  w  . j  a va2  s. com*/
    lp.rightMargin = margin;
    imageView.setLayoutParams(lp);
    imageView.setTag(color);
    GradientDrawable colorDrawable = new GradientDrawable();
    colorDrawable.setColor(color);
    colorDrawable.setCornerRadius(8);
    if (Build.VERSION.SDK_INT < 16) {
        imageView.setBackgroundDrawable(colorDrawable);
    } else {
        imageView.setBackground(colorDrawable);
    }
    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mCurrnetColor = (int) imageView.getTag();
            mScrawlImageView.setPaintColor(mCurrnetColor);
            mPreviewView.setColor(mCurrnetColor);
        }
    });
    return imageView;
}

From source file:com.android.beez.loadimage.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be
 * set on the ImageView./* www . j a  v  a 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), drawable });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap));

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

From source file:com.krava.vkmessenger.domain.image.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be
 * set on the ImageView.//from  w  ww.  j  a  v a2  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(imageView.getResources().getColor(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:com.tangjd.displayingbitmaps.util.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be
 * set on the ImageView.//w w  w . ja  v a 2s  .c om
 *
 * @param imageView
 * @param drawable
 */
@SuppressWarnings("deprecation")
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(imageView.getContext().getResources().getColor(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:com.android.mms.rcs.FavoriteDetailAdapter.java

private void initImageMsgView(LinearLayout linearLayout) {
    String thumbPath = mCursor//from  w w  w  .j  a v  a2 s  .co m
            .getString(mCursor.getColumnIndexOrThrow(FavoriteMessageProvider.FavoriteMessage.THUMBNAIL));
    String fileName = mCursor
            .getString(mCursor.getColumnIndexOrThrow(FavoriteMessageProvider.FavoriteMessage.FILE_NAME));
    thumbPath = RcsUtils.formatFilePathIfExisted(thumbPath);
    fileName = RcsUtils.formatFilePathIfExisted(fileName);
    ImageView imageView = (ImageView) linearLayout.findViewById(R.id.image_view);
    Bitmap thumbPathBitmap = null;
    Bitmap filePathBitmap = null;
    if (!TextUtils.isEmpty(thumbPath)) {
        thumbPathBitmap = RcsUtils.decodeInSampleSizeBitmap(thumbPath);
    } else if (!TextUtils.isEmpty(fileName)) {
        filePathBitmap = RcsUtils.decodeInSampleSizeBitmap(fileName);
    }
    if (thumbPathBitmap != null) {
        imageView.setBackgroundDrawable(new BitmapDrawable(thumbPathBitmap));
    } else if (filePathBitmap != null) {
        imageView.setBackgroundDrawable(new BitmapDrawable(filePathBitmap));
    } else {
        imageView.setBackgroundResource(R.drawable.ic_attach_picture_holo_light);
    }
}