AdGuard v4.4.135版本的 MD5 值为:95950267eaafbda3588f0934f48b2e36
以下内容为反编译后的 ChartView.java 源代码,内容仅作参考
package com.adguard.kit.ui.view.chart;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import androidx.annotation.AttrRes;
import androidx.annotation.ColorInt;
import androidx.annotation.Px;
import androidx.annotation.StyleRes;
import androidx.core.app.NotificationCompat;
import ch.qos.logback.core.CoreConstants;
import ch.qos.logback.core.rolling.helper.IntegerTokenConverter;
import e8.j;
import java.util.ArrayList;
import java.util.List;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.jvm.internal.h;
import kotlin.jvm.internal.n;
import kotlin.jvm.internal.p;
import mc.l;
import o8.d;
import o8.e;
import o8.f;
import z6.b;
import z6.i;
@Metadata(d1 = {"\u0000l\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010!\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0010\u0007\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0005\u0018\u00002\u00020\u0001B1\b\u0007\u0012\u0006\u00109\u001a\u000208\u0012\n\b\u0002\u0010:\u001a\u0004\u0018\u00010\u000e\u0012\b\b\u0003\u0010\u0010\u001a\u00020\u0006\u0012\b\b\u0003\u0010\u0011\u001a\u00020\u0006¢\u0006\u0004\b;\u0010<J\u0012\u0010\u0005\u001a\u00020\u00042\b\u0010\u0003\u001a\u0004\u0018\u00010\u0002H\u0014J\u0018\u0010\t\u001a\u00020\u00042\u0006\u0010\u0007\u001a\u00020\u00062\u0006\u0010\b\u001a\u00020\u0006H\u0014J\u0012\u0010\r\u001a\u00020\f2\b\u0010\u000b\u001a\u0004\u0018\u00010\nH\u0016J&\u0010\u0012\u001a\u00020\u00042\b\u0010\u000f\u001a\u0004\u0018\u00010\u000e2\b\b\u0001\u0010\u0010\u001a\u00020\u00062\b\b\u0001\u0010\u0011\u001a\u00020\u0006H\u0002J\u0018\u0010\u0015\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010\u0014\u001a\u00020\u0013H\u0002J\u001e\u0010\u0019\u001a\u00020\u00042\f\u0010\u0018\u001a\b\u0012\u0004\u0012\u00020\u00170\u00162\u0006\u0010\u0014\u001a\u00020\u0013H\u0002J\u001e\u0010\u001a\u001a\u00020\u00042\f\u0010\u0018\u001a\b\u0012\u0004\u0012\u00020\u00170\u00162\u0006\u0010\u0014\u001a\u00020\u0013H\u0002R0\u0010\"\u001a\u0010\u0012\u0002\b\u0003\u0012\u0002\b\u0003\u0012\u0002\b\u0003\u0018\u00010\u001b8\u0006@\u0006X\u0086\u000e¢\u0006\u0012\n\u0004\b\u001c\u0010\u001d\u001a\u0004\b\u001e\u0010\u001f\"\u0004\b \u0010!R\u0016\u0010%\u001a\u00020#8\u0002@\u0002X\u0082.¢\u0006\u0006\n\u0004\b\u0019\u0010$R\u0016\u0010'\u001a\u00020\u00068\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\u0015\u0010&R\u0016\u0010(\u001a\u00020\u00068\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\u0012\u0010&R\u0016\u0010*\u001a\u00020\u00068\u0002@\u0002X\u0083\u000e¢\u0006\u0006\n\u0004\b)\u0010&R\u0016\u0010.\u001a\u00020+8\u0002@\u0002X\u0083\u000e¢\u0006\u0006\n\u0004\b,\u0010-R\u0016\u00100\u001a\u00020+8\u0002@\u0002X\u0083\u000e¢\u0006\u0006\n\u0004\b/\u0010-R\u0014\u00104\u001a\u0002018\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b2\u00103R\u0014\u00107\u001a\u00020\u00138\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b5\u00106¨\u0006="}, d2 = {"Lcom/adguard/kit/ui/view/chart/ChartView;", "Landroid/view/View;", "Landroid/graphics/Canvas;", "canvas", "", "onDraw", "", "widthMeasureSpec", "heightMeasureSpec", "onMeasure", "Landroid/view/MotionEvent;", NotificationCompat.CATEGORY_EVENT, "", "onTouchEvent", "Landroid/util/AttributeSet;", "set", "defStyleAttr", "defStyleRes", IntegerTokenConverter.CONVERTER_KEY, "Landroid/graphics/Rect;", "rect", "h", "", "Lo8/f;", "lines", "g", "f", "Lo8/d;", "e", "Lo8/d;", "getAdapter", "()Lo8/d;", "setAdapter", "(Lo8/d;)V", "adapter", "Landroid/graphics/Bitmap;", "Landroid/graphics/Bitmap;", "cachedGridBitmap", "I", "gridWidthCount", "gridHeightCount", "j", "gridColor", "", "k", "F", "gridStrokeWidth", "l", "gridCenterLinesVerticalOffset", "Landroid/graphics/Paint;", "m", "Landroid/graphics/Paint;", "gridPaint", "n", "Landroid/graphics/Rect;", "fullDrawingRect", "Landroid/content/Context;", CoreConstants.CONTEXT_SCOPE_VALUE, "attrs", "<init>", "(Landroid/content/Context;Landroid/util/AttributeSet;II)V", "kit-ui_release"}, k = 1, mv = {1, 8, 0})
public final class ChartView extends View {
public d<?, ?, ?> f12042e;
public Bitmap f12043g;
public int f12044h;
public int f12045i;
@ColorInt
public int f12046j;
@Px
public float f12047k;
@Px
public float f12048l;
public final Paint f12049m;
public final Rect f12050n;
@Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0010\u0002\n\u0002\b\u0002\u0010\u0002\u001a\u00020\u0001*\u00020\u0000H\n¢\u0006\u0004\b\u0002\u0010\u0003"}, d2 = {"Landroid/content/res/TypedArray;", "", "a", "(Landroid/content/res/TypedArray;)V"}, k = 3, mv = {1, 8, 0})
public static final class a extends p implements l<TypedArray, Unit> {
public a() {
super(1);
}
public final void a(TypedArray useStyledAttributes) {
n.g(useStyledAttributes, "$this$useStyledAttributes");
ChartView.this.f12044h = useStyledAttributes.getInt(i.G, 0);
ChartView.this.f12045i = useStyledAttributes.getInt(i.H, 0);
ChartView chartView = ChartView.this;
int i10 = i.J;
Context context = chartView.getContext();
n.f(context, "this@ChartView.context");
chartView.f12046j = j.a(useStyledAttributes, i10, context, 0);
ChartView.this.f12047k = useStyledAttributes.getDimension(i.K, 0.0f);
ChartView.this.f12048l = useStyledAttributes.getDimension(i.I, 0.0f);
}
@Override
public Unit invoke(TypedArray typedArray) {
a(typedArray);
return Unit.INSTANCE;
}
}
public ChartView(Context context, AttributeSet attributeSet) {
this(context, attributeSet, 0, 0, 12, null);
n.g(context, "context");
}
public ChartView(Context context, AttributeSet attributeSet, @AttrRes int i10, @StyleRes int i11) {
super(context, attributeSet, i10, i11);
n.g(context, "context");
i(attributeSet, i10, i11);
Paint paint = new Paint();
paint.setColor(this.f12046j);
paint.setStyle(Paint.Style.FILL);
paint.setStrokeWidth(this.f12047k);
this.f12049m = paint;
this.f12050n = new Rect();
}
public ChartView(Context context, AttributeSet attributeSet, int i10, int i11, int i12, h hVar) {
this(context, (i12 & 2) != 0 ? null : attributeSet, (i12 & 4) != 0 ? b.kit__chartView_style : i10, (i12 & 8) != 0 ? 0 : i11);
}
public final void f(List<f> list, Rect rect) {
int i10 = this.f12045i;
int i11 = 1;
if (i10 <= 1) {
return;
}
int i12 = i10 - 1;
int height = rect.height() / this.f12045i;
if (1 > i12) {
return;
}
while (true) {
int i13 = height * i11;
list.add(new f(new e(rect.left, rect.top + i13), new e(rect.right, rect.top + i13)));
if (i11 == i12) {
return;
}
i11++;
}
}
public final void g(List<f> list, Rect rect) {
int i10 = 1;
boolean z10 = true | true;
if (this.f12044h <= 1) {
return;
}
ArrayList arrayList = new ArrayList();
int i11 = this.f12044h;
if (i11 % 2 == 0) {
arrayList.add(Integer.valueOf(i11 / 2));
} else {
arrayList.add(Integer.valueOf(i11 / 2));
arrayList.add(Integer.valueOf((this.f12044h / 2) + 1));
}
int width = rect.width();
int i12 = this.f12044h;
int i13 = width / i12;
int i14 = i12 - 1;
if (1 <= i14) {
while (true) {
float f10 = arrayList.contains(Integer.valueOf(i10)) ? 0.0f : this.f12048l;
int i15 = i13 * i10;
list.add(new f(new e(i15, rect.top + f10), new e(i15, rect.bottom - f10)));
if (i10 == i14) {
break;
}
i10++;
}
}
}
public final d<?, ?, ?> getAdapter() {
return this.f12042e;
}
public final void h(Canvas canvas, Rect rect) {
Bitmap bitmap = this.f12043g;
int i10 = 0 << 0;
if (bitmap != null) {
if (bitmap == null) {
n.y("cachedGridBitmap");
bitmap = null;
}
canvas.drawBitmap(bitmap, 0.0f, 0.0f, (Paint) null);
return;
}
Bitmap createBitmap = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888);
n.f(createBitmap, "createBitmap(canvas.widt… Bitmap.Config.ARGB_8888)");
this.f12043g = createBitmap;
Bitmap bitmap2 = this.f12043g;
if (bitmap2 == null) {
n.y("cachedGridBitmap");
bitmap2 = null;
}
Canvas canvas2 = new Canvas(bitmap2);
ArrayList<f> arrayList = new ArrayList();
g(arrayList, rect);
f(arrayList, rect);
for (f fVar : arrayList) {
canvas2.drawLine(fVar.b().a().floatValue(), fVar.b().b().floatValue(), fVar.a().a().floatValue(), fVar.a().b().floatValue(), this.f12049m);
}
Bitmap bitmap3 = this.f12043g;
if (bitmap3 == null) {
n.y("cachedGridBitmap");
bitmap3 = null;
}
canvas.drawBitmap(bitmap3, 0.0f, 0.0f, (Paint) null);
}
public final void i(AttributeSet attributeSet, @AttrRes int i10, @StyleRes int i11) {
Context context = getContext();
n.f(context, "context");
int[] ChartView = i.F;
n.f(ChartView, "ChartView");
a6.i.c(context, attributeSet, ChartView, i10, i11, new a());
}
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (canvas != null && getVisibility() == 0 && canvas.getWidth() > 0 && canvas.getHeight() > 0) {
getDrawingRect(this.f12050n);
h(canvas, this.f12050n);
d<?, ?, ?> dVar = this.f12042e;
boolean z10 = false;
if (dVar != null && dVar.d(canvas, this.f12050n)) {
z10 = true;
}
if (z10) {
postInvalidateOnAnimation();
}
}
}
@Override
public void onMeasure(int i10, int i11) {
int mode = View.MeasureSpec.getMode(i11);
if (mode == Integer.MIN_VALUE || mode == 0) {
int size = View.MeasureSpec.getSize(i10);
setMeasuredDimension(size, (size / this.f12044h) * this.f12045i);
} else {
super.onMeasure(i10, i11);
}
}
@Override
public boolean onTouchEvent(MotionEvent motionEvent) {
d<?, ?, ?> dVar = this.f12042e;
boolean z10 = false;
if (dVar != null && dVar.j(motionEvent, getWidth())) {
z10 = true;
}
if (z10) {
invalidate();
return true;
}
return super.onTouchEvent(motionEvent);
}
public final void setAdapter(d<?, ?, ?> dVar) {
this.f12042e = dVar;
}
}