package g9;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.view.View;
import androidx.annotation.Nullable;
import com.google.android.gms.measurement.internal.c2;

/* JADX INFO: loaded from: classes2.dex */
public final class b {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final a f26324a;

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

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

    @Nullable
    private Drawable overlayDrawable;

    @Nullable
    private f revealInfo;

    /* JADX WARN: Multi-variable type inference failed */
    public b(a aVar) {
        this.f26324a = aVar;
        View view = (View) aVar;
        this.f26325b = view;
        view.setWillNotDraw(false);
        new Path();
        new Paint(7);
        Paint paint = new Paint(1);
        this.f26326c = paint;
        paint.setColor(0);
    }

    public final void a(Canvas canvas) {
        f fVar = this.revealInfo;
        boolean z10 = !(fVar == null || fVar.f26333c == Float.MAX_VALUE);
        Paint paint = this.f26326c;
        a aVar = this.f26324a;
        View view = this.f26325b;
        if (z10) {
            aVar.c(canvas);
            if (Color.alpha(paint.getColor()) != 0) {
                canvas.drawRect(0.0f, 0.0f, view.getWidth(), view.getHeight(), paint);
            }
        } else {
            aVar.c(canvas);
            if (Color.alpha(paint.getColor()) != 0) {
                canvas.drawRect(0.0f, 0.0f, view.getWidth(), view.getHeight(), paint);
            }
        }
        Drawable drawable = this.overlayDrawable;
        if (drawable == null || this.revealInfo == null) {
            return;
        }
        Rect bounds = drawable.getBounds();
        float fWidth = this.revealInfo.f26331a - (bounds.width() / 2.0f);
        float fHeight = this.revealInfo.f26332b - (bounds.height() / 2.0f);
        canvas.translate(fWidth, fHeight);
        this.overlayDrawable.draw(canvas);
        canvas.translate(-fWidth, -fHeight);
    }

    public final boolean b() {
        if (!this.f26324a.d()) {
            return false;
        }
        f fVar = this.revealInfo;
        return !((fVar == null || (fVar.f26333c > Float.MAX_VALUE ? 1 : (fVar.f26333c == Float.MAX_VALUE ? 0 : -1)) == 0) ^ true);
    }

    public final void c(int i10) {
        this.f26326c.setColor(i10);
        this.f26325b.invalidate();
    }

    @Nullable
    public Drawable getCircularRevealOverlayDrawable() {
        return this.overlayDrawable;
    }

    @Nullable
    public f getRevealInfo() {
        f fVar = this.revealInfo;
        if (fVar == null) {
            return null;
        }
        f fVar2 = new f(fVar);
        if (fVar2.f26333c == Float.MAX_VALUE) {
            float f10 = fVar2.f26331a;
            float f11 = fVar2.f26332b;
            View view = this.f26325b;
            fVar2.f26333c = c2.h(f10, f11, view.getWidth(), view.getHeight());
        }
        return fVar2;
    }

    public void setCircularRevealOverlayDrawable(@Nullable Drawable drawable) {
        this.overlayDrawable = drawable;
        this.f26325b.invalidate();
    }

    public void setRevealInfo(@Nullable f fVar) {
        View view = this.f26325b;
        if (fVar == null) {
            this.revealInfo = null;
        } else {
            f fVar2 = this.revealInfo;
            if (fVar2 == null) {
                this.revealInfo = new f(fVar);
            } else {
                float f10 = fVar.f26331a;
                float f11 = fVar.f26332b;
                float f12 = fVar.f26333c;
                fVar2.f26331a = f10;
                fVar2.f26332b = f11;
                fVar2.f26333c = f12;
            }
            if (fVar.f26333c + 1.0E-4f >= c2.h(fVar.f26331a, fVar.f26332b, view.getWidth(), view.getHeight())) {
                this.revealInfo.f26333c = Float.MAX_VALUE;
            }
        }
        view.invalidate();
    }
}
