Only load the first page in grid preview

Bug: 160662425
Test: manual (verified correctness)
Merged-In: I9dc3b7d7b84924ffb588470d4b6b20431a62b6cd
Change-Id: I9dc3b7d7b84924ffb588470d4b6b20431a62b6cd
(cherry picked from commit 312cf43863)
This commit is contained in:
Tracy Zhou
2020-08-03 12:07:50 -07:00
parent 3cdba9d5b5
commit e209b03a7f
2 changed files with 37 additions and 30 deletions
@@ -595,7 +595,10 @@ public class LauncherPreviewRenderer {
@Override
public WorkspaceResult call() throws Exception {
List<ShortcutInfo> allShortcuts = new ArrayList<>();
loadWorkspace(allShortcuts, LauncherSettings.Favorites.PREVIEW_CONTENT_URI);
loadWorkspace(allShortcuts, LauncherSettings.Favorites.PREVIEW_CONTENT_URI,
LauncherSettings.Favorites.SCREEN + " = 0 or "
+ LauncherSettings.Favorites.CONTAINER + " = "
+ LauncherSettings.Favorites.CONTAINER_HOTSEAT);
return new WorkspaceResult(mBgDataModel.workspaceItems, mBgDataModel.appWidgets,
mBgDataModel.cachedPredictedItems, null, mWidgetProvidersMap);
}
+33 -29
View File
@@ -293,10 +293,12 @@ public class LoaderTask implements Runnable {
}
private void loadWorkspace(List<ShortcutInfo> allDeepShortcuts) {
loadWorkspace(allDeepShortcuts, LauncherSettings.Favorites.CONTENT_URI);
loadWorkspace(allDeepShortcuts, LauncherSettings.Favorites.CONTENT_URI,
null /* selection */);
}
protected void loadWorkspace(List<ShortcutInfo> allDeepShortcuts, Uri contentUri) {
protected void loadWorkspace(List<ShortcutInfo> allDeepShortcuts, Uri contentUri,
String selection) {
final Context context = mApp.getContext();
final ContentResolver contentResolver = context.getContentResolver();
final PackageManagerHelper pmHelper = new PackageManagerHelper(context);
@@ -341,8 +343,8 @@ public class LoaderTask implements Runnable {
Map<ShortcutKey, ShortcutInfo> shortcutKeyToPinnedShortcuts = new HashMap<>();
final LoaderCursor c = new LoaderCursor(
contentResolver.query(contentUri, null, null, null, null), contentUri, mApp,
mUserManagerState);
contentResolver.query(contentUri, null, selection, null, null), contentUri,
mApp, mUserManagerState);
try {
final int appWidgetIdIndex = c.getColumnIndexOrThrow(
@@ -776,33 +778,35 @@ public class LoaderTask implements Runnable {
return;
}
// Remove dead items
if (c.commitDeleted()) {
// Remove any empty folder
int[] deletedFolderIds = LauncherSettings.Settings
.call(contentResolver,
LauncherSettings.Settings.METHOD_DELETE_EMPTY_FOLDERS)
.getIntArray(LauncherSettings.Settings.EXTRA_VALUE);
for (int folderId : deletedFolderIds) {
mBgDataModel.workspaceItems.remove(mBgDataModel.folders.get(folderId));
mBgDataModel.folders.remove(folderId);
mBgDataModel.itemsIdMap.remove(folderId);
if (contentUri == LauncherSettings.Favorites.CONTENT_URI) {
// Remove dead items
if (c.commitDeleted()) {
// Remove any empty folder
int[] deletedFolderIds = LauncherSettings.Settings
.call(contentResolver,
LauncherSettings.Settings.METHOD_DELETE_EMPTY_FOLDERS)
.getIntArray(LauncherSettings.Settings.EXTRA_VALUE);
for (int folderId : deletedFolderIds) {
mBgDataModel.workspaceItems.remove(mBgDataModel.folders.get(folderId));
mBgDataModel.folders.remove(folderId);
mBgDataModel.itemsIdMap.remove(folderId);
}
// Remove any ghost widgets
LauncherSettings.Settings.call(contentResolver,
LauncherSettings.Settings.METHOD_REMOVE_GHOST_WIDGETS);
}
// Remove any ghost widgets
LauncherSettings.Settings.call(contentResolver,
LauncherSettings.Settings.METHOD_REMOVE_GHOST_WIDGETS);
}
// Unpin shortcuts that don't exist on the workspace.
HashSet<ShortcutKey> pendingShortcuts =
InstallShortcutReceiver.getPendingShortcuts(context);
for (ShortcutKey key : shortcutKeyToPinnedShortcuts.keySet()) {
MutableInt numTimesPinned = mBgDataModel.pinnedShortcutCounts.get(key);
if ((numTimesPinned == null || numTimesPinned.value == 0)
&& !pendingShortcuts.contains(key)) {
// Shortcut is pinned but doesn't exist on the workspace; unpin it.
mBgDataModel.unpinShortcut(context, key);
// Unpin shortcuts that don't exist on the workspace.
HashSet<ShortcutKey> pendingShortcuts =
InstallShortcutReceiver.getPendingShortcuts(context);
for (ShortcutKey key : shortcutKeyToPinnedShortcuts.keySet()) {
MutableInt numTimesPinned = mBgDataModel.pinnedShortcutCounts.get(key);
if ((numTimesPinned == null || numTimesPinned.value == 0)
&& !pendingShortcuts.contains(key)) {
// Shortcut is pinned but doesn't exist on the workspace; unpin it.
mBgDataModel.unpinShortcut(context, key);
}
}
}