All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.bumptech.glide.request.animation.NoAnimation Maven / Gradle / Ivy

package com.bumptech.glide.request.animation;

/**
 * A simple {@link com.bumptech.glide.request.animation.GlideAnimation} that performs no actions.
 *
 * @param  animated resource type
 */
public class NoAnimation implements GlideAnimation {
    private static final NoAnimation NO_ANIMATION = new NoAnimation();
    @SuppressWarnings("rawtypes")
    private static final GlideAnimationFactory NO_ANIMATION_FACTORY = new NoAnimationFactory();

    /**
     * A factory that always returns the same {@link com.bumptech.glide.request.animation.NoAnimation}.
     */
    public static class NoAnimationFactory implements GlideAnimationFactory {
        @SuppressWarnings("unchecked")
        @Override
        public GlideAnimation build(boolean isFromMemoryCache, boolean isFirstResource) {
            return (GlideAnimation) NO_ANIMATION;
        }
    }

    /**
     * Returns an instance of a factory that produces {@link com.bumptech.glide.request.animation.NoAnimation}s.
     */
    @SuppressWarnings("unchecked")
    public static  GlideAnimationFactory getFactory() {
        return (GlideAnimationFactory) NO_ANIMATION_FACTORY;
    }

    /**
     * Returns an instance of {@link com.bumptech.glide.request.animation.NoAnimation}.
     */
    @SuppressWarnings("unchecked")
    public static  GlideAnimation get() {
        return (GlideAnimation) NO_ANIMATION;
    }

    /**
     * Performs no animation and always returns {@code false}.
     */
    @Override
    public boolean animate(Object current, ViewAdapter adapter) {
        return false;
    }
}