com.bumptech.glide.request.animation
Class DrawableCrossFadeViewAnimation<T extends Drawable>

java.lang.Object
  extended by com.bumptech.glide.request.animation.DrawableCrossFadeViewAnimation<T>
Type Parameters:
T - The type of the Drawable that will be animated.
All Implemented Interfaces:
GlideAnimation<T>

public class DrawableCrossFadeViewAnimation<T extends Drawable>
extends Object
implements GlideAnimation<T>

A cross fade GlideAnimation for Drawables that uses an TransitionDrawable to transition from an existing drawable already visible on the target to a new drawable. If no existing drawable exists, this class can instead fall back to a default animation that doesn't rely on TransitionDrawable.


Nested Class Summary
static class DrawableCrossFadeViewAnimation.DrawableCrossFadeFactory<T extends Drawable>
          A factory class that produces a new GlideAnimation that varies depending on whether or not the drawable was loaded from the memory cache and whether or not the drawable is the first image to be set on the target.
 
Nested classes/interfaces inherited from interface com.bumptech.glide.request.animation.GlideAnimation
GlideAnimation.ViewAdapter
 
Field Summary
static int DEFAULT_DURATION
           
 
Constructor Summary
DrawableCrossFadeViewAnimation(Animation defaultAnimation, int duration)
          Constructor that takes a default animation and a duration in milliseconds that the cross fade animation should last.
 
Method Summary
 boolean animate(T current, GlideAnimation.ViewAdapter adapter)
          Animates from the previous drawable to the current drawable in one of two ways.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_DURATION

public static final int DEFAULT_DURATION
See Also:
Constant Field Values
Constructor Detail

DrawableCrossFadeViewAnimation

public DrawableCrossFadeViewAnimation(Animation defaultAnimation,
                                      int duration)
Constructor that takes a default animation and a duration in milliseconds that the cross fade animation should last.

Parameters:
defaultAnimation - The default animation that will run if there is nothing to cross fade from when a new Drawable is set.
duration - The duration that the cross fade animation should run if there is something to cross fade from when a new Drawable is set.
Method Detail

animate

public boolean animate(T current,
                       GlideAnimation.ViewAdapter adapter)
Animates from the previous drawable to the current drawable in one of two ways.
  1. Using the default animation provided in the constructor if the previous drawable is null
  2. Using the cross fade animation with the duration provided in the constructor if the previous drawable is non null

Specified by:
animate in interface GlideAnimation<T extends Drawable>
Parameters:
current - The new resource that will be displayed in the view.
adapter - The GlideAnimation.ViewAdapter wrapping a view that can at least return an View from GlideAnimation.ViewAdapter.getView().
Returns:
True if int he process of running the animation the new resource was set on the view, false if the caller needs to manually set the current resource on the view.