List of usage examples for android.widget ImageView getDrawable
public Drawable getDrawable()
From source file:it.gmariotti.cardslib.library.view.component.CardThumbnailView.java
protected static BitmapWorkerTask getBitmapWorkerTask(ImageView imageView) { if (imageView != null) { final Drawable drawable = imageView.getDrawable(); if (drawable instanceof AsyncDrawable) { final AsyncDrawable asyncDrawable = (AsyncDrawable) drawable; return asyncDrawable.getBitmapWorkerTask(); }//from ww w . j ava 2s .c o m } return null; }
From source file:it.gmariotti.cardslib.library.view.component.CardThumbnailView.java
protected static BitmapWorkerUrlTask getBitmapWorkerUrlTask(ImageView imageView) { if (imageView != null) { final Drawable drawable = imageView.getDrawable(); if (drawable instanceof AsyncDrawableUrl) { final AsyncDrawableUrl asyncDrawable = (AsyncDrawableUrl) drawable; return asyncDrawable.getBitmapWorkerUrlTask(); }// w w w . j a v a 2 s. c om } return null; }
From source file:it.gmariotti.cardslib.library.view.component.CardThumbnailView.java
protected static BitmapWorkerCustomSourceTask getBitmapWorkerCustomSourceTask(ImageView imageView) { if (imageView != null) { final Drawable drawable = imageView.getDrawable(); if (drawable instanceof AsyncDrawableCustomSource) { final AsyncDrawableCustomSource asyncDrawable = (AsyncDrawableCustomSource) drawable; return asyncDrawable.getBitmapWorkerCustomSourceTask(); }/*from w ww.ja v a2s .com*/ } return null; }
From source file:com.pongme.utils.ImageDownloader.java
/** * @param imageView//from w w w.j a v a 2 s. c o m * Any imageView * @return Retrieve the currently active download task (if any) associated * with this imageView. null if there is no such task. */ public static BitmapDownloaderTask getBitmapDownloaderTask(ImageView imageView) { if (imageView != null) { Drawable drawable = imageView.getDrawable(); if (drawable instanceof DownloadedDrawable) { DownloadedDrawable downloadedDrawable = (DownloadedDrawable) drawable; return downloadedDrawable.getBitmapDownloaderTask(); } } return null; }
From source file:cn.com.wo.bitmap.ImageWorker.java
/** * @param imageView Any imageView//w w w . j a v a 2 s. c o m * @return Retrieve the currently active work task (if any) associated with this imageView. * null if there is no such task. */ private static BitmapWorkerTask getBitmapWorkerTask(ImageView imageView, boolean isBackground) { if (imageView != null) { Drawable drawable = null; if (isBackground) drawable = imageView.getBackground(); else drawable = imageView.getDrawable(); if (drawable instanceof AsyncDrawable) { final AsyncDrawable asyncDrawable = (AsyncDrawable) drawable; return asyncDrawable.getBitmapWorkerTask(); } } return null; }
From source file:com.android.volley.cache.plus.SimpleImageLoader.java
/** * Sets a {@link android.graphics.Bitmap} to an {@link android.widget.ImageView} using a * fade-in animation. If there is a {@link android.graphics.drawable.Drawable} already set on * the ImageView then use that as the image to fade from. Otherwise fade in from a transparent * Drawable./* w w w .ja va2 s .c o m*/ */ @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1) private static void setImageBitmap(final ImageView imageView, final BitmapDrawable bitmapDrawable, Resources resources, boolean fadeIn) { // If we're fading in and on HC MR1+ if (fadeIn && Utils.hasHoneycombMR1()) { // Use ViewPropertyAnimator to run a simple fade in + fade out animation to update the // ImageView imageView.animate().scaleY(0.95f).scaleX(0.95f).alpha(0f) .setDuration(imageView.getDrawable() == null ? 0 : HALF_FADE_IN_TIME) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { imageView.setImageDrawable(bitmapDrawable); imageView.animate().alpha(1f).scaleY(1f).scaleX(1f).setDuration(HALF_FADE_IN_TIME) .setListener(null); } }); } else if (fadeIn) { // Otherwise use a TransitionDrawable to fade in Drawable initialDrawable; if (imageView.getDrawable() != null) { initialDrawable = imageView.getDrawable(); } else { initialDrawable = transparentDrawable; } // Use TransitionDrawable to fade in final TransitionDrawable td = new TransitionDrawable( new Drawable[] { initialDrawable, bitmapDrawable }); imageView.setImageDrawable(td); td.startTransition(Utils.ANIMATION_FADE_IN_TIME); } else { // No fade in, just set bitmap directly imageView.setImageDrawable(bitmapDrawable); } }
From source file:com.android.volley.cache.SimpleImageLoader.java
/** * Sets a {@link android.graphics.Bitmap} to an {@link android.widget.ImageView} using a * fade-in animation. If there is a {@link android.graphics.drawable.Drawable} already set on * the ImageView then use that as the image to fade from. Otherwise fade in from a transparent * Drawable.// w w w .jav a 2 s .co m */ @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1) private static void setImageBitmap(final ImageView imageView, final Bitmap bitmap, Resources resources, boolean fadeIn) { // If we're fading in and on HC MR1+ if (fadeIn && Utils.hasHoneycombMR1()) { // Use ViewPropertyAnimator to run a simple fade in + fade out animation to update the // ImageView imageView.animate().scaleY(0.95f).scaleX(0.95f).alpha(0f) .setDuration(imageView.getDrawable() == null ? 0 : HALF_FADE_IN_TIME) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { imageView.setImageBitmap(bitmap); imageView.animate().alpha(1f).scaleY(1f).scaleX(1f).setDuration(HALF_FADE_IN_TIME) .setListener(null); } }); } else if (fadeIn) { // Otherwise use a TransitionDrawable to fade in Drawable initialDrawable; if (imageView.getDrawable() != null) { initialDrawable = imageView.getDrawable(); } else { initialDrawable = transparentDrawable; } BitmapDrawable bitmapDrawable = new BitmapDrawable(resources, bitmap); // Use TransitionDrawable to fade in final TransitionDrawable td = new TransitionDrawable( new Drawable[] { initialDrawable, bitmapDrawable }); imageView.setImageDrawable(td); td.startTransition(Utils.ANIMATION_FADE_IN_TIME); } else { // No fade in, just set bitmap directly imageView.setImageBitmap(bitmap); } }
From source file:com.amazon.android.utils.Helpers.java
/** * Loads an image using Glide from a URL into an image view and crossfades it with the image * view's current image.// www. j a v a 2 s . c o m * * @param activity The activity. * @param imageView The image view to load the image into to. * @param url The URL that points to the image to load. * @param crossFadeDuration The duration of the cross-fade in milliseconds. */ public static void loadImageWithCrossFadeTransition(Activity activity, ImageView imageView, String url, final int crossFadeDuration) { /* * With the Glide image managing framework, cross fade animations only take place if the * image is not already downloaded in cache. In order to have the cross fade animation * when the image is in cache, we need to make the following two calls. */ Glide.with(activity).load(url).listener(new LoggingListener<>()).fitCenter() .error(R.drawable.browse_bg_color).placeholder(imageView.getDrawable()).crossFade().into(imageView); // Adding this second Glide call enables cross-fade transition even if the image is cached. Glide.with(activity).load(url).fitCenter().error(R.drawable.browse_bg_color) .placeholder(imageView.getDrawable()) // Here we override the onResourceReady of the RequestListener to force // the cross fade animation. .listener(new RequestListener<String, GlideDrawable>() { @Override public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) { Log.d("GLIDE", String.format(Locale.ROOT, "onException(%s, %s, %s, %s)", e, model, target, isFirstResource), e); return false; } @Override public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) { ImageViewTarget<GlideDrawable> imageTarget = (ImageViewTarget<GlideDrawable>) target; Drawable current = imageTarget.getCurrentDrawable(); if (current != null) { TransitionDrawable transitionDrawable = new TransitionDrawable( new Drawable[] { current, resource }); transitionDrawable.setCrossFadeEnabled(true); transitionDrawable.startTransition(crossFadeDuration); imageTarget.setDrawable(transitionDrawable); return true; } else return false; } }).crossFade().into(imageView); }
From source file:jp.mydns.sys1yagi.android.printingframeworksample.image.ImagePrintActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_image_print); findViewById(R.id.print_button).setOnClickListener(new OnClickListener() { @Override// w ww . j av a 2 s . c o m public void onClick(View v) { ImageView imageView = (ImageView) findViewById(R.id.image); BitmapDrawable drawable = (BitmapDrawable) imageView.getDrawable(); printImage("kitkat.pdf", drawable.getBitmap()); } }); }
From source file:com.ifeng.util.imagecache.ImageWorker.java
/** * @param imageView/*from w w w . j ava2 s. co m*/ * Any imageView * @return Retrieve the currently active work task (if any) associated with * this imageView. null if there is no such task. */ private static BitmapWorkerTask getBitmapWorkerTask(ImageView imageView) { if (imageView != null) { final Drawable drawable = imageView.getDrawable(); if (drawable instanceof AsyncBitmapDrawable) { final AsyncBitmapDrawable asyncDrawable = (AsyncBitmapDrawable) drawable; return asyncDrawable.getBitmapWorkerTask(); } else if (drawable instanceof AsyncNinePatchDrawable) { final AsyncNinePatchDrawable asyncDrawable = (AsyncNinePatchDrawable) drawable; return asyncDrawable.getBitmapWorkerTask(); } } return null; }