90 lines
2.5 KiB
Java
90 lines
2.5 KiB
Java
|
package c.o.a.r;
|
||
|
|
||
|
import android.content.Context;
|
||
|
import android.graphics.Canvas;
|
||
|
import android.graphics.Color;
|
||
|
import android.graphics.drawable.ColorDrawable;
|
||
|
import android.util.TypedValue;
|
||
|
import android.view.View;
|
||
|
import androidx.annotation.ColorInt;
|
||
|
import androidx.annotation.NonNull;
|
||
|
import c.o.a.m.g;
|
||
|
/* compiled from: GridLinesLayout */
|
||
|
public class d extends View {
|
||
|
public static final int i = Color.argb(160, 255, 255, 255);
|
||
|
public g j;
|
||
|
public int k = i;
|
||
|
public ColorDrawable l = new ColorDrawable(this.k);
|
||
|
public ColorDrawable m = new ColorDrawable(this.k);
|
||
|
public final float n;
|
||
|
|
||
|
public d(@NonNull Context context) {
|
||
|
super(context, null);
|
||
|
this.n = TypedValue.applyDimension(1, 0.9f, context.getResources().getDisplayMetrics());
|
||
|
}
|
||
|
|
||
|
private int getLineCount() {
|
||
|
int ordinal = this.j.ordinal();
|
||
|
if (ordinal == 1) {
|
||
|
return 2;
|
||
|
}
|
||
|
if (ordinal != 2) {
|
||
|
return ordinal != 3 ? 0 : 2;
|
||
|
}
|
||
|
return 3;
|
||
|
}
|
||
|
|
||
|
public int getGridColor() {
|
||
|
return this.k;
|
||
|
}
|
||
|
|
||
|
@NonNull
|
||
|
public g getGridMode() {
|
||
|
return this.j;
|
||
|
}
|
||
|
|
||
|
@Override // android.view.View
|
||
|
public void onDraw(@NonNull Canvas canvas) {
|
||
|
float f;
|
||
|
super.onDraw(canvas);
|
||
|
int lineCount = getLineCount();
|
||
|
for (int i2 = 0; i2 < lineCount; i2++) {
|
||
|
int lineCount2 = getLineCount();
|
||
|
if (this.j == g.DRAW_PHI) {
|
||
|
f = 0.38196602f;
|
||
|
if (i2 != 1) {
|
||
|
f = 0.618034f;
|
||
|
}
|
||
|
} else {
|
||
|
f = (1.0f / ((float) (lineCount2 + 1))) * (((float) i2) + 1.0f);
|
||
|
}
|
||
|
canvas.translate(0.0f, ((float) getHeight()) * f);
|
||
|
this.l.draw(canvas);
|
||
|
float f2 = -f;
|
||
|
canvas.translate(0.0f, ((float) getHeight()) * f2);
|
||
|
canvas.translate(f * ((float) getWidth()), 0.0f);
|
||
|
this.m.draw(canvas);
|
||
|
canvas.translate(f2 * ((float) getWidth()), 0.0f);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // android.view.View
|
||
|
public void onLayout(boolean z2, int i2, int i3, int i4, int i5) {
|
||
|
super.onLayout(z2, i2, i3, i4, i5);
|
||
|
this.l.setBounds(i2, 0, i4, (int) this.n);
|
||
|
this.m.setBounds(0, i3, (int) this.n, i5);
|
||
|
}
|
||
|
|
||
|
public void setGridColor(@ColorInt int i2) {
|
||
|
this.k = i2;
|
||
|
this.l.setColor(i2);
|
||
|
this.m.setColor(i2);
|
||
|
postInvalidate();
|
||
|
}
|
||
|
|
||
|
public void setGridMode(@NonNull g gVar) {
|
||
|
this.j = gVar;
|
||
|
postInvalidate();
|
||
|
}
|
||
|
}
|