List of usage examples for android.widget ImageView setImageBitmap
@android.view.RemotableViewMethod public void setImageBitmap(Bitmap bm)
From source file:com.example.imagegallery.ImageDownloader2.java
/** * Download the specified image from the Internet and binds it to the provided ImageView. The * binding is immediate if the image is found in the cache and will be done asynchronously * otherwise. A null bitmap will be associated to the ImageView if an error occurs. * * @param url The URL of the image to download. * @param imageView The ImageView to bind the downloaded image to. *///w w w . j av a 2s. co m public void download(String url, ImageView imageView) { resetPurgeTimer(); Bitmap bitmap = getBitmapFromCache(url); if (bitmap == null) { forceDownload(url, imageView); } else { cancelPotentialDownload(url, imageView); imageView.setImageBitmap(bitmap); } }
From source file:adapters.images.ImageDownloader.java
/** * Download the specified image from the Internet and binds it to the provided ImageView. The * binding is immediate if the image is found in the cache and will be done asynchronously * otherwise. A null bitmap will be associated to the ImageView if an error occurs. * * @param url The URL of the image to download. * @param imageView The ImageView to bind the downloaded image to. *///from ww w . j a v a2s. co m public void download(String url, ImageView imageView) { resetPurgeTimer(); Bitmap bitmap = getBitmapFromCache(url); if (bitmap == null) { forceDownload(url, imageView); } else { cancelPotentialDownload(url, imageView); imageView.setImageBitmap(bitmap); } }
From source file:com.android.foodbook.utils.ImageDownloader.java
/** * Download the specified image from the Internet and binds it to the provided ImageView. The * binding is immediate if the image is found in the cache and will be done asynchronously * otherwise. A null bitmap will be associated to the ImageView if an error occurs. * * @param url The URL of the image to download. * @param imageView The ImageView to bind the downloaded image to. */// w w w. j a v a 2 s .co m public void download(String url, ImageView imageView) { //resetPurgeTimer(); Bitmap bitmap = getBitmapFromCache(url); if (bitmap == null) { forceDownload(url, imageView); } else { cancelPotentialDownload(url, imageView); imageView.setImageBitmap(bitmap); } }
From source file:com.slava.android.utils.ImageDownloader.java
private void externalDownload(String url, ImageView imageView, int cornersRadius, File file) { ExternalDownloaderTask task = new ExternalDownloaderTask(imageView, cornersRadius, url); task.execute(file.toString());//from www .java2 s .co m imageView.setImageBitmap(mLoadingIndicator); }
From source file:fr.eoidb.util.ImageDownloader.java
/** * Same as {@link #download(String, ImageView)}, with the possibility to provide an additional * cookie that will be used when the image will be retrieved. * * @param url The URL of the image to download. * @param imageView The ImageView to bind the downloaded image to. * @param cookie A cookie String that will be used by the http connection. *//*from www . j a v a 2 s. c om*/ public void download(String url, ImageView imageView, String cookie) { Bitmap bitmap = getBitmapFromCache(url, imageView.getContext()); if (bitmap == null) { forceDownload(url, imageView, cookie); } else { cancelPotentialDownload(url, imageView); imageView.setImageBitmap(bitmap); IconUtil.hideIconProgress(imageView); } }
From source file:fr.eoit.util.ImageDownloader.java
/** * Same as {@link #download(String, ImageView)}, with the possibility to provide an additional * cookie that will be used when the image will be retrieved. * * @param url The URL of the image to download. * @param imageView The ImageView to bind the downloaded image to. * @param cookie A cookie String that will be used by the http connection. *//* ww w . j av a 2s .c o m*/ public void download(String url, ImageView imageView, String cookie) { Bitmap bitmap = getBitmapFromCache(url, imageView.getContext()); if (bitmap == null) { forceDownload(url, imageView, cookie); } else { cancelPotentialDownload(url, imageView); imageView.setImageBitmap(bitmap); } }
From source file:com.andrewreitz.encryptedcamera.ui.adapter.GalleryAdapter.java
@Override public void bindView(File file, int position, View view) { ImageView imageView = ButterKnife.findById(view, R.id.gallery_imageview); // Cancel any pending thumbnail task, since this view is now bound // to new thumbnail final ThumbnailAsyncTask oldTask = (ThumbnailAsyncTask) view.getTag(); if (oldTask != null) { oldTask.cancel(false);//from w w w. j a v a2 s . c o m } // Cache enabled, try looking for cache hit final Bitmap cachedResult = cache.get(file.getName()); if (cachedResult != null) { imageView.setImageBitmap(cachedResult); return; } int rotation = 0; try { rotation = ImageRotation.getRotation(file); } catch (IOException e) { Timber.e(e, "Error using exif data"); } // If we arrived here, either cache is disabled or cache miss, so we // need to kick task to load manually final ThumbnailAsyncTask task = new ThumbnailAsyncTask(imageView, viewSize, cache, rotation); imageView.setImageBitmap(null); task.execute(file); }
From source file:com.android.displayingbitmaps.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 * {@link ImageWorker#addImageCache(android.support.v4.app.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. *///w w w .j a v a 2 s. c o m public void loadImage(Object data, ImageView imageView) { if (TextUtils.isEmpty(String.valueOf(data))) { imageView.setImageBitmap(mLoadingBitmap); 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.DUAL_THREAD_EXECUTOR); //END_INCLUDE(execute_background_task) } }
From source file:net.sinoace.library.utils.ImageDownloader.java
public void download(String url, ImageView imageView) { resetPurgeTimer();/*from w w w .j a v a 2s . c o m*/ Bitmap bitmap = getBitmapFromCache(url); if (bitmap == null) { forceDownload(url, imageView); } else { cancelPotentialDownload(url, imageView); imageView.setImageBitmap(bitmap); } //return bitmap; }
From source file:net.sinoace.library.utils.ImageDownloader.java
/** * Download the specified image from the Internet and binds it to the * provided ImageView. The binding is immediate if the image is found in the * cache and will be done asynchronously otherwise. A null bitmap will be * associated to the ImageView if an error occurs. * /*from w ww . j a va 2s. co m*/ * @param url * The URL of the image to download. * @param imageView * The ImageView to bind the downloaded image to. */ public Bitmap downloadForCache(String url, ImageView imageView) { resetPurgeTimer(); Bitmap bitmap = getBitmapFromCache(url); if (bitmap == null) { forceDownload(url, imageView); } else { cancelPotentialDownload(url, imageView); imageView.setImageBitmap(bitmap); } return bitmap; }