Unifying various model update callbacks into one
Making the BubbleTextView.applyItem stateless so that it does not depend on the order of events
Bug: 390572144
Flag: EXEMPT refactor
Test: atest LauncherBindableItemsContainerTest
atest BubbleTextViewTest
Change-Id: Ib9c0ac6c330d6f4e08c3db5772d35787fa056b65
This commit is contained in:
1 parent
1809cb6ff3
commit
36c3112abf
19 files changed
+442
-370
No files matched your search
@@ -15,6 +15,9 @@
|
||||
*/
|
||||
package com.android.launcher3.model;
|
||||
|
||||
import static com.android.launcher3.icons.cache.CacheLookupFlag.DEFAULT_LOOKUP_FLAG;
|
||||
import static com.android.launcher3.model.ModelUtils.WIDGET_FILTER;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.os.UserHandle;
|
||||
|
||||
@@ -23,6 +26,8 @@ import androidx.annotation.NonNull;
|
||||
import com.android.launcher3.LauncherModel.ModelUpdateTask;
|
||||
import com.android.launcher3.LauncherSettings;
|
||||
import com.android.launcher3.icons.IconCache;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.model.data.LauncherAppWidgetInfo;
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -55,7 +60,7 @@ public class CacheDataUpdatedTask implements ModelUpdateTask {
|
||||
public void execute(@NonNull ModelTaskController taskController, @NonNull BgDataModel dataModel,
|
||||
@NonNull AllAppsList apps) {
|
||||
IconCache iconCache = taskController.getApp().getIconCache();
|
||||
ArrayList<WorkspaceItemInfo> updatedShortcuts = new ArrayList<>();
|
||||
ArrayList<ItemInfo> updatedItems = new ArrayList<>();
|
||||
|
||||
synchronized (dataModel) {
|
||||
dataModel.forAllWorkspaceItemInfos(mUser, si -> {
|
||||
@@ -64,12 +69,25 @@ public class CacheDataUpdatedTask implements ModelUpdateTask {
|
||||
&& isValidShortcut(si) && cn != null
|
||||
&& mPackages.contains(cn.getPackageName())) {
|
||||
iconCache.getTitleAndIcon(si, si.getMatchingLookupFlag());
|
||||
updatedShortcuts.add(si);
|
||||
updatedItems.add(si);
|
||||
}
|
||||
});
|
||||
|
||||
dataModel.itemsIdMap.stream()
|
||||
.filter(WIDGET_FILTER)
|
||||
.filter(item -> mUser.equals(item.user))
|
||||
.map(item -> (LauncherAppWidgetInfo) item)
|
||||
.filter(widget -> mPackages.contains(widget.providerName.getPackageName())
|
||||
&& widget.pendingItemInfo != null)
|
||||
.forEach(widget -> {
|
||||
iconCache.getTitleAndIconForApp(
|
||||
widget.pendingItemInfo, DEFAULT_LOOKUP_FLAG);
|
||||
updatedItems.add(widget);
|
||||
});
|
||||
|
||||
apps.updateIconsAndLabels(mPackages, mUser);
|
||||
}
|
||||
taskController.bindUpdatedWorkspaceItems(updatedShortcuts);
|
||||
taskController.bindUpdatedWorkspaceItems(updatedItems);
|
||||
taskController.bindApplicationsIfNeeded();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user