List of usage examples for android.graphics.drawable TransitionDrawable TransitionDrawable
public TransitionDrawable(Drawable[] layers)
From source file:com.app.chasebank.contactslist.util.ImageLoader.java
/** * Called when the processing is complete and the final bitmap should be set on the ImageView. * * @param imageView The ImageView to set the bitmap to. * @param bitmap The new bitmap to set.//from w w w.j a va2 s. c o m */ private void setImageBitmap(ImageView imageView, Bitmap bitmap) { if (mFadeInBitmap) { // Transition drawable to fade from loading bitmap to final bitmap final TransitionDrawable td = new TransitionDrawable(new Drawable[] { new ColorDrawable(android.R.color.transparent), new BitmapDrawable(mResources, bitmap) }); imageView.setBackgroundDrawable(imageView.getDrawable()); imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); } else { imageView.setImageBitmap(bitmap); } }
From source file:com.itsherpa.andg.imageloader.ContactImageLoader.java
/** * Called when the processing is complete and the final bitmap should be set * on the ImageView.//w w w.jav a 2s .com * * @param imageView * The ImageView to set the bitmap to. * @param bitmap * The new bitmap to set. */ @TargetApi(Build.VERSION_CODES.JELLY_BEAN) @SuppressWarnings("deprecation") private void setImageBitmap(ImageView imageView, Bitmap bitmap) { if (mFadeInBitmap) { // Transition drawable to fade from loading bitmap to final bitmap final TransitionDrawable td = new TransitionDrawable(new Drawable[] { new ColorDrawable(android.R.color.transparent), new BitmapDrawable(mResources, bitmap) }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { imageView.setBackground(imageView.getDrawable()); } else { imageView.setBackgroundDrawable(imageView.getDrawable()); } imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); } else { imageView.setImageBitmap(bitmap); } }
From source file:com.musenkishi.atelier.Atelier.java
private static void applyColorToView(final ImageView imageView, int color, boolean fromCache, boolean shouldMask) { if (fromCache) { if (shouldMask) { if (imageView.getDrawable() != null) { imageView.getDrawable().mutate().setColorFilter(color, PorterDuff.Mode.MULTIPLY); } else if (imageView.getBackground() != null) { imageView.getBackground().mutate().setColorFilter(color, PorterDuff.Mode.MULTIPLY); }//from ww w . ja v a 2s . c o m } else { imageView.setBackgroundColor(color); } } else { if (shouldMask) { Integer colorFrom; ValueAnimator.AnimatorUpdateListener imageAnimatorUpdateListener = new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { if (imageView.getDrawable() != null) { imageView.getDrawable().mutate().setColorFilter( (Integer) valueAnimator.getAnimatedValue(), PorterDuff.Mode.MULTIPLY); } else if (imageView.getBackground() != null) { imageView.getBackground().mutate().setColorFilter( (Integer) valueAnimator.getAnimatedValue(), PorterDuff.Mode.MULTIPLY); } } }; ValueAnimator.AnimatorUpdateListener animatorUpdateListener; PaletteTag paletteTag = (PaletteTag) imageView.getTag(viewTagKey); animatorUpdateListener = imageAnimatorUpdateListener; colorFrom = paletteTag.getColor(); imageView.setTag(viewTagKey, new PaletteTag(paletteTag.getId(), color)); Integer colorTo = color; ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo); colorAnimation.addUpdateListener(animatorUpdateListener); colorAnimation.setDuration(300); colorAnimation.start(); } else { Drawable preDrawable; if (imageView.getBackground() == null) { preDrawable = new ColorDrawable(Color.TRANSPARENT); } else { preDrawable = imageView.getBackground(); } TransitionDrawable transitionDrawable = new TransitionDrawable( new Drawable[] { preDrawable, new ColorDrawable(color) }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { imageView.setBackground(transitionDrawable); } else { imageView.setBackgroundDrawable(transitionDrawable); } transitionDrawable.startTransition(300); } } }
From source file:com.tylz.aelos.util.videoutils.ImageWorker.java
/** * Called when the processing is complete and the final drawable should be * set on the ImageView./*from ww w. ja v a 2s. 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(0X00000000), 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.appsimobile.appsii.module.weather.WeatherActivity.java
void showDrawable(Drawable drawable, boolean isImmediate) { mBackgroundImage.setLayerType(View.LAYER_TYPE_SOFTWARE, null); if (isImmediate) { int w = drawable.getIntrinsicWidth(); int viewWidth = mBackgroundImage.getWidth(); float factor = viewWidth / (float) w; int h = (int) (drawable.getIntrinsicHeight() * factor); drawable.setBounds(0, 0, w, h);// w w w . j a va 2s .c om mBackgroundImage.setImageDrawable(drawable); } else { Drawable current = mBackgroundImage.getDrawable(); if (current == null) current = new ColorDrawable(Color.TRANSPARENT); TransitionDrawable transitionDrawable = new TransitionDrawable(new Drawable[] { current, drawable }); transitionDrawable.setCrossFadeEnabled(true); mBackgroundImage.setImageDrawable(transitionDrawable); transitionDrawable.startTransition(500); } }
From source file:com.gokuai.yunkuandroidsdk.imageutils.ImageWorker.java
/** * Called when the processing is complete and the final drawable should be * set on the ImageView./* w w w . ja va 2 s .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), isRoundDrawable ? new BitmapDrawable(mResources, Util.makeRoundDrawable(drawable, GKApplication.getInstance(), false)) : drawable }); // Set background to loading bitmap imageView.setBackgroundDrawable(isRoundDrawable ? new BitmapDrawable(mResources, Util.makeRoundDrawable(drawable, GKApplication.getInstance(), false)) : new BitmapDrawable(mResources, mLoadingBitmap)); imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); } else { if (isRoundDrawable) { imageView.setImageBitmap(Util.makeRoundDrawable(drawable, GKApplication.getInstance(), false)); } else { imageView.setImageDrawable(drawable); } } }
From source file:com.gmall.gmallmanager.widget.videoimage.ImageWorker.java
/** * Called when the processing is complete and the final drawable should be * set on the ImageView./*w w w. ja v a 2 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.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.android.simpleimageloader.image.ImageWorker.java
/** * Called when the processing is complete and the final drawable should be set on the ImageView. * /*from www . ja va 2 s . co 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:imageUtils.ImageWorker.java
/** * Called when the processing is complete and the final drawable should be * set on the ImageView./*from ww w .ja va 2 s. co 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(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.roach.framework.http.bitmap.ImageWorker.java
/** * Called when the processing is complete and the final bitmap should be set on the ImageView. * * @param imageView/* w w w . j a v a 2s . 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 if (mLoadingBitmap != null) { imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap)); } imageView.setImageDrawable(td); td.startTransition(FADE_IN_TIME); } else { imageView.setImageBitmap(bitmap); } }