mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-02 17:06:49 +00:00
Improve Hybird hotseat cache support
Loads list of cached apps and shows predicted app icons with the rest of workspace items. -> Extracted prediction caching logic into a model layer Bug: 155029837 Test: Manual Change-Id: I6981594a910f5fe4e8e8cf8fe39db0cb856e7acd
This commit is contained in:
@@ -179,6 +179,7 @@ public class LoaderTask implements Runnable {
|
||||
try (LauncherModel.LoaderTransaction transaction = mApp.getModel().beginLoader(this)) {
|
||||
List<ShortcutInfo> allShortcuts = new ArrayList<>();
|
||||
loadWorkspace(allShortcuts);
|
||||
loadCachedPredictions();
|
||||
logger.addSplit("loadWorkspace");
|
||||
|
||||
verifyNotStopped();
|
||||
@@ -849,6 +850,23 @@ public class LoaderTask implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
private List<AppInfo> loadCachedPredictions() {
|
||||
List<ComponentKey> componentKeys = mApp.getPredictionModel().getPredictionComponentKeys();
|
||||
List<AppInfo> results = new ArrayList<>();
|
||||
if (componentKeys == null) return results;
|
||||
List<LauncherActivityInfo> l;
|
||||
mBgDataModel.cachedPredictedItems.clear();
|
||||
for (ComponentKey key : componentKeys) {
|
||||
l = mLauncherApps.getActivityList(key.componentName.getPackageName(), key.user);
|
||||
if (l.size() == 0) continue;
|
||||
boolean quietMode = mUserManager.isQuietModeEnabled(key.user);
|
||||
AppInfo info = new AppInfo(l.get(0), key.user, quietMode);
|
||||
mBgDataModel.cachedPredictedItems.add(info);
|
||||
mIconCache.getTitleAndIcon(info, false);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
private List<LauncherActivityInfo> loadAllApps() {
|
||||
final List<UserHandle> profiles = mUserCache.getUserProfiles();
|
||||
List<LauncherActivityInfo> allActivityList = new ArrayList<>();
|
||||
@@ -880,6 +898,14 @@ public class LoaderTask implements Runnable {
|
||||
PackageInstallInfo.fromInstallingState(info));
|
||||
}
|
||||
}
|
||||
for (AppInfo item : mBgDataModel.cachedPredictedItems) {
|
||||
List<LauncherActivityInfo> l = mLauncherApps.getActivityList(
|
||||
item.componentName.getPackageName(), item.user);
|
||||
for (LauncherActivityInfo info : l) {
|
||||
boolean quietMode = mUserManager.isQuietModeEnabled(item.user);
|
||||
mBgAllAppsList.add(new AppInfo(info, item.user, quietMode), info);
|
||||
}
|
||||
}
|
||||
|
||||
mBgAllAppsList.getAndResetChangeFlag();
|
||||
return allActivityList;
|
||||
|
||||
Reference in New Issue
Block a user