package com.bytedance.sdk.component.adexpress.ajl;

import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.view.ViewGroup;
import android.view.animation.LinearInterpolator;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;

/* JADX INFO: loaded from: classes.dex */
public class fhx extends FrameLayout {
    private TextView ajl;
    private Context fm;
    private boolean jnr;

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    private maa f6435lb;
    private ImageView ro;
    private AnimatorSet yz;

    public fhx(@NonNull Context context) {
        super(context);
        this.jnr = true;
        this.fm = context;
        this.yz = new AnimatorSet();
        lb();
        yz();
        post(new Runnable() { // from class: com.bytedance.sdk.component.adexpress.ajl.fhx.1
            @Override // java.lang.Runnable
            public void run() {
                int iFm = (int) com.bytedance.sdk.component.adexpress.yz.wsy.fm(fhx.this.fm, 50.0f);
                int iFm2 = (int) com.bytedance.sdk.component.adexpress.yz.wsy.fm(fhx.this.fm, 50.0f);
                if (fhx.this.f6435lb.getMeasuredHeight() > 0) {
                    iFm = fhx.this.f6435lb.getMeasuredHeight();
                }
                if (fhx.this.f6435lb.getMeasuredWidth() > 0) {
                    iFm2 = fhx.this.f6435lb.getMeasuredWidth();
                }
                FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) fhx.this.ro.getLayoutParams();
                layoutParams.topMargin = ((int) ((iFm / 2.0f) - com.bytedance.sdk.component.adexpress.yz.wsy.fm(fhx.this.getContext(), 5.0f))) + ((int) com.bytedance.sdk.component.adexpress.yz.wsy.fm(fhx.this.fm, 40.0f));
                layoutParams.leftMargin = ((int) ((iFm2 / 2.0f) - com.bytedance.sdk.component.adexpress.yz.wsy.fm(fhx.this.getContext(), 5.0f))) + ((int) com.bytedance.sdk.component.adexpress.yz.wsy.fm(fhx.this.fm, 20.0f));
                layoutParams.bottomMargin = (int) (com.bytedance.sdk.component.adexpress.yz.wsy.fm(fhx.this.getContext(), 5.0f) + ((-iFm) / 2.0f));
                layoutParams.rightMargin = (int) (com.bytedance.sdk.component.adexpress.yz.wsy.fm(fhx.this.getContext(), 5.0f) + ((-iFm2) / 2.0f));
                layoutParams.setMarginStart(layoutParams.leftMargin);
                layoutParams.setMarginEnd(layoutParams.rightMargin);
                fhx.this.ro.setLayoutParams(layoutParams);
            }
        });
    }

    public void setGuideText(String str) {
        this.ajl.setVisibility(0);
        this.ajl.setText(str);
    }

    public void setGuideTextColor(int i10) {
        this.ajl.setTextColor(i10);
    }

    private void lb() {
        this.f6435lb = new maa(this.fm);
        FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams((int) com.bytedance.sdk.component.adexpress.yz.wsy.fm(this.fm, 50.0f), (int) com.bytedance.sdk.component.adexpress.yz.wsy.fm(this.fm, 50.0f));
        layoutParams.gravity = 8388659;
        layoutParams.topMargin = (int) com.bytedance.sdk.component.adexpress.yz.wsy.fm(this.fm, 40.0f);
        int iFm = (int) com.bytedance.sdk.component.adexpress.yz.wsy.fm(this.fm, 20.0f);
        layoutParams.leftMargin = iFm;
        layoutParams.setMarginStart(iFm);
        layoutParams.setMarginEnd(layoutParams.rightMargin);
        addView(this.f6435lb, layoutParams);
        this.ro = new ImageView(this.fm);
        ViewGroup.LayoutParams layoutParams2 = new FrameLayout.LayoutParams((int) com.bytedance.sdk.component.adexpress.yz.wsy.fm(this.fm, 78.0f), (int) com.bytedance.sdk.component.adexpress.yz.wsy.fm(this.fm, 78.0f));
        this.ro.setImageResource(com.bytedance.sdk.component.utils.maa.yz(this.fm, "tt_splash_hand"));
        addView(this.ro, layoutParams2);
        TextView textView = new TextView(this.fm);
        this.ajl = textView;
        textView.setTextColor(-1);
        FrameLayout.LayoutParams layoutParams3 = new FrameLayout.LayoutParams(-2, -2);
        layoutParams3.gravity = 81;
        layoutParams3.bottomMargin = (int) com.bytedance.sdk.component.adexpress.yz.wsy.fm(this.fm, 10.0f);
        addView(this.ajl, layoutParams3);
        this.ajl.setVisibility(8);
    }

    private void yz() {
        ObjectAnimator objectAnimatorOfFloat = ObjectAnimator.ofFloat(this.ro, "scaleX", 1.0f, 1.0f, 1.0f, 0.9f);
        objectAnimatorOfFloat.setDuration(600L);
        objectAnimatorOfFloat.setRepeatMode(2);
        objectAnimatorOfFloat.setRepeatCount(-1);
        objectAnimatorOfFloat.addListener(new Animator.AnimatorListener() { // from class: com.bytedance.sdk.component.adexpress.ajl.fhx.2
            @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) {
                if (fhx.this.jnr) {
                    fhx.this.f6435lb.fm();
                }
                fhx.this.jnr = !r2.jnr;
            }

            @Override // android.animation.Animator.AnimatorListener
            public void onAnimationStart(Animator animator) {
                ObjectAnimator objectAnimatorOfFloat2 = ObjectAnimator.ofFloat(fhx.this.ro, "alpha", 0.0f, 1.0f);
                objectAnimatorOfFloat2.setDuration(200L);
                objectAnimatorOfFloat2.setInterpolator(new LinearInterpolator());
                objectAnimatorOfFloat2.start();
                fhx.this.ro.setVisibility(0);
            }
        });
        ObjectAnimator objectAnimatorOfFloat2 = ObjectAnimator.ofFloat(this.ro, "scaleY", 1.0f, 1.0f, 1.0f, 0.9f);
        objectAnimatorOfFloat2.setDuration(600L);
        objectAnimatorOfFloat2.setRepeatMode(2);
        objectAnimatorOfFloat2.setRepeatCount(-1);
        this.yz.playTogether(objectAnimatorOfFloat, objectAnimatorOfFloat2);
    }

    public void ro() {
        AnimatorSet animatorSet = this.yz;
        if (animatorSet != null) {
            animatorSet.cancel();
        }
        maa maaVar = this.f6435lb;
        if (maaVar != null) {
            maaVar.ro();
        }
        ImageView imageView = this.ro;
        if (imageView != null) {
            imageView.clearAnimation();
        }
    }

    public void fm() {
        this.yz.start();
    }
}
