Skip to content

Commit

Permalink
code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
woheller69 committed Nov 29, 2024
1 parent a76de0c commit dfc6887
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
11 changes: 6 additions & 5 deletions app/src/main/java/org/woheller69/weather/widget/RadarWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,12 @@ public static void updateView(Context context, AppWidgetManager appWidgetManager
paint.setStyle(Paint.Style.STROKE);
canvas.drawLine(10, 240, 10 + widthDistanceMarkerPixel, 240, paint);

canvas.drawCircle(128, 128, widthDistanceMarkerPixel, paint);
canvas.drawCircle(128, 128, 2 * widthDistanceMarkerPixel, paint);
canvas.drawCircle(128, 128, 3 * widthDistanceMarkerPixel, paint);
canvas.drawCircle(128, 128, 4 * widthDistanceMarkerPixel, paint);
canvas.drawCircle(128, 128, 5 * widthDistanceMarkerPixel, paint);
int maxI = 100 / widthDistanceMarkerPixel;
for (int i = 1; i <= maxI; i++) {
int radius = i * widthDistanceMarkerPixel;
canvas.drawCircle(128, 128, radius, paint);
}

paint.setStyle(Paint.Style.FILL);
canvas.drawCircle(128, 128, 2, paint);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,19 +384,20 @@ public static void updateView(Context context, AppWidgetManager appWidgetManager

paint.setStyle(Paint.Style.FILL);
paint.setTextAlign(Paint.Align.LEFT);
canvas.drawText(widthDistanceMarker + " " + distanceUnit, 5 + widthDistanceMarkerPixel + 5, 235 + 8, paint); // draw the text
canvas.drawText(widthDistanceMarker + " " + distanceUnit, 7 + widthDistanceMarkerPixel + 5, 238 + 8, paint); // draw the text

paint.setTextAlign(Paint.Align.RIGHT);
canvas.drawText(StringFormatUtils.formatTimeWithoutZone(context, radarTime), 250, 235 + 8, paint);
canvas.drawText(StringFormatUtils.formatTimeWithoutZone(context, radarTime), 248, 238 + 8, paint);

paint.setStyle(Paint.Style.STROKE);
canvas.drawLine(5, 235, 5 + widthDistanceMarkerPixel, 235, paint);
canvas.drawLine(7, 238, 7 + widthDistanceMarkerPixel, 238, paint);

int maxI = 100 / widthDistanceMarkerPixel;
for (int i = 1; i <= maxI; i++) {
int radius = i * widthDistanceMarkerPixel;
canvas.drawCircle(128, 128, radius, paint);
}

canvas.drawCircle(128, 128, widthDistanceMarkerPixel, paint);
canvas.drawCircle(128, 128, 2 * widthDistanceMarkerPixel, paint);
canvas.drawCircle(128, 128, 3 * widthDistanceMarkerPixel, paint);
canvas.drawCircle(128, 128, 4 * widthDistanceMarkerPixel, paint);
canvas.drawCircle(128, 128, 5 * widthDistanceMarkerPixel, paint);
paint.setStyle(Paint.Style.FILL);
canvas.drawCircle(128, 128, 2, paint);

Expand Down

0 comments on commit dfc6887

Please sign in to comment.