[Android] Widgets: fix color flickering when resizing a pelette widget

Nicolas Pomepuy git at videolan.org
Wed May 18 09:57:59 UTC 2022


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Thu May 12 13:15:03 2022 +0200| [2fa2238a234d3c0b69fd0a4ec2ca85655987b399] | committer: Duncan McNamara

Widgets: fix color flickering when resizing a pelette widget

> https://code.videolan.org/videolan/vlc-android/commit/2fa2238a234d3c0b69fd0a4ec2ca85655987b399
---

 .../vlc-android/src/org/videolan/vlc/repository/WidgetRepository.kt   | 4 ++--
 .../src/org/videolan/vlc/widget/MiniPlayerAppWidgetProvider.kt        | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/repository/WidgetRepository.kt b/application/vlc-android/src/org/videolan/vlc/repository/WidgetRepository.kt
index a92a6c583..276fcb3e6 100644
--- a/application/vlc-android/src/org/videolan/vlc/repository/WidgetRepository.kt
+++ b/application/vlc-android/src/org/videolan/vlc/repository/WidgetRepository.kt
@@ -55,8 +55,8 @@ class WidgetRepository(private val widgetDao: WidgetDao) {
         widgetDao.insert(widget)
     }
 
-    suspend fun updateWidget(widget:Widget) {
-        WidgetCache.clear(widget)
+    suspend fun updateWidget(widget:Widget, preventCacheClear:Boolean = false) {
+        if (!preventCacheClear) WidgetCache.clear(widget)
         withContext(Dispatchers.IO) {
             widgetDao.update(widget)
         }
diff --git a/application/vlc-android/src/org/videolan/vlc/widget/MiniPlayerAppWidgetProvider.kt b/application/vlc-android/src/org/videolan/vlc/widget/MiniPlayerAppWidgetProvider.kt
index 6da69313f..2c99eb618 100644
--- a/application/vlc-android/src/org/videolan/vlc/widget/MiniPlayerAppWidgetProvider.kt
+++ b/application/vlc-android/src/org/videolan/vlc/widget/MiniPlayerAppWidgetProvider.kt
@@ -177,7 +177,7 @@ class MiniPlayerAppWidgetProvider : AppWidgetProvider() {
             widgetCacheEntry.currentCoverInvalidated = true
             log(appWidgetId, WidgetLogType.INFO, "Updating widget entry to: $widgetCacheEntry.widget")
 
-            widgetRepository.updateWidget(widgetCacheEntry.widget)
+            widgetRepository.updateWidget(widgetCacheEntry.widget, true)
         }
         val correctedSize = if (size.first == 0 && size.second == 0) {
             log(appWidgetId, WidgetLogType.INFO, "Size is 0. Getting size from db: $widgetCacheEntry.widget")
@@ -232,7 +232,7 @@ class MiniPlayerAppWidgetProvider : AppWidgetProvider() {
 
         if (colorChanged) {
             if (widgetType == WidgetType.MACRO) views.setImageViewBitmap(R.id.cover_background, context.getColoredBitmapFromColor(R.drawable.widget_rectangle_background, widgetCacheEntry.widget.getBackgroundColor(context, palette), widgetCacheEntry.widget.width.dp,  widgetCacheEntry.widget.width.dp))
-            log(appWidgetId, WidgetLogType.BITMAP_GENERATION, "Bugfix Color changed!!! for widget $appWidgetId // forPreview $forPreview")
+            log(appWidgetId, WidgetLogType.BITMAP_GENERATION, "Bugfix Color changed!!! for widget $appWidgetId // forPreview $forPreview // foreground color: ${java.lang.String.format("#%06X", 0xFFFFFF and foregroundColor)} /// palette ${widgetCacheEntry.palette}")
             if (android.text.TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()) == View.LAYOUT_DIRECTION_RTL) {
                 views.setImageViewBitmap(R.id.forward, context.getColoredBitmapFromColor(R.drawable.ic_widget_previous_normal, foregroundColor))
                 views.setImageViewBitmap(R.id.backward, context.getColoredBitmapFromColor(R.drawable.ic_widget_next_normal, foregroundColor))



More information about the Android mailing list