jimu-decompiled/sources/com/ubt/jimu/controller/component/GridView.java
2025-05-13 19:24:51 +02:00

80 lines
2.0 KiB
Java

package com.ubt.jimu.controller.component;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import com.ubt.jimu.R;
import com.ubt.jimu.controller.util.ScreenUtil;
/* loaded from: classes.dex */
public class GridView extends View {
private float a;
private Context b;
private int c;
private int d;
private float e;
private int f;
private int g;
private Paint h;
public GridView(Context context) {
super(context);
this.a = 5.0f;
this.b = context;
b();
a();
}
private void a() {
this.c = ScreenUtil.a(this.b);
this.d = ScreenUtil.b(this.b);
this.e = this.b.getResources().getDimension(R.dimen.grid_view_width);
float f = this.d;
float f2 = this.e;
this.f = (int) (f / f2);
this.g = (int) (this.c / f2);
Log.e("Test", "mScreenWidth:" + this.c + " mScreenHeight:" + this.d + " rowNum:" + this.f + " lengthwaysNum:" + this.g);
this.h = new Paint();
this.h.setAntiAlias(true);
this.h.setColor(this.b.getResources().getColor(R.color.bg_BCEAFF));
this.h.setStrokeWidth(this.a);
}
private void b() {
}
public int getColumnNum() {
return this.g;
}
public int getRowNum() {
return this.f;
}
@Override // android.view.View
protected void onDraw(Canvas canvas) {
float f = this.e;
float f2 = f;
for (int i = 0; i < this.f; i++) {
canvas.drawLine(0.0f, f2, this.c, f2, this.h);
f2 += this.e;
}
for (int i2 = 0; i2 < this.g; i2++) {
canvas.drawLine(f, 0.0f, f, this.d, this.h);
f += this.e;
}
super.onDraw(canvas);
}
public GridView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
this.a = 5.0f;
this.b = context;
b();
a();
}
}