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 8c8c95c7581005f686da5734d5d9dd278c327cf8..d82d51e46ed02719cd1ab88f16d24d96b9985e74 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 @@ -71,6 +71,7 @@ import org.greenrobot.eventbus.ThreadMode; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.Calendar; import java.util.Comparator; import java.util.HashSet; @@ -1318,7 +1319,9 @@ public class LauncherActivity extends AppCompatActivity implements } // [[END]] - for (int id : mAppWidgetHost.getAppWidgetIds()) { + int[] widgetIds = mAppWidgetHost.getAppWidgetIds(); + Arrays.sort(widgetIds); + for (int id : widgetIds) { AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(id); if(appWidgetInfo != null){ RoundedWidgetView hostView = (RoundedWidgetView) mAppWidgetHost.createView( diff --git a/app/src/main/java/foundation/e/blisslauncher/features/widgets/WidgetManager.java b/app/src/main/java/foundation/e/blisslauncher/features/widgets/WidgetManager.java index 8e4fb017ad03ee1116bbc871d8f51fd87c7d0412..27385e374cee8bdb32872bf0a5d02f1db59ed663 100644 --- a/app/src/main/java/foundation/e/blisslauncher/features/widgets/WidgetManager.java +++ b/app/src/main/java/foundation/e/blisslauncher/features/widgets/WidgetManager.java @@ -1,5 +1,6 @@ package foundation.e.blisslauncher.features.widgets; +import java.util.Iterator; import java.util.LinkedList; import java.util.Queue; @@ -19,6 +20,14 @@ public class WidgetManager { } public void enqueueRemoveId(int id){ + // If the widget is not yet created but scheduled to be created we have to prevent the creation, too. + Iterator it = addWidgetViews.iterator(); + while(it.hasNext()){ + RoundedWidgetView view = it.next(); + if(id == view.getAppWidgetId()){ + addWidgetViews.remove(view); + } + } removeWidgetIds.add(id); } diff --git a/app/src/main/java/foundation/e/blisslauncher/features/widgets/WidgetsActivity.java b/app/src/main/java/foundation/e/blisslauncher/features/widgets/WidgetsActivity.java index ea1e6889534bb69a82d867157183d375470684d3..9de4de301816686e039d54c446e59c2f60a8f9f2 100644 --- a/app/src/main/java/foundation/e/blisslauncher/features/widgets/WidgetsActivity.java +++ b/app/src/main/java/foundation/e/blisslauncher/features/widgets/WidgetsActivity.java @@ -14,6 +14,7 @@ import foundation.e.blisslauncher.core.customviews.RoundedWidgetView; import foundation.e.blisslauncher.core.customviews.WidgetHost; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import foundation.e.blisslauncher.BlissLauncher; @@ -60,7 +61,9 @@ public class WidgetsActivity extends Activity implements AddedWidgetsAdapter.OnA private void refreshRecyclerView() { List widgets = new ArrayList<>(); - for (int id : mAppWidgetHost.getAppWidgetIds()) { + int[] widgetIds = mAppWidgetHost.getAppWidgetIds(); + Arrays.sort(widgetIds); + for (int id : widgetIds) { AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(id); if (appWidgetInfo != null) { Widget widget = new Widget();