discord-jadx/app/src/main/java/com/discord/utilities/view/rounded/RoundedCornerViewCoordinato...

105 lines
3.7 KiB
Java

package com.discord.utilities.view.rounded;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Path;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;
import androidx.annotation.StyleableRes;
import d0.z.d.m;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
/* compiled from: RoundedCornerViewCoordinator.kt */
public final class RoundedCornerViewCoordinator {
private float bottomLeftRadius;
private float bottomRightRadius;
private Path path = new Path();
private final float[] radii = new float[8];
private float topLeftRadius;
private float topRightRadius;
/* compiled from: RoundedCornerViewCoordinator.kt */
public enum Corner {
TOP_LEFT,
TOP_RIGHT,
BOTTOM_LEFT,
BOTTOM_RIGHT
}
public final /* synthetic */ class WhenMappings {
public static final /* synthetic */ int[] $EnumSwitchMapping$0;
static {
Corner.values();
int[] iArr = new int[4];
$EnumSwitchMapping$0 = iArr;
iArr[Corner.TOP_LEFT.ordinal()] = 1;
iArr[Corner.TOP_RIGHT.ordinal()] = 2;
iArr[Corner.BOTTOM_LEFT.ordinal()] = 3;
iArr[Corner.BOTTOM_RIGHT.ordinal()] = 4;
}
}
public final void draw(Canvas canvas, Function1<? super Canvas, Unit> function1) {
m.checkNotNullParameter(canvas, "canvas");
m.checkNotNullParameter(function1, "onDraw");
canvas.save();
canvas.clipPath(this.path);
function1.invoke(canvas);
canvas.restore();
}
public final void initialize(View view, AttributeSet attributeSet, @StyleableRes int[] iArr, @StyleableRes int i, @StyleableRes int i2, @StyleableRes int i3, @StyleableRes int i4) {
m.checkNotNullParameter(view, "view");
m.checkNotNullParameter(iArr, "attrsIndexArray");
view.setWillNotDraw(false);
TypedArray obtainStyledAttributes = view.getContext().obtainStyledAttributes(attributeSet, iArr);
m.checkNotNullExpressionValue(obtainStyledAttributes, "view.context.obtainStyle…s(attrs, attrsIndexArray)");
try {
this.topLeftRadius = obtainStyledAttributes.getDimension(i, 0.0f);
this.topRightRadius = obtainStyledAttributes.getDimension(i2, 0.0f);
this.bottomLeftRadius = obtainStyledAttributes.getDimension(i3, 0.0f);
this.bottomRightRadius = obtainStyledAttributes.getDimension(i4, 0.0f);
} finally {
obtainStyledAttributes.recycle();
}
}
public final void onSizeChanged(int i, int i2) {
Path path = new Path();
this.path = path;
float[] fArr = this.radii;
float f = this.topLeftRadius;
fArr[0] = f;
fArr[1] = f;
float f2 = this.topRightRadius;
fArr[2] = f2;
fArr[3] = f2;
float f3 = this.bottomRightRadius;
fArr[4] = f3;
fArr[5] = f3;
float f4 = this.bottomLeftRadius;
fArr[6] = f4;
fArr[7] = f4;
path.addRoundRect(new RectF(0.0f, 0.0f, (float) i, (float) i2), this.radii, Path.Direction.CW);
this.path.close();
}
public final void updateRadius(View view, float f, Corner corner) {
m.checkNotNullParameter(view, "view");
m.checkNotNullParameter(corner, "corner");
int ordinal = corner.ordinal();
if (ordinal == 0) {
this.topLeftRadius = f;
} else if (ordinal == 1) {
this.topRightRadius = f;
} else if (ordinal == 2) {
this.bottomLeftRadius = f;
} else if (ordinal == 3) {
this.bottomRightRadius = f;
}
view.invalidate();
}
}