package com.facebook.fresco.animation.factory;

import X.C2594PyZ;
import X.C2756Q2v;
import X.C2990QBv;
import X.C3014QCt;
import X.C3150QHz;
import X.C3164QIn;
import X.C3166QIp;
import X.C3167QIq;
import X.C3168QIr;
import X.PZJ;
import X.Q32;
import X.QBA;
import X.QC4;
import X.QD9;
import X.QEG;
import X.QEX;
import X.QGK;
import X.QJ3;
import X.QJ6;
import X.QJ8;
import X.QJA;
import X.QJC;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Rect;
import com.bytedance.covode.number.Covode;
import com.facebook.common.time.RealtimeSinceBootClock;

public class AnimatedFactoryV2Impl implements QEX {
    public static int sAnimationCachingStrategy = 1;
    public QJ6 mAnimatedDrawableBackendProvider;
    public C3150QHz mAnimatedDrawableFactory;
    public QJC mAnimatedDrawableUtil;
    public QJ3 mAnimatedImageFactory;
    public final C2756Q2v<QEG, QD9> mBackingCache;
    public final QC4 mExecutorSupplier;
    public final QGK mPlatformBitmapFactory;

    static {
        Covode.recordClassIndex(41332);
    }

    private QJ3 buildAnimatedImageFactory() {
        return new C3166QIp(new QJ6() {
            static {
                Covode.recordClassIndex(41339);
            }

            public final QJ8 LIZ(C3164QIn qIn, Rect rect) {
                return new QJA(AnimatedFactoryV2Impl.this.getAnimatedDrawableUtil(), qIn, rect);
            }
        }, this.mPlatformBitmapFactory);
    }

    private QJ6 getAnimatedDrawableBackendProvider() {
        if (this.mAnimatedDrawableBackendProvider == null) {
            this.mAnimatedDrawableBackendProvider = new QJ6() {
                static {
                    Covode.recordClassIndex(41338);
                }

                public final QJ8 LIZ(C3164QIn qIn, Rect rect) {
                    return new QJA(AnimatedFactoryV2Impl.this.getAnimatedDrawableUtil(), qIn, rect);
                }
            };
        }
        return this.mAnimatedDrawableBackendProvider;
    }

    public QJC getAnimatedDrawableUtil() {
        if (this.mAnimatedDrawableUtil == null) {
            this.mAnimatedDrawableUtil = new QJC();
        }
        return this.mAnimatedDrawableUtil;
    }

    public QJ3 getAnimatedImageFactory() {
        if (this.mAnimatedImageFactory == null) {
            this.mAnimatedImageFactory = buildAnimatedImageFactory();
        }
        return this.mAnimatedImageFactory;
    }

    private C3167QIq createDrawableFactory() {
        AnonymousClass4 r7 = new Q32<Integer>() {
            static {
                Covode.recordClassIndex(41336);
            }

            public final /* synthetic */ Object LIZIZ() {
                return Integer.valueOf(AnimatedFactoryV2Impl.sAnimationCachingStrategy);
            }
        };
        return new C3167QIq(getAnimatedDrawableBackendProvider(), PZJ.LIZIZ(), new C2594PyZ(this.mExecutorSupplier.LIZJ()), RealtimeSinceBootClock.get(), this.mPlatformBitmapFactory, this.mBackingCache, r7, new Q32<Integer>() {
            static {
                Covode.recordClassIndex(41337);
            }

            public final /* synthetic */ Object LIZIZ() {
                return 3;
            }
        });
    }

    public static void setAnimationCachingStrategy(int i) {
        sAnimationCachingStrategy = i;
    }

    public C3014QCt getGifDecoder(final Bitmap.Config config) {
        return new C3014QCt() {
            static {
                Covode.recordClassIndex(41333);
            }

            public final QD9 decode(QBA qba, int i, C2990QBv qBv, C3168QIr qIr) {
                return AnimatedFactoryV2Impl.this.getAnimatedImageFactory().LIZ(qba, qIr);
            }
        };
    }

    public C3014QCt getHeifDecoder(final Bitmap.Config config) {
        return new C3014QCt() {
            static {
                Covode.recordClassIndex(41335);
            }

            public final QD9 decode(QBA qba, int i, C2990QBv qBv, C3168QIr qIr) {
                return AnimatedFactoryV2Impl.this.getAnimatedImageFactory().LIZJ(qba, qIr);
            }
        };
    }

    public C3014QCt getWebPDecoder(final Bitmap.Config config) {
        return new C3014QCt() {
            static {
                Covode.recordClassIndex(41334);
            }

            public final QD9 decode(QBA qba, int i, C2990QBv qBv, C3168QIr qIr) {
                return AnimatedFactoryV2Impl.this.getAnimatedImageFactory().LIZIZ(qba, qIr);
            }
        };
    }

    public C3150QHz getAnimatedDrawableFactory(Context context) {
        if (this.mAnimatedDrawableFactory == null) {
            this.mAnimatedDrawableFactory = createDrawableFactory();
        }
        return this.mAnimatedDrawableFactory;
    }

    public AnimatedFactoryV2Impl(QGK qgk, QC4 qc4, C2756Q2v<QEG, QD9> q2v) {
        this.mPlatformBitmapFactory = qgk;
        this.mExecutorSupplier = qc4;
        this.mBackingCache = q2v;
    }
}
