List of usage examples for android.widget ImageView setImageBitmap
@android.view.RemotableViewMethod public void setImageBitmap(Bitmap bm)
From source file:com.crust87.centercropvideoviewsample.LoadImageTask.java
private static void setImageWithFadeIn(ImageView imageView, Bitmap picture) { if (imageView != null && picture != null) { imageView.setImageBitmap(picture); fadeInView(imageView);/*from w w w.j a va 2 s.c o m*/ } }
From source file:Main.java
public static void setImageSrc(ImageView imageView, String imagePath) { BitmapFactory.Options option = new BitmapFactory.Options(); option.inSampleSize = getImageScale(imagePath); Bitmap bm = BitmapFactory.decodeFile(imagePath, option); imageView.setImageBitmap(bm); }
From source file:Main.java
public static void releaseImageView(ImageView imageView) { if (imageView != null) { BitmapDrawable bitmapDrawable = (BitmapDrawable) (imageView.getDrawable()); if (bitmapDrawable != null) { bitmapDrawable.setCallback(null); }//from w w w .ja v a2s . c o m imageView.setImageBitmap(null); } }
From source file:Main.java
private static boolean loadAssetImage(ImageView view, String filename) { InputStream input = null;// w w w. j a va 2 s. c om try { input = view.getContext().getAssets().open(filename); Bitmap icon = BitmapFactory.decodeStream(input); view.setImageBitmap(icon); input.close(); return true; } catch (Exception error) { } finally { silentClose(input); } return false; }
From source file:Main.java
private static void loadAssetImage(ImageView view, String filename, int defaultIconId) { InputStream input = null;// www.j av a2 s .c o m try { input = view.getContext().getAssets().open(filename); Bitmap icon = BitmapFactory.decodeStream(input); view.setImageBitmap(icon); input.close(); } catch (Exception error) { view.setImageResource(defaultIconId); } finally { silentClose(input); } }
From source file:Main.java
/** * Entfernt ein zur ImageView zugeordnetes Bitmap aus dem Speicher * @param imageView ImageView welches das Bitmap anzeigt *//*w w w .j a v a2s. c om*/ public static void recycleBitmapFromImageView(ImageView imageView) { if (imageView != null && imageView.getDrawable() != null && imageView.getDrawable() instanceof BitmapDrawable) { final Bitmap bitmap = ((BitmapDrawable) imageView.getDrawable()).getBitmap(); recycleBitmap(bitmap); imageView.setImageBitmap(null); } }
From source file:Main.java
public static void applySampledResourceToImageView(Resources res, int resId, int reqWidth, int reqHeight, ImageView imageView) { if (resId != 0) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { imageView.setImageDrawable(res.getDrawable(resId)); } else {/*from w w w .j a v a 2 s . c om*/ // workaround for old versions of android imageView.setImageBitmap(decodeSampledBitmapFromResource(res, resId, reqWidth, reqHeight)); } } }
From source file:ca.psiphon.ploggy.Robohash.java
public static void setRobohashImage(Context context, ImageView imageView, boolean cacheCandidate, Identity.PublicIdentity publicIdentity) { if (publicIdentity != null) { try {/*from ww w. j a v a 2 s .c o m*/ imageView.setImageBitmap( Robohash.getRobohash(context, cacheCandidate, publicIdentity.getFingerprint())); return; } catch (Utils.ApplicationError e) { Log.addEntry(LOG_TAG, "failed to create image"); } } imageView.setImageResource(R.drawable.ic_unknown_avatar); }
From source file:com.example.android.supportv7.graphics.ImageLoader.java
static void loadMediaStoreThumbnail(final ImageView imageView, final long id, final Listener listener) { final Bitmap cachedValue = CACHE.get(id); if (cachedValue != null) { // If the image is already in the cache, display the image, // call the listener now and return imageView.setImageBitmap(cachedValue); if (listener != null) { listener.onImageLoaded(cachedValue); }//from www .j a va 2 s . co m return; } AsyncTaskCompat.executeParallel(new AsyncTask<Void, Void, Bitmap>() { @Override protected Bitmap doInBackground(Void... params) { return MediaStore.Images.Thumbnails.getThumbnail(imageView.getContext().getContentResolver(), id, MediaStore.Images.Thumbnails.MINI_KIND, null); } @Override protected void onPostExecute(Bitmap bitmap) { imageView.setImageBitmap(bitmap); if (bitmap != null) { // Add the image to the memory cache first CACHE.put(id, bitmap); if (listener != null) { listener.onImageLoaded(bitmap); } } } }); }
From source file:com.lovejoy777sarootool.rootool.preview.IconPreview.java
private static void loadBitmap(final File file, final ImageView imageView) { imageViews.put(imageView, file.getAbsolutePath()); Bitmap bitmap = getBitmapFromCache(file.getAbsolutePath()); // check in UI thread, so no concurrency issues if (bitmap != null) { // Item loaded from cache imageView.setImageBitmap(bitmap); } else {/*from w ww .j a v a2 s .co m*/ // here you can set a placeholder imageView.setImageBitmap(null); queueJob(file, imageView); } }