1 package com.bumptech.glide.request.animation; 2 3 /** 4 * A {@link GlideAnimationFactory} that produces ViewPropertyAnimations. 5 * 6 * @param <R> The type of the resource displayed in the view that is animated 7 */ 8 public class ViewPropertyAnimationFactory<R> implements GlideAnimationFactory<R> { 9 private final ViewPropertyAnimation.Animator animator; 10 private ViewPropertyAnimation<R> animation; 11 12 public ViewPropertyAnimationFactory(ViewPropertyAnimation.Animator animator) { 13 this.animator = animator; 14 } 15 16 /** 17 * Returns a new {@link GlideAnimation} for the given arguments. If 18 * isMemoryCache is {@code true} or isFirstImage is {@code false}, returns a 19 * {@link NoAnimation} and otherwise returns a new 20 * {@link ViewPropertyAnimation} for the 21 * {@link com.bumptech.glide.request.animation.ViewPropertyAnimation.Animator} provided in the constructor. 22 */ 23 @Override 24 public GlideAnimation<R> build(boolean isFromMemoryCache, boolean isFirstResource) { 25 if (isFromMemoryCache || !isFirstResource) { 26 return NoAnimation.get(); 27 } 28 if (animation == null) { 29 animation = new ViewPropertyAnimation<R>(animator); 30 } 31 32 return animation; 33 } 34 } 35