From 0d12b4ea3e98f951053afb8089cb61a83de4001f Mon Sep 17 00:00:00 2001 From: Yash Garg Date: Thu, 10 Nov 2022 20:22:22 +0530 Subject: [PATCH] fix: remove all views and re bind the widgets when AppRemoveEvent is received --- .../features/launcher/LauncherActivity.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java b/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java index 14b7a12517..1462e8adfb 100755 --- a/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java +++ b/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java @@ -629,6 +629,7 @@ public class LauncherActivity extends AppCompatActivity forceRefreshSuggestedApps = true; removePackageFromLauncher(appRemoveEvent.getPackageName(), appRemoveEvent.getUserHandle()); DatabaseManager.getManager(this).saveLayouts(pages, mDock); + rebindAllWidgets(); } public void onAppChangeEvent(AppChangeEvent appChangeEvent) { @@ -1468,12 +1469,23 @@ public class LauncherActivity extends AppCompatActivity } // [[END]] + rebindWidgetHost(); + } + + private void rebindWidgetHost() { int[] widgetIds = mAppWidgetHost.getAppWidgetIds(); getCompositeDisposable().add(DatabaseManager.getManager(this).getWidgets(widgetIds) .subscribeOn(Schedulers.from(AppExecutors.getInstance().diskIO())) .observeOn(AndroidSchedulers.mainThread()).subscribe(this::bindWidgets)); } + public void rebindAllWidgets() { + if (widgetsPage != null) { + widgetContainer.removeAllViewsInLayout(); + rebindWidgetHost(); + } + } + private void bindWidgets(List widgets) { for (WidgetItem widget : widgets) { AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(widget.id); -- GitLab