package androidx.constraintlayout.utils.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Path;
import android.graphics.RectF;
import android.util.AttributeSet;
import androidx.annotation.RequiresApi;
import androidx.appcompat.widget.AppCompatButton;
import androidx.constraintlayout.widget.s;
import b0.d;

/* JADX INFO: loaded from: classes.dex */
public class MotionButton extends AppCompatButton {

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public float f1210d;

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

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

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public d f1213g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public RectF f1214h;

    public MotionButton(Context context) {
        super(context);
        this.f1210d = 0.0f;
        this.f1211e = Float.NaN;
        a(context, null);
    }

    public final void a(Context context, AttributeSet attributeSet) {
        setPadding(0, 0, 0, 0);
        if (attributeSet != null) {
            TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, s.ImageFilterView);
            int indexCount = typedArrayObtainStyledAttributes.getIndexCount();
            for (int i10 = 0; i10 < indexCount; i10++) {
                int index = typedArrayObtainStyledAttributes.getIndex(i10);
                if (index == s.ImageFilterView_round) {
                    setRound(typedArrayObtainStyledAttributes.getDimension(index, 0.0f));
                } else if (index == s.ImageFilterView_roundPercent) {
                    setRoundPercent(typedArrayObtainStyledAttributes.getFloat(index, 0.0f));
                }
            }
            typedArrayObtainStyledAttributes.recycle();
        }
    }

    @Override // android.view.View
    public final void draw(Canvas canvas) {
        super.draw(canvas);
    }

    public float getRound() {
        return this.f1211e;
    }

    public float getRoundPercent() {
        return this.f1210d;
    }

    @RequiresApi(21)
    public void setRound(float f10) {
        if (Float.isNaN(f10)) {
            this.f1211e = f10;
            float f11 = this.f1210d;
            this.f1210d = -1.0f;
            setRoundPercent(f11);
            return;
        }
        boolean z10 = this.f1211e != f10;
        this.f1211e = f10;
        if (f10 != 0.0f) {
            if (this.f1212f == null) {
                this.f1212f = new Path();
            }
            if (this.f1214h == null) {
                this.f1214h = new RectF();
            }
            if (this.f1213g == null) {
                d dVar = new d(this, 1);
                this.f1213g = dVar;
                setOutlineProvider(dVar);
            }
            setClipToOutline(true);
            this.f1214h.set(0.0f, 0.0f, getWidth(), getHeight());
            this.f1212f.reset();
            Path path = this.f1212f;
            RectF rectF = this.f1214h;
            float f12 = this.f1211e;
            path.addRoundRect(rectF, f12, f12, Path.Direction.CW);
        } else {
            setClipToOutline(false);
        }
        if (z10) {
            invalidateOutline();
        }
    }

    @RequiresApi(21)
    public void setRoundPercent(float f10) {
        boolean z10 = this.f1210d != f10;
        this.f1210d = f10;
        if (f10 != 0.0f) {
            if (this.f1212f == null) {
                this.f1212f = new Path();
            }
            if (this.f1214h == null) {
                this.f1214h = new RectF();
            }
            if (this.f1213g == null) {
                d dVar = new d(this, 0);
                this.f1213g = dVar;
                setOutlineProvider(dVar);
            }
            setClipToOutline(true);
            int width = getWidth();
            int height = getHeight();
            float fMin = (Math.min(width, height) * this.f1210d) / 2.0f;
            this.f1214h.set(0.0f, 0.0f, width, height);
            this.f1212f.reset();
            this.f1212f.addRoundRect(this.f1214h, fMin, fMin, Path.Direction.CW);
        } else {
            setClipToOutline(false);
        }
        if (z10) {
            invalidateOutline();
        }
    }

    public MotionButton(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.f1210d = 0.0f;
        this.f1211e = Float.NaN;
        a(context, attributeSet);
    }

    public MotionButton(Context context, AttributeSet attributeSet, int i10) {
        super(context, attributeSet, i10);
        this.f1210d = 0.0f;
        this.f1211e = Float.NaN;
        a(context, attributeSet);
    }
}
