package com.bytedance.adsdk.ugeno.fm;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Canvas;
import android.view.View;
import com.bytedance.adsdk.ugeno.fm.fm.fm;
import com.bytedance.adsdk.ugeno.fm.lb;
import java.util.ArrayList;
import java.util.Map;
import java.util.TreeMap;
import org.json.JSONObject;

/* JADX INFO: loaded from: classes.dex */
public class fm extends AnimatorListenerAdapter {
    private int ajl = 1;

    /* JADX INFO: renamed from: ef, reason: collision with root package name */
    private ro f6339ef;
    private com.bytedance.adsdk.ugeno.ro.lb fm;
    private int jnr;

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    private ValueAnimator f6340lb;
    private lb ro;
    private com.bytedance.adsdk.ugeno.fm.fm.fm wsy;
    private String wu;
    private Context yz;

    public fm(Context context, com.bytedance.adsdk.ugeno.ro.lb lbVar, lb lbVar2) {
        this.fm = lbVar;
        this.ro = lbVar2;
        this.yz = context;
    }

    public void fm(ro roVar) {
        this.f6339ef = roVar;
    }

    public String jnr() {
        return this.wu;
    }

    public void lb() {
        ValueAnimator valueAnimator = this.f6340lb;
        if (valueAnimator != null) {
            valueAnimator.cancel();
        }
    }

    @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
    public void onAnimationEnd(Animator animator) {
        super.onAnimationEnd(animator);
        ro roVar = this.f6339ef;
        if (roVar != null) {
            roVar.ro();
        }
    }

    @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
    public void onAnimationStart(Animator animator) {
        super.onAnimationStart(animator);
        ro roVar = this.f6339ef;
        if (roVar != null) {
            roVar.fm();
        }
    }

    public void ro() {
        ValueAnimator valueAnimator = this.f6340lb;
        if (valueAnimator != null) {
            valueAnimator.start();
        }
    }

    public ValueAnimator yz() {
        String key;
        com.bytedance.adsdk.ugeno.fm.ro.fm lbVar;
        lb lbVar2 = this.ro;
        if (lbVar2 == null || this.fm == null) {
            return null;
        }
        Map<String, TreeMap<Float, String>> mapRo = lbVar2.ro();
        ArrayList arrayList = new ArrayList();
        if (mapRo != null && !mapRo.isEmpty()) {
            for (Map.Entry<String, TreeMap<Float, String>> entry : mapRo.entrySet()) {
                if (entry != null) {
                    key = entry.getKey();
                    String strLb = jnr.fm(key).lb();
                    strLb.getClass();
                    switch (strLb) {
                        case "int":
                            lbVar = new com.bytedance.adsdk.ugeno.fm.ro.lb(this.yz, this.fm, key, entry.getValue());
                            break;
                        case "float":
                            lbVar = new com.bytedance.adsdk.ugeno.fm.ro.ro(this.yz, this.fm, key, entry.getValue());
                            break;
                        case "point":
                            lbVar = new com.bytedance.adsdk.ugeno.fm.ro.yz(this.yz, this.fm, key, entry.getValue());
                            break;
                        default:
                            lbVar = null;
                            break;
                    }
                    if (lbVar != null) {
                        arrayList.addAll(lbVar.jnr());
                    }
                }
            }
        }
        JSONObject jSONObjectFm = this.ro.fm();
        if (jSONObjectFm != null) {
            com.bytedance.adsdk.ugeno.fm.fm.fm fmVarFm = fm.C0017fm.fm(this.fm, jSONObjectFm);
            this.wsy = fmVarFm;
            if (fmVarFm != null) {
                arrayList.addAll(fmVarFm.lb());
            }
        }
        final View viewKu = this.fm.ku();
        if (viewKu == null) {
            return null;
        }
        final lb.fm fmVarWsy = this.ro.wsy();
        if (fmVarWsy != null) {
            viewKu.post(new Runnable() { // from class: com.bytedance.adsdk.ugeno.fm.fm.1
                @Override // java.lang.Runnable
                public void run() {
                    int width = viewKu.getWidth();
                    int height = viewKu.getHeight();
                    viewKu.setPivotX(yz.fm(fmVarWsy.fm, width));
                    viewKu.setPivotY(yz.fm(fmVarWsy.ro, height));
                }
            });
        }
        ObjectAnimator objectAnimatorOfPropertyValuesHolder = ObjectAnimator.ofPropertyValuesHolder(viewKu, (PropertyValuesHolder[]) arrayList.toArray(new PropertyValuesHolder[0]));
        this.jnr = yz.fm(this.ro.yz());
        objectAnimatorOfPropertyValuesHolder.setDuration(this.ro.lb());
        int i10 = this.jnr;
        if (i10 != Integer.MIN_VALUE) {
            objectAnimatorOfPropertyValuesHolder.setRepeatCount(i10);
        }
        this.ajl = this.ro.vt();
        this.wu = this.ro.ef();
        objectAnimatorOfPropertyValuesHolder.setStartDelay(this.ro.ajl());
        objectAnimatorOfPropertyValuesHolder.setRepeatMode(yz.fm(this.ro.jnr()));
        objectAnimatorOfPropertyValuesHolder.setInterpolator(yz.ro(this.ro.wu()));
        objectAnimatorOfPropertyValuesHolder.addListener(this);
        this.f6340lb = objectAnimatorOfPropertyValuesHolder;
        return objectAnimatorOfPropertyValuesHolder;
    }

    public void fm() {
        ValueAnimator valueAnimator = this.f6340lb;
        if (valueAnimator == null || this.ajl == 0 || this.jnr == Integer.MIN_VALUE) {
            return;
        }
        valueAnimator.start();
    }

    public void ro(Canvas canvas) {
        com.bytedance.adsdk.ugeno.fm.fm.fm fmVar = this.wsy;
        if (fmVar != null) {
            fmVar.ro(canvas);
        }
    }

    public void fm(Canvas canvas) {
        com.bytedance.adsdk.ugeno.fm.fm.fm fmVar = this.wsy;
        if (fmVar != null) {
            fmVar.fm(canvas);
        }
    }

    public void fm(int i10, int i11) {
        com.bytedance.adsdk.ugeno.fm.fm.fm fmVar = this.wsy;
        if (fmVar != null) {
            fmVar.fm(i10, i11);
        }
    }
}
