package androidx.leanback.widget;

import F1.AbstractC0195y;
import android.animation.ArgbEvaluator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewPropertyAnimator;
import android.widget.FrameLayout;
import android.widget.ImageView;
import com.debridstream.tv.R;
import java.lang.reflect.Field;

/* JADX INFO: loaded from: classes.dex */
public class SearchOrbView extends FrameLayout implements View.OnClickListener {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public View.OnClickListener f11907a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final View f11908b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final View f11909c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final ImageView f11910d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public Drawable f11911e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public M f11912f;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public final float f11913j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public final int f11914k;
    public final int l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public final float f11915m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public final float f11916n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public ValueAnimator f11917o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public boolean f11918p;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public boolean f11919q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public final ArgbEvaluator f11920r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public final L f11921s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public ValueAnimator f11922t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public final L f11923u;

    public SearchOrbView(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, R.attr.searchOrbViewStyle);
    }

    public final void a(boolean z6) {
        float f6 = z6 ? this.f11913j : 1.0f;
        ViewPropertyAnimator viewPropertyAnimatorScaleY = this.f11908b.animate().scaleX(f6).scaleY(f6);
        long j4 = this.l;
        viewPropertyAnimatorScaleY.setDuration(j4).start();
        if (this.f11922t == null) {
            ValueAnimator valueAnimatorOfFloat = ValueAnimator.ofFloat(0.0f, 1.0f);
            this.f11922t = valueAnimatorOfFloat;
            valueAnimatorOfFloat.addUpdateListener(this.f11923u);
        }
        if (z6) {
            this.f11922t.start();
        } else {
            this.f11922t.reverse();
        }
        this.f11922t.setDuration(j4);
        this.f11918p = z6;
        b();
    }

    public final void b() {
        ValueAnimator valueAnimator = this.f11917o;
        if (valueAnimator != null) {
            valueAnimator.end();
            this.f11917o = null;
        }
        if (this.f11918p && this.f11919q) {
            ValueAnimator valueAnimatorOfObject = ValueAnimator.ofObject(this.f11920r, Integer.valueOf(this.f11912f.f11825a), Integer.valueOf(this.f11912f.f11826b), Integer.valueOf(this.f11912f.f11825a));
            this.f11917o = valueAnimatorOfObject;
            valueAnimatorOfObject.setRepeatCount(-1);
            this.f11917o.setDuration(this.f11914k * 2);
            this.f11917o.addUpdateListener(this.f11921s);
            this.f11917o.start();
        }
    }

    public float getFocusedZoom() {
        return this.f11913j;
    }

    public int getLayoutResourceId() {
        return R.layout.lb_search_orb;
    }

    public int getOrbColor() {
        return this.f11912f.f11825a;
    }

    public M getOrbColors() {
        return this.f11912f;
    }

    public Drawable getOrbIcon() {
        return this.f11911e;
    }

    @Override // android.view.ViewGroup, android.view.View
    public final void onAttachedToWindow() {
        super.onAttachedToWindow();
        this.f11919q = true;
        b();
    }

    @Override // android.view.View.OnClickListener
    public final void onClick(View view) {
        View.OnClickListener onClickListener = this.f11907a;
        if (onClickListener != null) {
            onClickListener.onClick(view);
        }
    }

    @Override // android.view.ViewGroup, android.view.View
    public final void onDetachedFromWindow() {
        this.f11919q = false;
        b();
        super.onDetachedFromWindow();
    }

    @Override // android.view.View
    public final void onFocusChanged(boolean z6, int i6, Rect rect) {
        super.onFocusChanged(z6, i6, rect);
        a(z6);
    }

    public void setOnOrbClickedListener(View.OnClickListener onClickListener) {
        this.f11907a = onClickListener;
    }

    public void setOrbColor(int i6) {
        setOrbColors(new M(i6, i6, 0));
    }

    public void setOrbColors(M m6) {
        this.f11912f = m6;
        this.f11910d.setColorFilter(m6.f11827c);
        if (this.f11917o == null) {
            setOrbViewColor(this.f11912f.f11825a);
        } else {
            this.f11918p = true;
            b();
        }
    }

    public void setOrbIcon(Drawable drawable) {
        this.f11911e = drawable;
        this.f11910d.setImageDrawable(drawable);
    }

    public void setOrbViewColor(int i6) {
        View view = this.f11909c;
        if (view.getBackground() instanceof GradientDrawable) {
            ((GradientDrawable) view.getBackground()).setColor(i6);
        }
    }

    public void setSearchOrbZ(float f6) {
        float f7 = this.f11916n;
        float f8 = this.f11915m;
        float fA = com.google.android.recaptcha.internal.a.a(f7, f8, f6, f8);
        Field field = F1.F.f1367a;
        AbstractC0195y.e(this.f11909c, fA);
    }

    public SearchOrbView(Context context, AttributeSet attributeSet, int i6) {
        super(context, attributeSet, i6);
        this.f11920r = new ArgbEvaluator();
        this.f11921s = new L(this, 0);
        this.f11923u = new L(this, 1);
        Resources resources = context.getResources();
        View viewInflate = ((LayoutInflater) context.getSystemService("layout_inflater")).inflate(getLayoutResourceId(), (ViewGroup) this, true);
        this.f11908b = viewInflate;
        this.f11909c = viewInflate.findViewById(R.id.search_orb);
        ImageView imageView = (ImageView) viewInflate.findViewById(R.id.icon);
        this.f11910d = imageView;
        this.f11913j = context.getResources().getFraction(R.fraction.lb_search_orb_focused_zoom, 1, 1);
        this.f11914k = context.getResources().getInteger(R.integer.lb_search_orb_pulse_duration_ms);
        this.l = context.getResources().getInteger(R.integer.lb_search_orb_scale_duration_ms);
        float dimensionPixelSize = context.getResources().getDimensionPixelSize(R.dimen.lb_search_orb_focused_z);
        this.f11916n = dimensionPixelSize;
        this.f11915m = context.getResources().getDimensionPixelSize(R.dimen.lb_search_orb_unfocused_z);
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, Z1.a.f9147g, i6, 0);
        Drawable drawable = typedArrayObtainStyledAttributes.getDrawable(2);
        setOrbIcon(drawable == null ? resources.getDrawable(R.drawable.lb_ic_in_app_search) : drawable);
        int color = typedArrayObtainStyledAttributes.getColor(1, resources.getColor(R.color.lb_default_search_color));
        setOrbColors(new M(color, typedArrayObtainStyledAttributes.getColor(0, color), typedArrayObtainStyledAttributes.getColor(3, 0)));
        typedArrayObtainStyledAttributes.recycle();
        setFocusable(true);
        setClipChildren(false);
        setOnClickListener(this);
        setSoundEffectsEnabled(false);
        setSearchOrbZ(0.0f);
        Field field = F1.F.f1367a;
        AbstractC0195y.e(imageView, dimensionPixelSize);
    }
}
