117 lines
4.4 KiB
Java
117 lines
4.4 KiB
Java
package com.discord.utilities.spans;
|
|
|
|
import android.annotation.SuppressLint;
|
|
import android.graphics.Canvas;
|
|
import android.graphics.Paint;
|
|
import android.graphics.Path;
|
|
import android.text.Layout;
|
|
import android.text.Spanned;
|
|
import android.text.style.LeadingMarginSpan;
|
|
import androidx.core.app.NotificationCompat;
|
|
import d0.z.d.m;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
/* compiled from: BulletSpan.kt */
|
|
public final class BulletSpan implements LeadingMarginSpan {
|
|
public static final Companion Companion = new Companion(null);
|
|
private static final int STANDARD_BULLET_RADIUS = 4;
|
|
private static final int STANDARD_GAP_WIDTH = 2;
|
|
private static Path sBulletPath;
|
|
private final int mBulletRadius;
|
|
private final int mColor;
|
|
private final int mGapWidth;
|
|
private final boolean mWantColor;
|
|
|
|
/* compiled from: BulletSpan.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public final int getSTANDARD_BULLET_RADIUS() {
|
|
return BulletSpan.access$getSTANDARD_BULLET_RADIUS$cp();
|
|
}
|
|
|
|
public final int getSTANDARD_GAP_WIDTH() {
|
|
return BulletSpan.access$getSTANDARD_GAP_WIDTH$cp();
|
|
}
|
|
}
|
|
|
|
public BulletSpan(int i, int i2) {
|
|
this.mGapWidth = i;
|
|
this.mBulletRadius = i2;
|
|
this.mWantColor = false;
|
|
this.mColor = 0;
|
|
}
|
|
|
|
public BulletSpan(int i, int i2, int i3) {
|
|
this.mGapWidth = i;
|
|
this.mBulletRadius = i3;
|
|
this.mWantColor = true;
|
|
this.mColor = i2;
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public /* synthetic */ BulletSpan(int i, int i2, int i3, int i4, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(i, i2, (i4 & 4) != 0 ? STANDARD_BULLET_RADIUS : i3);
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public /* synthetic */ BulletSpan(int i, int i2, int i3, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this((i3 & 1) != 0 ? STANDARD_GAP_WIDTH : i, (i3 & 2) != 0 ? STANDARD_BULLET_RADIUS : i2);
|
|
}
|
|
|
|
public static final /* synthetic */ int access$getSTANDARD_BULLET_RADIUS$cp() {
|
|
return STANDARD_BULLET_RADIUS;
|
|
}
|
|
|
|
public static final /* synthetic */ int access$getSTANDARD_GAP_WIDTH$cp() {
|
|
return STANDARD_GAP_WIDTH;
|
|
}
|
|
|
|
@Override // android.text.style.LeadingMarginSpan
|
|
@SuppressLint({"NewApi"})
|
|
public void drawLeadingMargin(Canvas canvas, Paint paint, int i, int i2, int i3, int i4, int i5, CharSequence charSequence, int i6, int i7, boolean z2, Layout layout) {
|
|
m.checkNotNullParameter(canvas, "c");
|
|
m.checkNotNullParameter(paint, "p");
|
|
m.checkNotNullParameter(charSequence, NotificationCompat.MessagingStyle.Message.KEY_TEXT);
|
|
m.checkNotNullParameter(layout, "l");
|
|
if (((Spanned) charSequence).getSpanStart(this) == i6) {
|
|
Paint.Style style = paint.getStyle();
|
|
int i8 = 0;
|
|
if (this.mWantColor) {
|
|
i8 = paint.getColor();
|
|
paint.setColor(this.mColor);
|
|
}
|
|
paint.setStyle(Paint.Style.FILL);
|
|
if (canvas.isHardwareAccelerated()) {
|
|
if (sBulletPath == null) {
|
|
Path path = new Path();
|
|
sBulletPath = path;
|
|
m.checkNotNull(path);
|
|
path.addCircle(0.0f, 0.0f, ((float) this.mBulletRadius) * 1.2f, Path.Direction.CW);
|
|
}
|
|
canvas.save();
|
|
canvas.translate((((float) i2) * 1.2f * ((float) this.mBulletRadius)) + ((float) i), ((float) (i3 + i5)) / 2.0f);
|
|
Path path2 = sBulletPath;
|
|
m.checkNotNull(path2);
|
|
canvas.drawPath(path2, paint);
|
|
canvas.restore();
|
|
} else {
|
|
int i9 = this.mBulletRadius;
|
|
canvas.drawCircle((float) ((i2 * i9) + i), ((float) (i3 + i5)) / 2.0f, (float) i9, paint);
|
|
}
|
|
if (this.mWantColor) {
|
|
paint.setColor(i8);
|
|
}
|
|
paint.setStyle(style);
|
|
}
|
|
}
|
|
|
|
@Override // android.text.style.LeadingMarginSpan
|
|
public int getLeadingMargin(boolean z2) {
|
|
return (this.mBulletRadius * 2) + this.mGapWidth;
|
|
}
|
|
}
|