discord-jadx/app/src/main/java/com/discord/views/CutoutView.java

301 lines
10 KiB
Java

package com.discord.views;
import android.content.Context;
import android.content.res.Resources;
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 android.widget.FrameLayout;
import androidx.annotation.IntRange;
import androidx.annotation.Px;
import com.airbnb.lottie.parser.AnimatableValueParser;
import com.discord.R;
import com.discord.utilities.dimen.DimenUtils;
import d0.z.d.m;
/* compiled from: CutoutView.kt */
public class CutoutView extends FrameLayout {
public static final int i = DimenUtils.dpToPixels(14);
public static final int j = DimenUtils.dpToPixels(8);
public a k = a.d.a;
public boolean l = true;
public Path m;
public int n;
public int o;
/* compiled from: CutoutView.kt */
public interface a {
/* compiled from: CutoutView.kt */
/* renamed from: com.discord.views.CutoutView$a$a reason: collision with other inner class name */
public static final class C0181a implements a {
public final int a;
public final int b;
public C0181a() {
int i = CutoutView.i;
int i2 = CutoutView.j;
this.a = i;
this.b = i2;
}
public C0181a(@Px int i, @Px int i2) {
this.a = i;
this.b = i2;
}
public C0181a(int i, int i2, int i3) {
i = (i3 & 1) != 0 ? CutoutView.i : i;
i2 = (i3 & 2) != 0 ? CutoutView.j : i2;
this.a = i;
this.b = i2;
}
@Override // com.discord.views.CutoutView.a
public Path a(Context context, int i, int i2) {
m.checkNotNullParameter(context, "context");
Path path = new Path();
path.addRect(0.0f, 0.0f, (float) i, (float) i2, Path.Direction.CW);
Path path2 = new Path();
path2.addCircle(AnimatableValueParser.o1(context) ? (float) (i - this.b) : (float) this.b, (float) this.b, (float) this.a, Path.Direction.CW);
Path path3 = new Path(path);
path3.op(path2, Path.Op.DIFFERENCE);
return path3;
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof C0181a)) {
return false;
}
C0181a aVar = (C0181a) obj;
return this.a == aVar.a && this.b == aVar.b;
}
public int hashCode() {
return (this.a * 31) + this.b;
}
public String toString() {
StringBuilder L = c.d.b.a.a.L("CircularBadge(badgeRadius=");
L.append(this.a);
L.append(", inset=");
return c.d.b.a.a.z(L, this.b, ")");
}
}
/* compiled from: CutoutView.kt */
public static final class b implements a {
public final int a;
public final int b;
public b(@IntRange(from = 0) int i, @IntRange(from = 0) int i2) {
this.a = i;
this.b = i2;
}
@Override // com.discord.views.CutoutView.a
public Path a(Context context, int i, int i2) {
m.checkNotNullParameter(context, "context");
float f = (float) i;
int i3 = this.a;
float f2 = ((float) i3) - (f / 2.0f);
float f3 = ((float) i3) * 2.0f;
float f4 = -f2;
float f5 = ((float) i2) + f2;
if (AnimatableValueParser.o1(context)) {
float f6 = f - ((float) this.b);
RectF rectF = new RectF(f6, f4, f3 + f6, f5);
Path path = new Path();
path.moveTo(f4, f4);
path.arcTo(rectF, 270.0f, -180.0f);
path.lineTo(f4, f5);
path.close();
return path;
}
float f7 = (float) this.b;
RectF rectF2 = new RectF(f7 - f3, f4, f7, f5);
Path path2 = new Path();
float f8 = f + f2;
path2.moveTo(f8, f4);
path2.arcTo(rectF2, 270.0f, 180.0f);
path2.lineTo(f8, f5);
path2.close();
return path2;
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof b)) {
return false;
}
b bVar = (b) obj;
return this.a == bVar.a && this.b == bVar.b;
}
public int hashCode() {
return (this.a * 31) + this.b;
}
public String toString() {
StringBuilder L = c.d.b.a.a.L("End(cutCurveRadiusPx=");
L.append(this.a);
L.append(", cutDistanceInwardFromEdgePx=");
return c.d.b.a.a.z(L, this.b, ")");
}
}
/* compiled from: CutoutView.kt */
public static final class c implements a {
public final int a;
public c(int i) {
this.a = i;
}
@Override // com.discord.views.CutoutView.a
public Path a(Context context, int i, int i2) {
m.checkNotNullParameter(context, "context");
Resources resources = context.getResources();
m.checkNotNullExpressionValue(resources, "context.resources");
float f = ((float) this.a) * resources.getDisplayMetrics().density;
float f2 = (float) i2;
float f3 = f2 / 2.0f;
if (AnimatableValueParser.o1(context)) {
Path path = new Path();
float f4 = ((float) i) + f;
path.moveTo(0.0f, 0.0f);
path.lineTo(f4, 0.0f);
path.arcTo(new RectF(f4 - f3, 0.0f, f4 + f3, f2), 270.0f, -180.0f);
path.lineTo(0.0f, f2);
path.lineTo(0.0f, 0.0f);
return path;
}
Path path2 = new Path();
float f5 = -f;
float f6 = (float) i;
path2.moveTo(f6, 0.0f);
path2.lineTo(f5, 0.0f);
path2.arcTo(new RectF(f5 - f3, 0.0f, f5 + f3, f2), 270.0f, 180.0f);
path2.lineTo(f6, f2);
path2.lineTo(f6, 0.0f);
return path2;
}
public boolean equals(Object obj) {
if (this != obj) {
return (obj instanceof c) && this.a == ((c) obj).a;
}
return true;
}
public int hashCode() {
return this.a;
}
public String toString() {
return c.d.b.a.a.z(c.d.b.a.a.L("EndOverlap(offsetDp="), this.a, ")");
}
}
/* compiled from: CutoutView.kt */
public static final class d implements a {
public static final d a = new d();
@Override // com.discord.views.CutoutView.a
public Path a(Context context, int i, int i2) {
m.checkNotNullParameter(context, "context");
return null;
}
}
Path a(Context context, int i, int i2);
}
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public CutoutView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
m.checkNotNullParameter(context, "context");
setWillNotDraw(false);
int[] iArr = R.a.CutoutView;
m.checkNotNullExpressionValue(iArr, "R.styleable.CutoutView");
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, iArr);
m.checkNotNullExpressionValue(obtainStyledAttributes, "obtainStyledAttributes(attrs, styleable)");
if (obtainStyledAttributes.getInt(2, 0) == 1) {
setStyle(new a.C0181a(obtainStyledAttributes.getDimensionPixelSize(1, i), obtainStyledAttributes.getDimensionPixelSize(0, j)));
}
obtainStyledAttributes.recycle();
}
@Override // android.view.View
public void draw(Canvas canvas) {
Path path;
m.checkNotNullParameter(canvas, "canvas");
int save = canvas.save();
try {
if (this.l && (path = this.m) != null) {
canvas.clipPath(path);
}
super.draw(canvas);
} finally {
canvas.restoreToCount(save);
}
}
public final a getStyle() {
return this.k;
}
@Override // android.view.View
public void onFinishInflate() {
super.onFinishInflate();
if (isInEditMode()) {
if (getChildCount() == 0) {
View view = new View(getContext());
view.setBackgroundColor((int) 4278255360L);
addView(view);
setStyle(new a.C0181a(0, 0, 3));
}
}
}
@Override // android.widget.FrameLayout, android.view.View
public void onMeasure(int i2, int i3) {
super.onMeasure(i2, i3);
int measuredWidth = getMeasuredWidth();
int measuredHeight = getMeasuredHeight();
if (measuredWidth != this.n || measuredHeight != this.o || this.m == null) {
this.n = measuredWidth;
this.o = measuredHeight;
a aVar = this.k;
Context context = getContext();
m.checkNotNullExpressionValue(context, "context");
this.m = aVar.a(context, measuredWidth, measuredHeight);
}
}
public final void setCutoutEnabled(boolean z2) {
if (this.l != z2) {
this.l = z2;
invalidate();
}
}
public final void setStyle(a aVar) {
m.checkNotNullParameter(aVar, "value");
this.k = aVar;
if (this.n > 0 && this.o > 0) {
Context context = getContext();
m.checkNotNullExpressionValue(context, "context");
this.m = aVar.a(context, this.n, this.o);
invalidate();
}
}
}