Example usage for android.widget ImageView setImageDrawable

List of usage examples for android.widget ImageView setImageDrawable

Introduction

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

Prototype

public void setImageDrawable(@Nullable Drawable drawable) 

Source Link

Document

Sets a drawable as the content of this ImageView.

Usage

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// w  w  w.  jav  a  2 s  .c o m
 * @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:com.abcs.sociax.gimgutil.ImageWorker.java

/**
 * Called when the processing is complete and the final bitmap should be set
 * on the ImageView.//from   w ww.java 2  s  .  c  o  m
 * 
 * @param imageView
 * @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.setImageDrawable(new BitmapDrawable(mResources, mLoadingBitmap));

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

From source file:com.ehret.mixit.fragment.SessionDetailFragment.java

private void addSpeakerInfo(Talk conference) {
    //On vide les lments
    sessionPersonList.removeAllViews();//from   w  w w  .j  a  v  a 2  s .  com

    List<Member> speakers = new ArrayList<>();
    for (Speaker member : conference.getSpeakers()) {
        Member membre = MembreFacade.getInstance().getMembre(getActivity(), TypeFile.speaker.name(),
                member.getIdMember());

        if (membre != null) {
            speakers.add(membre);
        }
    }

    //On affiche les liens que si on a recuperer des choses
    if (!speakers.isEmpty()) {
        //On utilisait auparavant une liste pour afficher ces lments dans la page mais cette liste
        //empche d'avoir un ScrollView englobant pour toute la page. Nous utilisons donc un tableau

        //On ajoute un table layout
        TableLayout.LayoutParams tableParams = new TableLayout.LayoutParams(
                TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT);
        TableLayout tableLayout = new TableLayout(getActivity().getBaseContext());
        tableLayout.setLayoutParams(tableParams);

        if (mInflater != null) {
            for (final Member membre : speakers) {
                LinearLayout row = (LinearLayout) mInflater.inflate(R.layout.item_person, tableLayout, false);
                row.setBackgroundResource(R.drawable.row_transparent_background);

                //Dans lequel nous allons ajouter le contenu que nous faisons mapp dans
                TextView userName = (TextView) row.findViewById(R.id.person_user_name);
                TextView descriptif = (TextView) row.findViewById(R.id.person_shortdesciptif);
                TextView level = (TextView) row.findViewById(R.id.person_level);
                ImageView profileImage = (ImageView) row.findViewById(R.id.person_user_image);

                userName.setText(membre.getCompleteName());

                if (membre.getShortDescription() != null) {
                    descriptif.setText(membre.getShortDescription().trim());
                }

                //Recuperation de l'mage liee au profil
                Bitmap image = FileUtils.getImageProfile(getActivity(), membre);
                if (image == null) {
                    profileImage.setImageDrawable(getResources().getDrawable(R.drawable.person_image_empty));
                } else {
                    //On regarde dans les images embarquees
                    profileImage.setImageBitmap(image);
                }

                row.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        ((HomeActivity) getActivity()).changeCurrentFragment(PeopleDetailFragment
                                .newInstance(TypeFile.speaker.toString(), membre.getLogin(), 7),
                                TypeFile.speaker.toString());
                    }
                });

                tableLayout.addView(row);
            }
        }
        sessionPersonList.addView(tableLayout);
    }
}

From source file:com.cnblogs.app.bitmap.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be 
 * set on the ImageView./*from  ww  w  .java 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(android.R.color.transparent), drawable });
        // Set background to loading bitmap
        imageView.setBackground(new BitmapDrawable(mResources, mLoadingBitmap));

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

From source file:com.amachikhin.vkmachikhin.utils.image_cache.ImageWorker.java

/**
 * Load an image specified by the data parameter into an ImageView (override
 * {@link ImageWorker#processBitmap(Object)} to define the processing logic). A memory and
 * disk cache will be used if an {@link ImageCache} has been added using
 * {@link ImageWorker#addImageCache(ImageCache.ImageCacheParams)}. 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.
 *///w w w  . j  av a2 s  . com
public void loadImage(Object data, ImageView imageView) {
    if (data == null) {
        return;
    }

    BitmapDrawable value = null;

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

    if (value != null) {
        // Bitmap found in memory cache
        imageView.setImageDrawable(value);
    } else if (cancelPotentialWork(data, imageView)) {
        //BEGIN_INCLUDE(execute_background_task)
        final BitmapWorkerTask task = new BitmapWorkerTask(data, imageView);
        final AsyncDrawable asyncDrawable = new AsyncDrawable(mResources, mLoadingBitmap, task);
        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.THREAD_POOL_EXECUTOR/*DUAL_THREAD_EXECUTOR*/);
        //END_INCLUDE(execute_background_task)
    }
}

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.
 * /* w  w w  . j  a va2s.  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:com.codingPower.framework.worker.ImageWorker.java

/**
 * Called when the processing is complete and the final bitmap should be set on the ImageView.
 *
 * @param imageView//from w  w  w  .jav 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:com.corebase.android.bitmap.util.ImageWorker.java

/**
 * Load an image specified by the data parameter into an ImageView (override
 * {@link 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  . ja va2s  .  com*/
 * {@link ImageWorker#addImageCache(FragmentManager, ImageCache.ImageCacheParams)}
 * . 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, boolean isSaveFlow,
        ImageFetcher.LoadImageFailureListener loadImageFailureListener) {
    if (data == null) {
        return;
    }

    BitmapDrawable value = null;

    if (mImageCache != null) {
        value = mImageCache.getBitmapFromMemCache(String.valueOf(data));
    }
    if (value != null) {
        // Bitmap found in memory cache
        imageView.setImageDrawable(value);
    } else if (cancelPotentialWork(data, imageView)) {
        final BitmapWorkerTask task = new BitmapWorkerTask(imageView, isSaveFlow);
        final AsyncDrawable asyncDrawable = new AsyncDrawable(mResources, mLoadingBitmap, task);
        if (loadImageFailureListener != null && asyncDrawable != null) {
            ImageWorker.loadImageFailureListener = loadImageFailureListener;
        }
        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, data);
    }
}

From source file:android.bitmap.util.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be 
 * set on the ImageView.//from  w  ww . jav a 2 s.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(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.andreaszeiser.bob.ImageWorker.java

/**
 * Called when the processing is complete and the final bitmap should be set
 * on the ImageView.//from ww  w  . ja v a2  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.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageBitmap(bitmap);
    }
}