1 package com.bumptech.glide.request.animation; 2 3 /** 4 * A simple {@link com.bumptech.glide.request.animation.GlideAnimation} that performs no actions. 5 * 6 * @param <R> animated resource type 7 */ 8 public class NoAnimation<R> implements GlideAnimation<R> { 9 private static final NoAnimation<?> NO_ANIMATION = new NoAnimation<Object>(); 10 @SuppressWarnings("rawtypes") 11 private static final GlideAnimationFactory<?> NO_ANIMATION_FACTORY = new NoAnimationFactory(); 12 13 /** 14 * A factory that always returns the same {@link com.bumptech.glide.request.animation.NoAnimation}. 15 */ 16 public static class NoAnimationFactory<R> implements GlideAnimationFactory<R> { 17 @SuppressWarnings("unchecked") 18 @Override 19 public GlideAnimation<R> build(boolean isFromMemoryCache, boolean isFirstResource) { 20 return (GlideAnimation<R>) NO_ANIMATION; 21 } 22 } 23 24 /** 25 * Returns an instance of a factory that produces {@link com.bumptech.glide.request.animation.NoAnimation}s. 26 */ 27 @SuppressWarnings("unchecked") 28 public static <R> GlideAnimationFactory<R> getFactory() { 29 return (GlideAnimationFactory<R>) NO_ANIMATION_FACTORY; 30 } 31 32 /** 33 * Returns an instance of {@link com.bumptech.glide.request.animation.NoAnimation}. 34 */ 35 @SuppressWarnings("unchecked") 36 public static <R> GlideAnimation<R> get() { 37 return (GlideAnimation<R>) NO_ANIMATION; 38 } 39 40 /** 41 * Performs no animation and always returns {@code false}. 42 */ 43 @Override 44 public boolean animate(Object current, ViewAdapter adapter) { 45 return false; 46 } 47 } 48