neiam
/gitgud
Git Gud
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Badges · Packages
⭐
1
Log in to mark this repository.
Android: stop the CI widget piling up circles on every redraw
c09893f · Gabriel Morell · 2026-09-28 00:40
Message
{commit_body(@commit)}
Files changed
modified
android/app/src/main/java/org/neiam/gitgud/app/widget/CiWidgetRenderer.kt
+16
−0
@@ -63,6 +63,22 @@ object CiWidgetRenderer {
| 63 | 63 | val slots = ((widthDp - PADDING_DP - 2 * CELL_DP) / CELL_DP).coerceAtLeast(1) |
| 64 | 64 | |
| 65 | 65 | val views = RemoteViews(context.packageName, R.layout.widget_ci) |
| 66 | + | |
| 67 | + // The launcher doesn't re-inflate an update with the same layout: | |
| 68 | + // it replays these actions onto the views it already has. So | |
| 69 | + // every render starts by undoing the last one — without this, | |
| 70 | + // addView appends to the previous circles and runs, and a widget | |
| 71 | + // redrawn every thirty seconds piles up thousands of views. | |
| 72 | + views.removeAllViews(R.id.widget_circles) | |
| 73 | + views.removeAllViews(R.id.widget_runs) | |
| 74 | + views.setViewVisibility(R.id.widget_circles, View.VISIBLE) | |
| 75 | + views.setViewVisibility(R.id.widget_prompt, View.GONE) | |
| 76 | + views.setViewVisibility(R.id.widget_body, View.GONE) | |
| 77 | + views.setViewVisibility(R.id.widget_message, View.GONE) | |
| 78 | + views.setTextViewText(R.id.widget_updated, "") | |
| 79 | + views.setInt(R.id.widget_logo, "setImageAlpha", 255) | |
| 80 | + views.setInt(R.id.widget_logo_cell, "setBackgroundResource", 0) | |
| 81 | + | |
| 66 | 82 | views.setInt(R.id.widget_bg, "setColorFilter", palette.bg) |
| 67 | 83 | views.setInt(R.id.widget_bg, "setImageAlpha", 240) |
| 68 | 84 | views.setInt(R.id.widget_refresh, "setColorFilter", palette.dim) |
Parents: 351bed2