• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.bumptech.glide.request.animation;
2 
3 import android.graphics.drawable.Drawable;
4 import android.view.View;
5 
6 /**
7  * An interface that allows a transformation to be applied to {@link android.view.View}s in
8  * {@link com.bumptech.glide.request.target.Target}s in across resource types. Targets that wrap views will be able to
9  * provide all of the necessary arguments and start the animation. Those that do not will be unable to provide the
10  * necessary arguments and will therefore be forced to ignore the animation. This interface is a compromise that
11  * allows view animations in Glide's complex world of arbitrary resource types and arbitrary target types.
12  *
13  * @param <R> The type of the resource that should be animated to.
14  */
15 public interface GlideAnimation<R> {
16 
17     /**
18      * An interface wrapping a view that exposes the necessary methods to run the various types of android animations
19      * ({@link com.bumptech.glide.request.animation.ViewAnimation},
20      * {@link com.bumptech.glide.request.animation.ViewPropertyAnimation} and animated
21      * {@link android.graphics.drawable.Drawable}s).
22      */
23     interface ViewAdapter {
24         /**
25          * Returns the wrapped {@link android.view.View}.
26          */
getView()27         View getView();
28 
29         /**
30          * Returns the current drawable being displayed in the view, or null if no such drawable exists (or one cannot
31          * be retrieved).
32          */
getCurrentDrawable()33         Drawable getCurrentDrawable();
34 
35         /**
36          * Sets the current drawable (usually an animated drawable) to display in the wrapped view.
37          *
38          * @param drawable The drawable to display in the wrapped view.
39          */
setDrawable(Drawable drawable)40         void setDrawable(Drawable drawable);
41     }
42 
43     /**
44      * Animates from the previous {@link android.graphics.drawable.Drawable} that is currently being displayed in the
45      * given view, if not null, to the new resource that should be displayed in the view.
46      *
47      * @param current The new resource that will be displayed in the view.
48      * @param adapter The {@link com.bumptech.glide.request.animation.GlideAnimation.ViewAdapter} wrapping a view that
49      *                can at least return an {@link android.view.View} from
50      *                {@link com.bumptech.glide.request.animation.GlideAnimation.ViewAdapter#getView()}.
51      * @return True if int he process of running the animation the new resource was set on the view, false if the caller
52      * needs to manually set the current resource on the view.
53      */
animate(R current, ViewAdapter adapter)54     boolean animate(R current, ViewAdapter adapter);
55 }
56