Greetings, thanks in advance, how could I make a Custom View Wrapper from this code.
B4X:
package base.app.app;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.content.Context;
import android.graphics.Rect;
import android.graphics.Paint;
public class TiempoWidget extends LayoutWidget
{
public Paint redPaint;
public Paint greenPaint;
public Paint yellowPaint;
public TiempoWidget(final Context context) {
this(context, null, 0);
}
public TiempoWidget(final Context context, final AttributeSet set) {
this(context, set, 0);
}
public TiempoWidget(final Context context, final AttributeSet set, final int n) {
super(context, set, n);
this.bluePercentage = 0.0f;
this.redPercentage = 0.0f;
}
public void initPaint() {
(this.redPaint = new Paint()).setColor(-65536);
this.redPaint.setStyle(Paint.Style.STROKE);
this.redPaint.setStrokeCap(Paint.Cap.SQUARE);
(this.greenPaint = new Paint()).setColor(-16711936);
this.greenPaint.setStyle(Paint.Style.STROKE);
}
public String getvolarFormatString(final int n, final boolean b) {
if (!b) {
return "--:--";
}
if (n == 0) {
return this.volarText;
}
final int[] formatSecondToHourAr;
String s;
if ((formatSecondToHourAr = baseCalculationUtil.formatSecondToHourAr(n))[2] > 0) {
final Context context = this.getContext();
final int _hours_mins_secs = R.string._hours_mins_secs;
final Object[] array2;
final Object[] array = array2 = new Object[3];
final int[] array3 = formatSecondToHourAr;
final Object[] array4 = array2;
final int[] array5 = formatSecondToHourAr;
array2[0] = formatSecondToHourAr[2];
array4[1] = array5[1];
array[2] = array3[0];
s = context.getString(_hours_mins_secs, array);
}
else {
final Context context2 = this.getContext();
final int _mins_secs = R.string._mins_secs;
final Object[] array6 = new Object[2];
final int[] array7 = formatSecondToHourAr;
array6[0] = formatSecondToHourAr[1];
array6[1] = array7[0];
s = context2.getString(_mins_secs, array6);
}
return s;
}
static {
disponible__Yave = (baseYave)volar.create(volar.disponible_);
}
@Override
public void initView(final Context context, final AttributeSet set, final int n) {
this.initPaint();
}
@Override
public BaseWidgetAppearances getWidgetAppearances() {
return null;
}
@Override
public void initYave() {
this.addDependentYave(disponible__Yave);
}
public synchronized void onDraw(final Canvas canvas) {
if (this.viewHeight == 0.0f) {
this.viewHeight = (float)this.getHeight();
final float viewHeight;
this.usableViewWidth = this.getWidth() - (viewHeight = this.viewHeight) / 2.0f;
this.blueDotPaint.setStrokeWidth(this.viewHeight / 2.4f);
this.redPaint.setStrokeWidth(viewHeight / 6.0f);
this.greenPaint.setStrokeWidth(this.viewHeight / 6.0f);
this.yellowPaint.setStrokeWidth(this.viewHeight / 6.0f);
}
else if (this.isConnected) {
final float min = Math.min(100.0f, Math.max(0.0f, this.redPercentage));
this.redPercentage = min;
final float min2 = Math.min(100.0f, Math.max(min, this.yellowPercentage));
this.yellowPercentage = min2;
final float min3 = Math.min(100.0f, Math.max(min2, this.greenPercentage));
final float n = this.greenPercentage = min3;
final float n2 = this.viewHeight / 2.0f;
canvas.drawLine(0.0f, n2, n4, n2, this.redPaint);
canvas.drawLine(n4, n2, n8, n2, this.yellowPaint);
canvas.drawLine(n8, n2, n7 + n9, n2, this.greenPaint);
final float whiteDot1Percentage;
if ((whiteDot1Percentage = this.whiteDot1Percentage) <= this.greenPercentage) {
canvas.drawPoint(this.usableViewWidth * whiteDot1Percentage / 100.0f, n2, this.whiteDotPaint);
}
canvas.drawLine(usableViewWidth2 * greenPercentage / 100.0f - measureText, n2, usableViewWidth2 * greenPercentage / 100.0f, n2, this.volarRoundedWhiteBackgroundPaint);
canvas.drawText(this.volarText, this.usableViewWidth * this.greenPercentage / 100.0f - measureText, n11 + this.volarTextBounds.height() / 2.0f, this.volarTextPaint);
}
}
@Override
public void transformValue(final Object o, final baseYave baseYave) {
if (true)) {
final Integer n;
if ((n = (Integer)o) != this.greenPercentage) {
final Integer n2 = n;
this.shouldRedraw = true;
this.greenPercentage = n2;
}
}
else if (baseYave.equals((Object)TiempoWidget)) {
this.isFlying = (boolean)o;
}
}
@Override
public void update() {
if (this.shouldRedraw) {
this.shouldRedraw = false;
this.invalidate();
}
}
@Override
public void destroy() {
super.destroy();
}
}