165 lines
6.2 KiB
Java
165 lines
6.2 KiB
Java
package com.discord.widgets.chat.list;
|
|
|
|
import android.content.Context;
|
|
import android.content.res.TypedArray;
|
|
import android.graphics.Canvas;
|
|
import android.graphics.Matrix;
|
|
import android.graphics.Paint;
|
|
import android.graphics.Path;
|
|
import android.graphics.RectF;
|
|
import android.util.AttributeSet;
|
|
import android.view.View;
|
|
import com.discord.R;
|
|
import com.discord.utilities.color.ColorCompat;
|
|
import com.discord.utilities.dimen.DimenUtils;
|
|
import d0.z.d.m;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
/* compiled from: ViewReplySpline.kt */
|
|
public final class ViewReplySpline extends View {
|
|
private static final int BOTTOM_TO_END = 0;
|
|
private static final int CAP_LONG = 1;
|
|
private static final int CAP_LONG_AND_SHORT = 0;
|
|
public static final Companion Companion = new Companion(null);
|
|
private static final int TOP_TO_END = 1;
|
|
private final float arcPercent;
|
|
private RectF arcRectLocal;
|
|
private int capStyle;
|
|
private final float endX;
|
|
private final float endY;
|
|
private final float halfStrokeWidth = 3.0f;
|
|
private int orientation;
|
|
private final Paint paint;
|
|
private final Path path = new Path();
|
|
private final RectF pathRect;
|
|
private RectF pathRectLocal;
|
|
private int spineEndPadding;
|
|
private int spineStartPadding;
|
|
private final float startX;
|
|
private final float startY;
|
|
private final float strokeWidth;
|
|
private Matrix transformMatrix;
|
|
|
|
/* compiled from: ViewReplySpline.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public ViewReplySpline(Context context, AttributeSet attributeSet) {
|
|
super(context, attributeSet);
|
|
m.checkNotNullParameter(context, "context");
|
|
Paint paint = new Paint();
|
|
this.paint = paint;
|
|
float f = 3.0f * ((float) 2);
|
|
this.strokeWidth = f;
|
|
this.arcPercent = 0.25f;
|
|
this.startY = 1.0f;
|
|
this.endX = 1.0f;
|
|
this.pathRect = new RectF(this.startX, this.endY, 1.0f, 1.0f);
|
|
this.pathRectLocal = new RectF();
|
|
this.arcRectLocal = new RectF();
|
|
this.transformMatrix = new Matrix();
|
|
paint.setStyle(Paint.Style.STROKE);
|
|
paint.setStrokeCap(Paint.Cap.ROUND);
|
|
paint.setStrokeWidth(f);
|
|
paint.setColor(ColorCompat.getThemedColor(this, 2130968892));
|
|
if (attributeSet != null) {
|
|
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R.a.ViewReplySpline, 0, 0);
|
|
m.checkNotNullExpressionValue(obtainStyledAttributes, "context.obtainStyledAttr…* defStyleRes */0\n )");
|
|
float dimension = obtainStyledAttributes.getDimension(3, 0.0f);
|
|
float dimension2 = obtainStyledAttributes.getDimension(1, 0.0f);
|
|
this.orientation = obtainStyledAttributes.getInteger(2, 0);
|
|
this.capStyle = obtainStyledAttributes.getInteger(0, 0);
|
|
float f2 = (float) 0;
|
|
if (dimension > f2) {
|
|
this.spineStartPadding = DimenUtils.dpToPixels(dimension);
|
|
}
|
|
if (dimension2 > f2) {
|
|
this.spineEndPadding = DimenUtils.dpToPixels(dimension2);
|
|
}
|
|
obtainStyledAttributes.recycle();
|
|
}
|
|
}
|
|
|
|
public final void createPath() {
|
|
this.path.reset();
|
|
int i = this.orientation;
|
|
if (i == 0) {
|
|
Path path = this.path;
|
|
RectF rectF = this.pathRectLocal;
|
|
path.moveTo(rectF.left, rectF.bottom + ((float) getLongPathOffset()));
|
|
this.path.arcTo(this.arcRectLocal, 180.0f, 90.0f, false);
|
|
Path path2 = this.path;
|
|
RectF rectF2 = this.pathRectLocal;
|
|
path2.lineTo(rectF2.right, rectF2.top);
|
|
} else if (i == 1) {
|
|
Path path3 = this.path;
|
|
RectF rectF3 = this.pathRectLocal;
|
|
path3.moveTo(rectF3.left, rectF3.top - ((float) getLongPathOffset()));
|
|
this.path.arcTo(this.arcRectLocal, 180.0f, -90.0f, false);
|
|
Path path4 = this.path;
|
|
RectF rectF4 = this.pathRectLocal;
|
|
path4.lineTo(rectF4.right, rectF4.bottom);
|
|
}
|
|
}
|
|
|
|
public final int getLongPathOffset() {
|
|
int i = this.capStyle;
|
|
if (i == 0) {
|
|
return 0;
|
|
}
|
|
if (i == 1) {
|
|
return DimenUtils.dpToPixels(1);
|
|
}
|
|
throw new IllegalStateException("Unknown cap style");
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void onDraw(Canvas canvas) {
|
|
super.onDraw(canvas);
|
|
if (canvas != null) {
|
|
canvas.drawPath(this.path, this.paint);
|
|
}
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void onSizeChanged(int i, int i2, int i3, int i4) {
|
|
RectF rectF;
|
|
super.onSizeChanged(i, i2, i3, i4);
|
|
if (i != i3 || i2 != i4) {
|
|
this.transformMatrix.reset();
|
|
Matrix matrix = this.transformMatrix;
|
|
float f = this.halfStrokeWidth;
|
|
matrix.preTranslate(f, f);
|
|
Matrix matrix2 = this.transformMatrix;
|
|
float f2 = this.strokeWidth;
|
|
matrix2.preScale((((float) i) - f2) - ((float) this.spineEndPadding), (((float) i2) - f2) - ((float) this.spineStartPadding));
|
|
this.transformMatrix.mapRect(this.pathRectLocal, this.pathRect);
|
|
float f3 = this.arcPercent;
|
|
RectF rectF2 = this.pathRectLocal;
|
|
float f4 = (rectF2.right - rectF2.left) * f3 * ((float) 2);
|
|
int i5 = this.orientation;
|
|
if (i5 == 0) {
|
|
RectF rectF3 = this.pathRectLocal;
|
|
float f5 = rectF3.left;
|
|
float f6 = rectF3.top;
|
|
rectF = new RectF(f5, f6, f5 + f4, f4 + f6);
|
|
} else if (i5 == 1) {
|
|
RectF rectF4 = this.pathRectLocal;
|
|
float f7 = rectF4.left;
|
|
float f8 = rectF4.bottom;
|
|
rectF = new RectF(f7, f8 - f4, f4 + f7, f8);
|
|
} else {
|
|
throw new IllegalStateException("Unknown orientation");
|
|
}
|
|
this.arcRectLocal = rectF;
|
|
createPath();
|
|
}
|
|
}
|
|
}
|