• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.bumptech.glide.request.animation;
2 
3 import android.view.View;
4 
5 /**
6  * A {@link com.bumptech.glide.request.animation.GlideAnimation GlideAnimation} that accepts an interface
7  * that can apply an animation like a {@link android.view.ViewPropertyAnimator}
8  * or a {@link android.animation.ObjectAnimator} to an {@link View}.
9  *
10  * @param <R> The type of the resource displayed in the view that is animated
11  */
12 public class ViewPropertyAnimation<R> implements GlideAnimation<R> {
13 
14     private final Animator animator;
15 
16     /**
17      * Constructor for a view property animation that takes an
18      * {@link com.bumptech.glide.request.animation.ViewPropertyAnimation.Animator} interface that can apply an animation
19      * to a view.
20      *
21      * @param animator The animator to use.
22      */
ViewPropertyAnimation(Animator animator)23     public ViewPropertyAnimation(Animator animator) {
24         this.animator = animator;
25     }
26 
27     /**
28      * Always applies the {@link com.bumptech.glide.request.animation.ViewPropertyAnimation.Animator} given in the
29      * constructor to the given view and returns {@code false} because the animator cannot set the new resource on
30      * the view.
31      *
32      * @param current {@inheritDoc}
33      * @param adapter {@inheritDoc}
34      * @return {@inheritDoc}
35      */
36     @Override
animate(R current, ViewAdapter adapter)37     public boolean animate(R current, ViewAdapter adapter) {
38         final View view = adapter.getView();
39         if (view != null) {
40             animator.animate(adapter.getView());
41         }
42         return false;
43     }
44 
45     /**
46      * An interface that allows an animation to be applied on or started from an {@link android.view.View}.
47      */
48     public interface Animator {
49         /**
50          * Starts an animation on the given {@link android.view.View}.
51          *
52          * @param view The view to animate.
53          */
animate(View view)54         void animate(View view);
55     }
56 
57 }
58