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.atgc.cotton.util.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be
 * set on the ImageView.//from w w w  . j  a  va 2s  . c om
 *
 * @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(mResources.getColor(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.jackleeentertainment.oq.ui.layout.fragment.util.ImageLoader.java

/**
 * Called when the processing is complete and the final bitmap should be set on the ImageView.
 *
 * @param imageView The ImageView to set the bitmap to.
 * @param bitmap The new bitmap to set.//from w ww.j  a  va2  s . co  m
 */
private void setImageBitmap(ImageView imageView, Bitmap bitmap) {
    if (mFadeInBitmap) {
        // Transition drawable to fade from loading bitmap to final bitmap
        final TransitionDrawable td = new TransitionDrawable(new Drawable[] {
                new ColorDrawable(App.getContext().getResources().getColor(android.R.color.transparent)),
                new BitmapDrawable(mResources, bitmap) });
        imageView.setBackgroundDrawable(imageView.getDrawable());
        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageBitmap(bitmap);
    }
}

From source file:com.android.simpleimageloader.image.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be set on the ImageView.
 * //from w  ww .j  a  va 2s .  c  o m
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable, DisplayOptions options) {
    if (options.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, options.mLoadingBitmap));

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

From source file:br.org.funcate.dynamicforms.views.GPictureView.java

private ImageView getImageView(final Context context, Bitmap photo, String uuid) {
    ImageView imageView = new ImageView(context);
    imageView.setLayoutParams(new LinearLayout.LayoutParams(thumbnailWidth, thumbnailHeight));
    imageView.setPadding(5, 5, 5, 5);// w  w  w .j a  va2  s. co m
    imageView.setImageBitmap(photo);
    imageView.setBackgroundDrawable(getResources().getDrawable(R.drawable.border_black_1px));
    imageView.setTag(uuid);
    imageView.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            String photoId = (String) v.getTag();

            FragmentActivity activity = mFragmentDetail.getActivity();
            Intent intent = new Intent(activity, PictureActivity.class);

            if (addedIdsToImageViews.containsKey(photoId)) {// pictures on session
                intent.putExtra(FormUtilities.PICTURE_PATH_VIEW, addedIdsToImageViews.get(photoId));
            } else if (_pictures.containsKey(photoId)) {// pictures from database

                Map<String, String> imagePaths = _pictures.get(photoId);
                String imagePath = imagePaths.get("display");

                intent.putExtra(FormUtilities.PICTURE_DB_VIEW, imagePath);// Image temporary path
            }
            if (intent.hasExtra(FormUtilities.PICTURE_PATH_VIEW)
                    || intent.hasExtra(FormUtilities.PICTURE_DB_VIEW)) {
                intent.putExtra(FormUtilities.PICTURE_BITMAP_ID, photoId);
                activity.startActivityForResult(intent, PICTURE_VIEW_RESULT);
            } else
                Toast.makeText(getContext(), "Fail, the picture not found.", Toast.LENGTH_LONG).show();

            /*
            JSONArray form = null;
            try {
            form = mFragmentDetail.getSelectedForm();
            } catch (JSONException jse) {
            jse.printStackTrace();
            Toast.makeText(getContext(), jse.getMessage(), Toast.LENGTH_LONG).show();
            }
                    
            if (form != null) {
            try {
                String json = encodeToJson();
                FormUtilities.updatePicture(form, json);
            } catch (JSONException e) {
                e.printStackTrace();
            }catch (Exception e) {
                e.printStackTrace();
            }
            }
            try {
            refresh(getContext());
            } catch (Exception e) {
            e.printStackTrace();
            Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_LONG).show();
            }*/
            /**
             * open in markers to edit it
             */
            // MarkersUtilities.launchOnImage(context, image);
            /* try {
                 Intent intent = new Intent();
                 intent.setAction(Intent.ACTION_VIEW);
                 Image image = imagesDbHelper.getImage(imageIdLong);
                 File tempDir = ResourcesManager.getInstance(context).getTempDir();
                 String ext = ".jpg";
                 if (image.getName().endsWith(".png"))
                     ext = ".png";
                 File imageFile = new File(tempDir, ImageUtilities.getTempImageName(ext));
                 byte[] imageData = imagesDbHelper.getImageData(image.getId());
                 ImageUtilities.writeImageDataToFile(imageData, imageFile.getAbsolutePath());
                    
                 intent.setDataAndType(Uri.fromFile(imageFile), "image*//**//*"); //$NON-NLS-1$
                                                                             context.startActivity(intent);
                                                                             } catch (Exception e) {
                                                                             //GPLog.error(this, null, e);
                                                                             Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_LONG).show();
                                                                             }*/
            //Toast.makeText(getContext(), "Implement this action", Toast.LENGTH_LONG).show();

        }
    });
    return imageView;
}

From source file:cn.mimail.sdk.net.image.ImageWorker.java

/**
 * Called when the processing is complete and the final bitmap should be set on the ImageView.
 *
 * @param imageView//from  ww  w.  j av  a 2 s. c om
 * @param bitmap
 */
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(android.R.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:fanx.instl.utils.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be 
 * set on the ImageView.//from   w  w  w .  j ava  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[] { new ColorDrawable(00000000), 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.mp.common.photo.ImageWorker.java

/**
 * Called when the processing is complete and the final bitmap should be set on the ImageView.
 *
 * @param imageView/*from   ww  w  . j a v a 2 s. com*/
 * @param bitmap
 */
@SuppressWarnings("deprecation")
protected 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(android.R.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.wl.pluto.plutochat.chat.cache.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be
 * set on the ImageView./*  ww  w .  j  av a  2 s  . c  om*/
 *
 * @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(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:android.bitmap.util.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be 
 * set on the ImageView./* w ww .  jav  a 2 s  . c  o  m*/
 *
 * @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(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:me.crossle.imagefetcher.ImageWorker.java

/**
 * Called when the processing is complete and the final bitmap should be set on the ImageView.
 *
 * @param imageView/*w  ww . j a v  a 2s  .  co  m*/
 * @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(android.R.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);
    }
}