package com.bytedance.adsdk.ro;

import android.animation.Animator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.graphics.RectF;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Looper;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.SystemClock;
import android.text.TextUtils;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import com.bytedance.adsdk.ro.wsy;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Callable;
import org.json.JSONArray;

/* JADX INFO: loaded from: classes.dex */
public class ajl extends ImageView {
    private static final String fm = "ajl";
    private static final ku<Throwable> ro = new ku<Throwable>() { // from class: com.bytedance.adsdk.ro.ajl.1
        @Override // com.bytedance.adsdk.ro.ku
        public void fm(Throwable th) {
            com.bytedance.adsdk.ro.ajl.ajl.fm(th);
        }
    };
    private ro ai;
    private int ajl;
    private final Set<yz> dsz;
    private boolean duv;

    /* JADX INFO: renamed from: ef, reason: collision with root package name */
    private int f6184ef;
    private dsz<wsy> fhx;
    private int gof;
    private Handler gqi;
    private final Runnable gzf;
    private int hi;
    private int hlt;
    private wsy irt;
    private ku<Throwable> jnr;
    private boolean ku;

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    private final ku<wsy> f6185lb;
    private int lse;
    private int maa;
    private JSONArray mq;
    private String nt;
    private fm ol;
    private final Set<Object> onz;
    private final Handler qhl;
    private com.bytedance.adsdk.ro.lb.lb.lb sds;
    private boolean vt;
    private long wey;
    private final ef wsy;
    private String wu;
    private final ku<Throwable> yz;

    /* JADX INFO: renamed from: com.bytedance.adsdk.ro.ajl$5, reason: invalid class name */
    public static /* synthetic */ class AnonymousClass5 {
        static final /* synthetic */ int[] fm;

        static {
            int[] iArr = new int[ImageView.ScaleType.values().length];
            fm = iArr;
            try {
                iArr[ImageView.ScaleType.CENTER_CROP.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                fm[ImageView.ScaleType.CENTER_INSIDE.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                fm[ImageView.ScaleType.CENTER.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                fm[ImageView.ScaleType.FIT_CENTER.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
        }
    }

    public interface fm {
    }

    public static class lb extends View.BaseSavedState {
        public static final Parcelable.Creator<lb> CREATOR = new Parcelable.Creator<lb>() { // from class: com.bytedance.adsdk.ro.ajl.lb.1
            @Override // android.os.Parcelable.Creator
            /* JADX INFO: renamed from: fm, reason: merged with bridge method [inline-methods] */
            public lb createFromParcel(Parcel parcel) {
                return new lb(parcel);
            }

            @Override // android.os.Parcelable.Creator
            /* JADX INFO: renamed from: fm, reason: merged with bridge method [inline-methods] */
            public lb[] newArray(int i10) {
                return new lb[i10];
            }
        };
        int ajl;
        String fm;
        String jnr;

        /* JADX INFO: renamed from: lb, reason: collision with root package name */
        float f6188lb;
        int ro;
        int wsy;
        boolean yz;

        @Override // android.view.View.BaseSavedState, android.view.AbsSavedState, android.os.Parcelable
        public void writeToParcel(Parcel parcel, int i10) {
            super.writeToParcel(parcel, i10);
            parcel.writeString(this.fm);
            parcel.writeFloat(this.f6188lb);
            parcel.writeInt(this.yz ? 1 : 0);
            parcel.writeString(this.jnr);
            parcel.writeInt(this.ajl);
            parcel.writeInt(this.wsy);
        }

        public lb(Parcelable parcelable) {
            super(parcelable);
        }

        private lb(Parcel parcel) {
            super(parcel);
            this.fm = parcel.readString();
            this.f6188lb = parcel.readFloat();
            this.yz = parcel.readInt() == 1;
            this.jnr = parcel.readString();
            this.ajl = parcel.readInt();
            this.wsy = parcel.readInt();
        }
    }

    public interface ro {
    }

    public enum yz {
        SET_ANIMATION,
        SET_PROGRESS,
        SET_REPEAT_MODE,
        SET_REPEAT_COUNT,
        SET_IMAGE_ASSETS,
        PLAY_OPTION
    }

    public ajl(Context context) {
        super(context);
        this.f6185lb = new ku<wsy>() { // from class: com.bytedance.adsdk.ro.ajl.6
            @Override // com.bytedance.adsdk.ro.ku
            public void fm(wsy wsyVar) {
                ajl.this.setComposition(wsyVar);
            }
        };
        this.yz = new ku<Throwable>() { // from class: com.bytedance.adsdk.ro.ajl.7
            @Override // com.bytedance.adsdk.ro.ku
            public void fm(Throwable th) {
                if (ajl.this.ajl != 0) {
                    ajl ajlVar = ajl.this;
                    ajlVar.setImageResource(ajlVar.ajl);
                }
                (ajl.this.jnr == null ? ajl.ro : ajl.this.jnr).fm(th);
            }
        };
        this.ajl = 0;
        this.wsy = new ef();
        this.vt = false;
        this.ku = false;
        this.duv = true;
        this.dsz = new HashSet();
        this.onz = new HashSet();
        this.qhl = new Handler(Looper.getMainLooper());
        this.gof = 0;
        this.wey = 0L;
        this.gzf = new Runnable() { // from class: com.bytedance.adsdk.ro.ajl.4
            @Override // java.lang.Runnable
            public void run() {
                int unused = ajl.this.maa;
                int unused2 = ajl.this.lse;
                if (ajl.this.maa > ajl.this.lse) {
                    ajl.gof(ajl.this);
                    com.bytedance.adsdk.ro.lb.lb.lb lbVar = ajl.this.sds;
                    StringBuilder sb = new StringBuilder();
                    sb.append(ajl.this.maa);
                    lbVar.fm(sb.toString());
                    ajl.this.invalidate();
                    ajl.this.fhx();
                    return;
                }
                if (ajl.this.hlt < 0 || ajl.this.hi < 0) {
                    int unused3 = ajl.this.hlt;
                    int unused4 = ajl.this.hi;
                } else {
                    int unused5 = ajl.this.hlt;
                    ajl.this.fm();
                    ajl ajlVar = ajl.this;
                    ajlVar.setFrame(ajlVar.hlt);
                    ajl.this.fm(new ValueAnimator.AnimatorUpdateListener() { // from class: com.bytedance.adsdk.ro.ajl.4.1
                        @Override // android.animation.ValueAnimator.AnimatorUpdateListener
                        public void onAnimationUpdate(ValueAnimator valueAnimator) {
                            if (ajl.this.getFrame() < ajl.this.hi - 1 || ajl.this.getFrame() >= ajl.this.hi + 2) {
                                return;
                            }
                            int unused6 = ajl.this.hi;
                            ajl.this.ro(this);
                            ajl.this.ajl();
                        }
                    });
                }
                if ((!TextUtils.isEmpty(ajl.this.nt) || (ajl.this.mq != null && ajl.this.mq.length() > 0)) && ajl.this.ai != null) {
                    ro unused6 = ajl.this.ai;
                    String unused7 = ajl.this.nt;
                    JSONArray unused8 = ajl.this.mq;
                }
            }
        };
        wu();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public wsy.fm getGlobalConfig() {
        wsy wsyVarNt;
        ef efVar = this.wsy;
        if (efVar == null || (wsyVarNt = efVar.nt()) == null) {
            return null;
        }
        return wsyVarNt.ku();
    }

    private wsy.ro getGlobalEvent() {
        wsy wsyVarNt;
        ef efVar = this.wsy;
        if (efVar == null || (wsyVarNt = efVar.nt()) == null) {
            return null;
        }
        return wsyVarNt.vt();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public String getPlayDelayedELExpressTimeS() {
        wsy wsyVarNt;
        ef efVar = this.wsy;
        if (efVar == null || (wsyVarNt = efVar.nt()) == null) {
            return null;
        }
        return wsyVarNt.ef();
    }

    public static /* synthetic */ int gof(ajl ajlVar) {
        int i10 = ajlVar.maa;
        ajlVar.maa = i10 - 1;
        return i10;
    }

    public static /* synthetic */ int jnr(ajl ajlVar) {
        int i10 = ajlVar.gof;
        ajlVar.gof = i10 + 1;
        return i10;
    }

    private void setCompositionTask(dsz<wsy> dszVar) {
        this.dsz.add(yz.SET_ANIMATION);
        qhl();
        dsz();
        this.fhx = dszVar.fm(this.f6185lb).lb(this.yz);
    }

    public boolean getClipToCompositionBounds() {
        return this.wsy.lb();
    }

    public wsy getComposition() {
        return this.irt;
    }

    public long getDuration() {
        wsy wsyVar = this.irt;
        if (wsyVar != null) {
            return (long) wsyVar.jnr();
        }
        return 0L;
    }

    public int getFrame() {
        return this.wsy.gqi();
    }

    public String getImageAssetsFolder() {
        return this.wsy.yz();
    }

    public boolean getMaintainOriginalImageBounds() {
        return this.wsy.jnr();
    }

    public float getMaxFrame() {
        return this.wsy.fhx();
    }

    public float getMinFrame() {
        return this.wsy.onz();
    }

    public gof getPerformanceTracker() {
        return this.wsy.wu();
    }

    public float getProgress() {
        return this.wsy.ai();
    }

    public gqi getRenderMode() {
        return this.wsy.ajl();
    }

    public int getRepeatCount() {
        return this.wsy.sds();
    }

    public int getRepeatMode() {
        return this.wsy.wey();
    }

    public float getSpeed() {
        return this.wsy.irt();
    }

    @Override // android.view.View
    public void invalidate() {
        super.invalidate();
        Drawable drawable = getDrawable();
        if ((drawable instanceof ef) && ((ef) drawable).ajl() == gqi.SOFTWARE) {
            this.wsy.invalidateSelf();
        }
    }

    @Override // android.widget.ImageView, android.view.View, android.graphics.drawable.Drawable.Callback
    public void invalidateDrawable(Drawable drawable) {
        Drawable drawable2 = getDrawable();
        ef efVar = this.wsy;
        if (drawable2 == efVar) {
            super.invalidateDrawable(efVar);
        } else {
            super.invalidateDrawable(drawable);
        }
    }

    @Override // android.widget.ImageView, android.view.View
    public void onAttachedToWindow() {
        super.onAttachedToWindow();
        if (isInEditMode() || !this.ku) {
            return;
        }
        this.wsy.ku();
    }

    @Override // android.widget.ImageView, android.view.View
    public void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        irt();
        Handler handler = this.gqi;
        if (handler != null) {
            handler.removeCallbacksAndMessages(null);
        }
        lb();
        ro();
    }

    @Override // android.view.View
    public void onRestoreInstanceState(Parcelable parcelable) {
        int i10;
        if (!(parcelable instanceof lb)) {
            super.onRestoreInstanceState(parcelable);
            return;
        }
        lb lbVar = (lb) parcelable;
        super.onRestoreInstanceState(lbVar.getSuperState());
        this.wu = lbVar.fm;
        Set<yz> set = this.dsz;
        yz yzVar = yz.SET_ANIMATION;
        if (!set.contains(yzVar) && !TextUtils.isEmpty(this.wu)) {
            setAnimation(this.wu);
        }
        this.f6184ef = lbVar.ro;
        if (!this.dsz.contains(yzVar) && (i10 = this.f6184ef) != 0) {
            setAnimation(i10);
        }
        if (!this.dsz.contains(yz.SET_PROGRESS)) {
            fm(lbVar.f6188lb, false);
        }
        if (!this.dsz.contains(yz.PLAY_OPTION) && lbVar.yz) {
            fm();
        }
        if (!this.dsz.contains(yz.SET_IMAGE_ASSETS)) {
            setImageAssetsFolder(lbVar.jnr);
        }
        if (!this.dsz.contains(yz.SET_REPEAT_MODE)) {
            setRepeatMode(lbVar.ajl);
        }
        if (this.dsz.contains(yz.SET_REPEAT_COUNT)) {
            return;
        }
        setRepeatCount(lbVar.wsy);
    }

    @Override // android.view.View
    public Parcelable onSaveInstanceState() {
        lb lbVar = new lb(super.onSaveInstanceState());
        lbVar.fm = this.wu;
        lbVar.ro = this.f6184ef;
        lbVar.f6188lb = this.wsy.ai();
        lbVar.yz = this.wsy.lse();
        lbVar.jnr = this.wsy.yz();
        lbVar.ajl = this.wsy.wey();
        lbVar.wsy = this.wsy.sds();
        return lbVar;
    }

    @Override // android.view.View
    public boolean onTouchEvent(MotionEvent motionEvent) {
        int[][] iArr;
        com.bytedance.adsdk.ro.lb.lb.fm fmVarFm = fm(motionEvent);
        if (fmVarFm == null) {
            if (getGlobalConfig() == null || getGlobalConfig().fm != 1) {
                return super.onTouchEvent(motionEvent);
            }
            return false;
        }
        String strEf = fmVarFm.ef();
        if (fmVarFm instanceof com.bytedance.adsdk.ro.lb.lb.ro) {
            if (getGlobalConfig() == null || getGlobalConfig().fm != 1) {
                return super.onTouchEvent(motionEvent);
            }
            return false;
        }
        if (strEf != null && strEf.startsWith("CSJCLOSE")) {
            irt();
        }
        vt vtVarFm = fm(fmVarFm.jnr());
        if (vtVarFm != null && motionEvent.getAction() == 1) {
            fm(strEf, vtVarFm.jnr(), vtVarFm.wsy());
            int[][] iArrAjl = vtVarFm.ajl();
            if (iArrAjl != null) {
                fm(iArrAjl);
            } else if (getGlobalEvent() != null && (iArr = getGlobalEvent().ro) != null) {
                fm(iArr);
            }
        }
        if (strEf == null || !strEf.startsWith("CSJNTP")) {
            return super.onTouchEvent(motionEvent);
        }
        return false;
    }

    public void setAnimation(int i10) {
        this.f6184ef = i10;
        this.wu = null;
        setCompositionTask(fm(i10));
    }

    public void setAnimationFromJson(String str) {
        fm(str, (String) null);
    }

    public void setAnimationFromUrl(String str) {
        setCompositionTask(this.duv ? wu.fm(getContext(), str) : wu.fm(getContext(), str, (String) null));
    }

    public void setApplyingOpacityToLayersEnabled(boolean z10) {
        this.wsy.jnr(z10);
    }

    public void setCacheComposition(boolean z10) {
        this.duv = z10;
    }

    public void setClipToCompositionBounds(boolean z10) {
        this.wsy.fm(z10);
    }

    public void setComposition(wsy wsyVar) {
        if (jnr.fm) {
            "Set Composition \n".concat(String.valueOf(wsyVar));
        }
        this.wsy.setCallback(this);
        this.irt = wsyVar;
        this.vt = true;
        boolean zFm = this.wsy.fm(wsyVar, getContext().getApplicationContext());
        this.vt = false;
        if (getDrawable() != this.wsy || zFm) {
            if (!zFm) {
                gof();
            }
            onVisibilityChanged(this, getVisibility());
            requestLayout();
            Iterator<Object> it = this.onz.iterator();
            while (it.hasNext()) {
                it.next();
            }
        }
    }

    public void setDefaultFontFileExtension(String str) {
        this.wsy.wsy(str);
    }

    public void setFailureListener(ku<Throwable> kuVar) {
        this.jnr = kuVar;
    }

    public void setFallbackResource(int i10) {
        this.ajl = i10;
    }

    public void setFontAssetDelegate(com.bytedance.adsdk.ro.lb lbVar) {
        this.wsy.fm(lbVar);
    }

    public void setFontMap(Map<String, Typeface> map) {
        this.wsy.fm(map);
    }

    public void setFrame(int i10) {
        this.wsy.lb(i10);
    }

    public void setIgnoreDisabledSystemAnimations(boolean z10) {
        this.wsy.wsy(z10);
    }

    public void setImageAssetDelegate(com.bytedance.adsdk.ro.yz yzVar) {
        this.wsy.fm(yzVar);
    }

    public void setImageAssetsFolder(String str) {
        this.wsy.fm(str);
    }

    @Override // android.widget.ImageView
    public void setImageBitmap(Bitmap bitmap) {
        dsz();
        super.setImageBitmap(bitmap);
    }

    @Override // android.widget.ImageView
    public void setImageDrawable(Drawable drawable) {
        dsz();
        super.setImageDrawable(drawable);
    }

    @Override // android.widget.ImageView
    public void setImageResource(int i10) {
        dsz();
        super.setImageResource(i10);
    }

    public void setLottieAnimListener(fm fmVar) {
        this.ol = fmVar;
    }

    public void setLottieClicklistener(ro roVar) {
        this.ai = roVar;
    }

    public void setMaintainOriginalImageBounds(boolean z10) {
        this.wsy.ro(z10);
    }

    public void setMaxFrame(int i10) {
        this.wsy.ro(i10);
    }

    public void setMaxProgress(float f10) {
        this.wsy.ro(f10);
    }

    public void setMinAndMaxFrame(String str) {
        this.wsy.yz(str);
    }

    public void setMinFrame(int i10) {
        this.wsy.fm(i10);
    }

    public void setMinProgress(float f10) {
        this.wsy.fm(f10);
    }

    public void setOutlineMasksAndMattes(boolean z10) {
        this.wsy.yz(z10);
    }

    public void setPerformanceTrackingEnabled(boolean z10) {
        this.wsy.lb(z10);
    }

    public void setProgress(float f10) {
        fm(f10, true);
    }

    public void setRenderMode(gqi gqiVar) {
        this.wsy.fm(gqiVar);
    }

    public void setRepeatCount(int i10) {
        this.dsz.add(yz.SET_REPEAT_COUNT);
        this.wsy.jnr(i10);
    }

    public void setRepeatMode(int i10) {
        this.dsz.add(yz.SET_REPEAT_MODE);
        this.wsy.yz(i10);
    }

    public void setSafeMode(boolean z10) {
        this.wsy.ajl(z10);
    }

    public void setSpeed(float f10) {
        this.wsy.lb(f10);
    }

    public void setTextDelegate(wey weyVar) {
        this.wsy.fm(weyVar);
    }

    public void setUseCompositionFrameRate(boolean z10) {
        this.wsy.wu(z10);
    }

    public void setView(View view) {
        this.wsy.fm(view);
    }

    @Override // android.view.View
    public void unscheduleDrawable(Drawable drawable) {
        ef efVar;
        if (!this.vt && drawable == (efVar = this.wsy) && efVar.maa()) {
            ajl();
        } else if (!this.vt && (drawable instanceof ef)) {
            ef efVar2 = (ef) drawable;
            if (efVar2.maa()) {
                efVar2.gzf();
            }
        }
        super.unscheduleDrawable(drawable);
    }

    private void dsz() {
        dsz<wsy> dszVar = this.fhx;
        if (dszVar != null) {
            dszVar.ro(this.f6185lb);
            this.fhx.yz(this.yz);
        }
    }

    private void duv() {
        fm(new Animator.AnimatorListener() { // from class: com.bytedance.adsdk.ro.ajl.11
            @Override // android.animation.Animator.AnimatorListener
            public void onAnimationCancel(Animator animator) {
            }

            @Override // android.animation.Animator.AnimatorListener
            public void onAnimationEnd(Animator animator) {
            }

            @Override // android.animation.Animator.AnimatorListener
            public void onAnimationRepeat(Animator animator) {
            }

            @Override // android.animation.Animator.AnimatorListener
            public void onAnimationStart(Animator animator) {
                wey weyVarHlt;
                final long jElapsedRealtime = SystemClock.elapsedRealtime() - ajl.this.wey;
                ajl.this.ro(this);
                String playDelayedELExpressTimeS = ajl.this.getPlayDelayedELExpressTimeS();
                if (!TextUtils.isEmpty(playDelayedELExpressTimeS) && (weyVarHlt = ajl.this.wsy.hlt()) != null) {
                    try {
                        int i10 = Integer.parseInt(weyVarHlt.fm(playDelayedELExpressTimeS)) * 1000;
                        if (ajl.this.wey > 0) {
                            long jElapsedRealtime2 = (ajl.this.wey + ((long) i10)) - SystemClock.elapsedRealtime();
                            "--==-- lottie delayed time: ".concat(String.valueOf(jElapsedRealtime2));
                            if (jElapsedRealtime2 > 0) {
                                ajl.this.ajl();
                                ajl.this.setVisibility(8);
                                if (ajl.this.gqi == null) {
                                    ajl.this.gqi = new Handler(Looper.getMainLooper());
                                }
                                ajl.this.gqi.removeCallbacksAndMessages(null);
                                ajl.this.gqi.postDelayed(new Runnable() { // from class: com.bytedance.adsdk.ro.ajl.11.1
                                    @Override // java.lang.Runnable
                                    public void run() {
                                        ajl.this.setVisibility(0);
                                        ajl.this.fm();
                                        ajl.this.fm(jElapsedRealtime);
                                    }
                                }, jElapsedRealtime2);
                                return;
                            }
                        }
                    } catch (NumberFormatException unused) {
                    }
                }
                ajl.this.fm(jElapsedRealtime);
            }
        });
    }

    private void ef() {
        fm(new Animator.AnimatorListener() { // from class: com.bytedance.adsdk.ro.ajl.8
            @Override // android.animation.Animator.AnimatorListener
            public void onAnimationCancel(Animator animator) {
            }

            @Override // android.animation.Animator.AnimatorListener
            public void onAnimationEnd(Animator animator) {
            }

            @Override // android.animation.Animator.AnimatorListener
            public void onAnimationRepeat(Animator animator) {
            }

            @Override // android.animation.Animator.AnimatorListener
            public void onAnimationStart(Animator animator) {
                ajl.this.ro(this);
                ajl.this.onz();
                ajl.this.ku();
            }
        });
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void fhx() {
        this.qhl.postDelayed(this.gzf, 1000L);
    }

    private void gof() {
        boolean zYz = yz();
        setImageDrawable(null);
        setImageDrawable(this.wsy);
        if (zYz) {
            this.wsy.dsz();
        }
    }

    private void irt() {
        this.qhl.removeCallbacksAndMessages(null);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void ku() {
        final wsy.fm globalConfig = getGlobalConfig();
        if (globalConfig == null || globalConfig.jnr <= 0) {
            return;
        }
        if (TextUtils.isEmpty(globalConfig.ajl) && globalConfig.wsy == null) {
            return;
        }
        int maxFrame = globalConfig.jnr;
        if (maxFrame > getMaxFrame()) {
            maxFrame = (int) getMaxFrame();
        }
        final float maxFrame2 = maxFrame / getMaxFrame();
        fm(new ValueAnimator.AnimatorUpdateListener() { // from class: com.bytedance.adsdk.ro.ajl.10
            @Override // android.animation.ValueAnimator.AnimatorUpdateListener
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                Object animatedValue = valueAnimator.getAnimatedValue();
                if (!(animatedValue instanceof Float) || ((Float) animatedValue).floatValue() < maxFrame2) {
                    return;
                }
                ajl.this.ro(this);
                if (ajl.this.ai != null) {
                    ro unused = ajl.this.ai;
                }
            }
        });
    }

    private void lb(Matrix matrix, float f10, float f11, float f12, float f13) {
        matrix.postTranslate((f10 - f12) / 2.0f, (f11 - f13) / 2.0f);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void onz() {
        ef efVar;
        int i10;
        int i11;
        final int i12;
        com.bytedance.adsdk.ro.lb.lb.lb lbVarLb;
        if (this.irt == null || (efVar = this.wsy) == null) {
            return;
        }
        wey weyVarHlt = efVar.hlt();
        wsy.lb lbVarWu = this.irt.wu();
        if (lbVarWu == null || weyVarHlt == null) {
            return;
        }
        final int i13 = lbVarWu.fm;
        if (i13 < 0) {
            "--==--- timer fail, ke is invalid: ".concat(String.valueOf(i13));
            return;
        }
        int[] iArr = lbVarWu.jnr;
        final int i14 = -1;
        if (iArr == null || iArr.length < 2) {
            i10 = -1;
            i11 = -1;
        } else {
            i11 = iArr[0];
            i10 = iArr[1];
        }
        String strFm = weyVarHlt.fm(lbVarWu.f6294lb);
        String strFm2 = weyVarHlt.fm(lbVarWu.yz);
        try {
            i12 = Integer.parseInt(strFm);
            try {
                i14 = Integer.parseInt(strFm2);
            } catch (NumberFormatException unused) {
            }
        } catch (NumberFormatException unused2) {
            i12 = -1;
        }
        if (TextUtils.isEmpty(lbVarWu.ro) || (lbVarLb = lb(lbVarWu.ro)) == null) {
            return;
        }
        this.nt = lbVarWu.ajl;
        this.mq = lbVarWu.wsy;
        this.sds = lbVarLb;
        this.maa = i12;
        this.lse = i12 - i14;
        this.hlt = i11;
        this.hi = i10;
        StringBuilder sb = new StringBuilder();
        sb.append(this.maa);
        lbVarLb.fm(sb.toString());
        fm(new ValueAnimator.AnimatorUpdateListener() { // from class: com.bytedance.adsdk.ro.ajl.3
            @Override // android.animation.ValueAnimator.AnimatorUpdateListener
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                if (ajl.this.getFrame() < i13 - 1 || ajl.this.getFrame() >= i13 + 2) {
                    return;
                }
                ajl.this.getFrame();
                ajl.this.ro(this);
                if (i12 >= 0 && i14 >= 0) {
                    ajl.this.fhx();
                }
                ajl.this.ajl();
            }
        });
    }

    private void qhl() {
        this.irt = null;
        this.wsy.vt();
    }

    private void ro(RectF rectF, RectF rectF2) {
        float width = getWidth();
        float height = getHeight();
        float fWidth = this.wsy.getBounds().width();
        float fHeight = this.wsy.getBounds().height();
        if (width == 0.0f || height == 0.0f || fWidth == 0.0f || fHeight == 0.0f) {
            return;
        }
        Matrix matrix = new Matrix();
        int i10 = AnonymousClass5.fm[getScaleType().ordinal()];
        if (i10 == 1) {
            fm(matrix, width, height, fWidth, fHeight);
        } else if (i10 == 2) {
            ro(matrix, width, height, fWidth, fHeight);
        } else if (i10 == 3) {
            lb(matrix, width, height, fWidth, fHeight);
        } else if (i10 == 4) {
            yz(matrix, width, height, fWidth, fHeight);
        }
        matrix.mapRect(rectF, rectF2);
    }

    private void vt() {
        fm(new ValueAnimator.AnimatorUpdateListener() { // from class: com.bytedance.adsdk.ro.ajl.9
            @Override // android.animation.ValueAnimator.AnimatorUpdateListener
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                int i10;
                Object animatedValue = valueAnimator.getAnimatedValue();
                if (!(animatedValue instanceof Float) || ((Float) animatedValue).floatValue() < 0.98f) {
                    return;
                }
                ajl.jnr(ajl.this);
                wsy.fm globalConfig = ajl.this.getGlobalConfig();
                if (globalConfig != null && (i10 = globalConfig.yz) > 0 && i10 > ajl.this.gof) {
                    ajl.this.onz();
                    ajl.this.fm();
                    ajl.this.setProgress(0.0f);
                } else {
                    ajl.this.ro(this);
                    if (ajl.this.ol != null) {
                        fm unused = ajl.this.ol;
                    }
                }
            }
        });
    }

    private void wu() {
        setSaveEnabled(false);
        this.duv = true;
        setFallbackResource(0);
        setImageAssetsFolder("");
        fm(0.0f, false);
        fm(false, getContext().getApplicationContext());
        setIgnoreDisabledSystemAnimations(false);
        this.wsy.fm(Boolean.valueOf(com.bytedance.adsdk.ro.ajl.ajl.fm(getContext()) != 0.0f));
        ef();
        vt();
        duv();
    }

    private void yz(Matrix matrix, float f10, float f11, float f12, float f13) {
        if (f12 >= f10 || f13 >= f11) {
            if (f12 / f13 >= f10 / f11) {
                float f14 = f10 / f12;
                matrix.preScale(f14, f14);
                matrix.postTranslate(0.0f, (f11 - (f13 * f14)) / 2.0f);
                return;
            } else {
                float f15 = f11 / f13;
                matrix.preScale(f15, f15);
                matrix.postTranslate((f10 - (f12 * f15)) / 2.0f, 0.0f);
                return;
            }
        }
        if (f12 / f13 >= f10 / f11) {
            float f16 = f10 / f12;
            matrix.preScale(f16, f16);
            matrix.postTranslate(0.0f, (f11 - (f13 * f16)) / 2.0f);
        } else {
            float f17 = f11 / f13;
            matrix.preScale(f17, f17);
            matrix.postTranslate((f10 - (f12 * f17)) / 2.0f, 0.0f);
        }
    }

    public void ajl() {
        this.ku = false;
        this.wsy.gzf();
    }

    public void jnr() {
        this.dsz.add(yz.PLAY_OPTION);
        this.wsy.mq();
    }

    public void setAnimation(String str) {
        this.wu = str;
        this.f6184ef = 0;
        setCompositionTask(ro(str));
    }

    public void setMaxFrame(String str) {
        this.wsy.lb(str);
    }

    public void setMinFrame(String str) {
        this.wsy.ro(str);
    }

    private com.bytedance.adsdk.ro.lb.lb.lb lb(String str) {
        com.bytedance.adsdk.ro.lb.lb.ro roVarRo;
        ef efVar = this.wsy;
        if (efVar == null || (roVarRo = efVar.ro()) == null) {
            return null;
        }
        return fm(roVarRo, str);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void fm(long j10) {
        Map<String, Object> map;
        wsy.fm globalConfig = getGlobalConfig();
        if (this.ol != null) {
            HashMap map2 = new HashMap();
            map2.put("duration", Long.valueOf(j10));
            if (globalConfig == null || (map = globalConfig.ro) == null || map.isEmpty()) {
                return;
            }
            map2.putAll(globalConfig.ro);
        }
    }

    public void lb() {
        this.wsy.gof();
    }

    private vt fm(String str) {
        ef efVar;
        wsy wsyVarNt;
        Map<String, vt> mapIrt;
        if (TextUtils.isEmpty(str) || (efVar = this.wsy) == null || (wsyVarNt = efVar.nt()) == null || (mapIrt = wsyVarNt.irt()) == null) {
            return null;
        }
        return mapIrt.get(str);
    }

    public boolean yz() {
        return this.wsy.maa();
    }

    private void fm(int[][] iArr) {
        if (iArr == null || iArr.length == 0) {
            return;
        }
        try {
            int[] iArr2 = iArr[0];
            int i10 = iArr2[0];
            final int i11 = iArr2[1];
            if (i10 < 0 || i11 < 0) {
                return;
            }
            "--==--- inel enter, play anim, startframe: ".concat(String.valueOf(i10));
            irt();
            fm();
            setFrame(i10);
            fm(new ValueAnimator.AnimatorUpdateListener() { // from class: com.bytedance.adsdk.ro.ajl.12
                @Override // android.animation.ValueAnimator.AnimatorUpdateListener
                public void onAnimationUpdate(ValueAnimator valueAnimator) {
                    if (ajl.this.getFrame() < i11 - 1 || ajl.this.getFrame() >= i11 + 2) {
                        return;
                    }
                    ajl.this.getFrame();
                    ajl.this.ro(this);
                    ajl.this.ajl();
                }
            });
        } catch (Throwable unused) {
        }
    }

    private void ro(Matrix matrix, float f10, float f11, float f12, float f13) {
        if (f12 < f10 && f13 < f11) {
            matrix.postTranslate((f10 - f12) / 2.0f, (f11 - f13) / 2.0f);
            return;
        }
        if (f12 / f13 >= f10 / f11) {
            float f14 = f10 / f12;
            matrix.preScale(f14, f14);
            matrix.postTranslate(0.0f, (f11 - (f13 * f14)) / 2.0f);
        } else {
            float f15 = f11 / f13;
            matrix.preScale(f15, f15);
            matrix.postTranslate((f10 - (f12 * f15)) / 2.0f, 0.0f);
        }
    }

    private dsz<wsy> ro(final String str) {
        if (isInEditMode()) {
            return new dsz<>(new Callable<duv<wsy>>() { // from class: com.bytedance.adsdk.ro.ajl.2
                @Override // java.util.concurrent.Callable
                /* JADX INFO: renamed from: fm, reason: merged with bridge method [inline-methods] */
                public duv<wsy> call() throws Exception {
                    return ajl.this.duv ? wu.lb(ajl.this.getContext(), str) : wu.lb(ajl.this.getContext(), str, null);
                }
            }, true);
        }
        return this.duv ? wu.ro(getContext(), str) : wu.ro(getContext(), str, (String) null);
    }

    private void fm(String str, String str2, JSONArray jSONArray) {
        wsy.ro globalEvent = getGlobalEvent();
        if (globalEvent != null && str != null) {
            if (TextUtils.isEmpty(str2) && !str.contains("CSJNO")) {
                str2 = globalEvent.fm;
            }
            if ((jSONArray == null || jSONArray.length() <= 0) && !str.contains("CSJLELNO")) {
                jSONArray = globalEvent.f6295lb;
            }
        }
        if (!TextUtils.isEmpty(str2) || jSONArray == null) {
            return;
        }
        jSONArray.length();
    }

    public void ro(ValueAnimator.AnimatorUpdateListener animatorUpdateListener) {
        this.wsy.ro(animatorUpdateListener);
    }

    public void ro() {
        this.wsy.qhl();
    }

    public void ro(Animator.AnimatorListener animatorListener) {
        this.wsy.ro(animatorListener);
    }

    private com.bytedance.adsdk.ro.lb.lb.fm fm(MotionEvent motionEvent) {
        com.bytedance.adsdk.ro.lb.lb.ro roVarRo;
        ef efVar = this.wsy;
        if (efVar == null || (roVarRo = efVar.ro()) == null) {
            return null;
        }
        return fm(roVarRo, motionEvent);
    }

    private com.bytedance.adsdk.ro.lb.lb.fm fm(com.bytedance.adsdk.ro.lb.lb.ro roVar, MotionEvent motionEvent) {
        com.bytedance.adsdk.ro.lb.lb.fm fmVarFm;
        for (com.bytedance.adsdk.ro.lb.lb.fm fmVar : roVar.duv()) {
            if (fmVar instanceof com.bytedance.adsdk.ro.lb.lb.ro) {
                if (fmVar.wu() && fmVar.ajl() > 0.0f) {
                    RectF rectF = new RectF();
                    fmVar.fm(rectF, fmVar.yz(), true);
                    if (rectF.width() >= 3.0f && rectF.height() >= 3.0f && (fmVarFm = fm((com.bytedance.adsdk.ro.lb.lb.ro) fmVar, motionEvent)) != null) {
                        return fmVarFm;
                    }
                }
            } else if (fmVar.wu() && fmVar.ajl() > 0.0f) {
                RectF rectF2 = new RectF();
                ef efVar = this.wsy;
                if (efVar != null && efVar.wsy()) {
                    fmVar.fm(rectF2, fmVar.yz(), true);
                    RectF rectFOl = this.wsy.ol();
                    if (rectFOl != null) {
                        fm(rectF2, rectFOl);
                    }
                } else {
                    RectF rectF3 = new RectF();
                    fmVar.fm(rectF3, fmVar.yz(), true);
                    ro(rectF2, rectF3);
                }
                if (fm(motionEvent, rectF2)) {
                    return fmVar;
                }
            }
        }
        return null;
    }

    private boolean fm(MotionEvent motionEvent, RectF rectF) {
        if (motionEvent != null && rectF != null) {
            float x10 = motionEvent.getX();
            float y10 = motionEvent.getY();
            if (x10 >= rectF.left && x10 <= rectF.right && y10 >= rectF.top && y10 <= rectF.bottom) {
                return true;
            }
        }
        return false;
    }

    private void fm(RectF rectF, RectF rectF2) {
        float width = getWidth();
        float height = getHeight();
        float fWidth = rectF2.width();
        float fHeight = rectF2.height();
        if (width == 0.0f || height == 0.0f || fWidth == 0.0f || fHeight == 0.0f) {
            return;
        }
        Matrix matrix = new Matrix();
        int i10 = AnonymousClass5.fm[getScaleType().ordinal()];
        if (i10 == 1) {
            fm(matrix, width, height, fWidth, fHeight);
        } else if (i10 == 2) {
            ro(matrix, width, height, fWidth, fHeight);
        } else if (i10 == 3) {
            lb(matrix, width, height, fWidth, fHeight);
        } else if (i10 == 4) {
            yz(matrix, width, height, fWidth, fHeight);
        }
        matrix.mapRect(rectF);
    }

    private void fm(Matrix matrix, float f10, float f11, float f12, float f13) {
        if (f12 / f13 >= f10 / f11) {
            float f14 = f11 / f13;
            matrix.preScale(f14, f14);
            matrix.postTranslate(-(((f12 * f14) - f10) / 2.0f), 0.0f);
        } else {
            float f15 = f10 / f12;
            matrix.preScale(f15, f15);
            matrix.postTranslate(0.0f, -(((f13 * f15) - f11) / 2.0f));
        }
    }

    public void fm(boolean z10, Context context) {
        this.wsy.fm(z10, context);
    }

    private dsz<wsy> fm(final int i10) {
        if (isInEditMode()) {
            return new dsz<>(new Callable<duv<wsy>>() { // from class: com.bytedance.adsdk.ro.ajl.13
                @Override // java.util.concurrent.Callable
                /* JADX INFO: renamed from: fm, reason: merged with bridge method [inline-methods] */
                public duv<wsy> call() throws Exception {
                    return ajl.this.duv ? wu.ro(ajl.this.getContext(), i10) : wu.ro(ajl.this.getContext(), i10, (String) null);
                }
            }, true);
        }
        return this.duv ? wu.fm(getContext(), i10) : wu.fm(getContext(), i10, (String) null);
    }

    public void fm(String str, String str2) {
        fm(new ByteArrayInputStream(str.getBytes()), str2);
    }

    public void fm(InputStream inputStream, String str) {
        setCompositionTask(wu.fm(inputStream, str));
    }

    private com.bytedance.adsdk.ro.lb.lb.lb fm(com.bytedance.adsdk.ro.lb.lb.ro roVar, String str) {
        for (com.bytedance.adsdk.ro.lb.lb.fm fmVar : roVar.duv()) {
            if (fmVar instanceof com.bytedance.adsdk.ro.lb.lb.ro) {
                com.bytedance.adsdk.ro.lb.lb.lb lbVarFm = fm((com.bytedance.adsdk.ro.lb.lb.ro) fmVar, str);
                if (lbVarFm != null) {
                    return lbVarFm;
                }
            } else if (TextUtils.equals(str, fmVar.ef()) && (fmVar instanceof com.bytedance.adsdk.ro.lb.lb.lb)) {
                return (com.bytedance.adsdk.ro.lb.lb.lb) fmVar;
            }
        }
        return null;
    }

    public void fm() {
        if (this.wey == 0) {
            this.wey = SystemClock.elapsedRealtime();
        }
        this.dsz.add(yz.PLAY_OPTION);
        this.wsy.ku();
    }

    public void fm(ValueAnimator.AnimatorUpdateListener animatorUpdateListener) {
        this.wsy.fm(animatorUpdateListener);
    }

    public void fm(Animator.AnimatorListener animatorListener) {
        this.wsy.fm(animatorListener);
    }

    public void fm(boolean z10) {
        this.wsy.jnr(z10 ? -1 : 0);
    }

    public Bitmap fm(String str, Bitmap bitmap) {
        return this.wsy.fm(str, bitmap);
    }

    private void fm(float f10, boolean z10) {
        if (z10) {
            this.dsz.add(yz.SET_PROGRESS);
        }
        this.wsy.yz(f10);
    }
}
