1package com.bumptech.glide.request;
2
3import android.graphics.drawable.Drawable;
4import android.view.View;
5import com.bumptech.glide.request.target.Target;
6
7public class ViewPropertyAnimation implements GlideAnimation {
8
9    public interface Animator {
10        public void animate(View view);
11    }
12
13    public static class ViewPropertyAnimationFactory implements GlideAnimationFactory {
14        private Animator animator;
15        private ViewPropertyAnimation animation;
16
17        public ViewPropertyAnimationFactory(Animator animator) {
18            this.animator = animator;
19        }
20
21        @Override
22        public GlideAnimation build(boolean isFromMemoryCache, boolean isFirstImage) {
23            if (isFromMemoryCache || !isFirstImage) {
24                return NoAnimation.get();
25            }
26            if (animation == null) {
27                animation = new ViewPropertyAnimation(animator);
28            }
29
30            return animation;
31        }
32    }
33
34    private Animator animator;
35
36    public ViewPropertyAnimation(Animator animator) {
37        this.animator = animator;
38    }
39
40    @Override
41    public boolean animate(Drawable previous, Object current, View view, Target target) {
42        animator.animate(view);
43        return false;
44    }
45}
46