Moving data sanitization to the end, as it need not block

the loading

Change-Id: If1a966e546127efafd0afd7e3ca771f63a1fa544
This commit is contained in:
Sunny Goyal
2020-08-04 17:28:46 -07:00
parent 60096e990a
commit 77ca1e4c40

View File

@@ -128,6 +128,8 @@ public class LoaderTask implements Runnable {
private boolean mStopped;
private boolean mItemsDeleted = false;
public LoaderTask(LauncherAppState app, AllAppsList bgAllAppsList, BgDataModel dataModel,
ModelDelegate modelDelegate, LoaderResults results) {
mApp = app;
@@ -271,6 +273,7 @@ public class LoaderTask implements Runnable {
if (FeatureFlags.FOLDER_NAME_SUGGEST.get()) {
loadFolderNames();
}
sanitizeData();
verifyNotStopped();
updateHandler.finish();
@@ -791,14 +794,9 @@ public class LoaderTask implements Runnable {
mBgDataModel.itemsIdMap.remove(folderId);
}
// Remove any ghost widgets
LauncherSettings.Settings.call(contentResolver,
LauncherSettings.Settings.METHOD_REMOVE_GHOST_WIDGETS);
mItemsDeleted = true;
}
// Update pinned state of model shortcuts
mBgDataModel.updateShortcutPinnedState(context);
// Sort the folder items, update ranks, and make sure all preview items are high res.
FolderGridOrganizer verifier =
new FolderGridOrganizer(mApp.getInvariantDeviceProfile());
@@ -872,6 +870,18 @@ public class LoaderTask implements Runnable {
}
}
private void sanitizeData() {
Context context = mApp.getContext();
if (mItemsDeleted) {
// Remove any ghost widgets
LauncherSettings.Settings.call(context.getContentResolver(),
LauncherSettings.Settings.METHOD_REMOVE_GHOST_WIDGETS);
}
// Update pinned state of model shortcuts
mBgDataModel.updateShortcutPinnedState(context);
}
private List<LauncherActivityInfo> loadAllApps() {
final List<UserHandle> profiles = mUserCache.getUserProfiles();
List<LauncherActivityInfo> allActivityList = new ArrayList<>();