aboutsummaryrefslogtreecommitdiff
path: root/library/src/main/java/com/bumptech/glide/request/animation/NoAnimation.java
blob: e2935dbade28eb74f361ae5c8a6a01d5f990ef0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package com.bumptech.glide.request.animation;

import android.graphics.drawable.Drawable;
import android.view.View;
import com.bumptech.glide.request.target.Target;

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

    public static class NoAnimationFactory implements GlideAnimationFactory {
        @Override
        public GlideAnimation build(boolean isFromMemoryCache, boolean isFirstImage) {
            return NO_ANIMATION;
        }
    }

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

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

    /**
     * Performs no animation and always returns {@code false}.
     */
    @Override
    public boolean animate(Drawable previous, Object current, View view, Target target) {
        return false;
    }
}