List of usage examples for android.graphics.drawable TransitionDrawable TransitionDrawable
public TransitionDrawable(Drawable[] layers)
From source file:com.travel.ac.utils.ImageWorker.java
/** * Called when the processing is complete and the final drawable should be * set on the ImageView.//from ww w.j av a2 s . c om * * @param imageView * @param drawable */ private void setImageDrawable(ImageView imageView, Drawable drawable) { /* * ?? */ if (mFadeInBitmap && mCircleImageView == null) { // 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 // if (mCircleImageView == null) { imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap)); imageView.setImageDrawable(td); } else { ((CircleImageView) imageView).setImage(new BitmapDrawable(mResources, mLoadingBitmap)); ((CircleImageView) imageView).setImage(td); } td.startTransition(FADE_IN_TIME); } else { if (mCircleImageView == null) { imageView.setImageDrawable(drawable); } else { ((CircleImageView) imageView).setImage(drawable); } } }
From source file:pum.android.project.tools.displayingbitmaps.ImageWorker.java
/** * Called when the processing is complete and the final drawable should be * set on the ImageView.//from w w w. j a va2 s. c o m * * @param imageView * @param drawable */ private void setImageDrawable(ImageView imageView, Drawable drawable) { try { ViewGroup viewGroup = (ViewGroup) imageView.getParent(); if (viewGroup instanceof FrameLayout) { FrameLayout parent = (FrameLayout) viewGroup; View view; if ((view = parent.getChildAt(1)) instanceof ProgressBar) parent.removeView(view); } } catch (Exception e) { Log.e(getClass().getSimpleName(), "onPostExecute, progressBar not found", e); } 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.tangjd.displayingbitmaps.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 v a 2s . co 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(imageView.getContext().getResources().getColor(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.onedollar.image.ImageWorker.java
/** * Called when the processing is complete and the final drawable should be * set on the ImageView./*w w w.jav a 2 s. c o m*/ * * @param imageView * @param drawable */ private void setImageDrawable(ImageView imageView, Drawable drawable, OnBitmapDownload callBack) { 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.setImageBitmap(mLoadingBitmap); imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); } else { if (callBack != null) { callBack.onFinish(imageView, drawable); } else { imageView.setImageDrawable(drawable); } } }
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.//from ww w .jav a2s .c o m */ @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1) private static void setPhotoImageBitmap(final PhotoView 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.bindDrawable(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.bindDrawable(td); td.startTransition(Utils.ANIMATION_FADE_IN_TIME); } else { // No fade in, just set bitmap directly imageView.bindDrawable(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./* ww w. j a va 2 s. co m*/ */ @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1) private static void setPhotoImageBitmap(final PhotoView 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.bindPhoto(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.bindDrawable(td); td.startTransition(Utils.ANIMATION_FADE_IN_TIME); } else { // No fade in, just set bitmap directly imageView.bindPhoto(bitmap); } }
From source file:arun.com.chromer.webheads.ui.views.BaseWebHead.java
public void setFaviconDrawable(@NonNull final Drawable faviconDrawable) { if (indicator != null && favicon != null) { indicator.animate().alpha(0).withLayer().start(); TransitionDrawable transitionDrawable = new TransitionDrawable( new Drawable[] { new ColorDrawable(TRANSPARENT), faviconDrawable }); favicon.setVisibility(VISIBLE);//from w ww . ja v a2 s . com favicon.setImageDrawable(transitionDrawable); transitionDrawable.setCrossFadeEnabled(true); transitionDrawable.startTransition(500); } }
From source file:com.fivehundredpxdemo.android.storage.ImageWorker.java
/** * Called when the processing is complete and the final bitmap should be set on the ImageView. * * @param imageView//from www . j a va 2 s.c om * @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.setBackgroundDrawable(imageView.getDrawable()); imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); } else { imageView.setImageBitmap(bitmap); } }
From source file:com.android.beez.loadimage.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(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.setVisibility(View.VISIBLE); imageView.setImageDrawable(drawable); } }
From source file:com.jcsoluciones.superdt.utilities.ImageWorker.java
/** * Called when the processing is complete and the final drawable should be * set on the ImageView.//from w w w . j a v a2 s . c o 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(R.color.colorPrimary), drawable }); // Set background to loading bitmap imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap)); imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); } else { imageView.setImageDrawable(drawable); } }