Skip to content

Widget with graphic trend arrow #4272

@JotaMyke

Description

@JotaMyke

in xDripWidget.java
line 169:
try {
float mDesvio = (float) (BestGlucose.getDisplayGlucose().slope * 600000 * 5);
if (mDesvio>90F)mDesvio=90F;
if (mDesvio<-90F)mDesvio=-90F;

                    views.setImageViewBitmap(R.id.trendArrowWG, rotateBitmap(getBitmap(R.drawable.ic_gtk_go_forward_ltr),
                            mDesvio*-1));
                } catch (Exception e) {
                    Log.e("xDripJMM", "ERRO Widget Image arrow=" + e);
                }

line 282 :
private static Bitmap getBitmap(int drawableRes) {
Drawable drawable = xdrip.getAppContext().getResources().getDrawable(drawableRes);
Canvas canvas = new Canvas();
Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
canvas.setBitmap(bitmap);
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
drawable.draw(canvas);
return bitmap;
}

private static Bitmap rotateBitmap(Bitmap source, float angle)
{
    Matrix matrix = new Matrix();
    matrix.postRotate(angle);
    //  source.recycle();
    return Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true);
}			

in x_drip_widget.xml

line 49 :

            <TextView
                android:id="@+id/widgetArrow"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_marginBottom="-5dp"
                android:layout_marginTop="-2dp"
                android:paddingBottom="-2dp"
                android:text="--"
                android:textColor="#ffffff"
                android:textSize="37sp" />

line81 :

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions