Merging update and modify model callbacks

Instead of the dispatcher specifying the type, the UI checks th diff. This
ensures that the UI is updated correctly in all paths

Bug: 390572144
Flag: EXEMPT refactor
Test: Manually verified folder edit path where these callbacks were getting dispatched

Change-Id: Ib73eed5da87a847753a78453a48ab4fc495c1199
This commit is contained in:
Sunny Goyal committed 2025-04-21 12:31:23 -07:00
1 parent c562b3ce4e
commit 007cfecf5e
14 files changed
+211 -87

No files matched your search

@@ -15,17 +15,23 @@
*/
package com.android.launcher3.taskbar;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION;
import android.util.SparseArray;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.celllayout.CellInfo;
import com.android.launcher3.model.BgDataModel;
import com.android.launcher3.model.BgDataModel.FixedContainerItems;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.taskbar.TaskbarView.TaskbarLayoutParams;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.IntArray;
import com.android.launcher3.util.IntSet;
@@ -104,7 +110,7 @@ public class TaskbarModelCallbacks implements
}
}
private boolean handleItemsAdded(List<ItemInfo> items) {
private boolean handleItemsAdded(Iterable<ItemInfo> items) {
boolean modified = false;
for (ItemInfo item : items) {
if (item.container == Favorites.CONTAINER_HOTSEAT) {
@@ -117,7 +123,24 @@ public class TaskbarModelCallbacks implements
@Override
public void bindItemsUpdated(Set<ItemInfo> updates) {
updateContainerItems(updates, mContext);
Set<ItemInfo> itemsToRebind = updateContainerItems(updates, mContext);
boolean removed = handleItemsRemoved(ItemInfoMatcher.ofItems(itemsToRebind));
boolean added = handleItemsAdded(itemsToRebind);
if (removed || added) {
commitItemsToUI();
}
}
@Nullable
@Override
public CellInfo getCellInfoForView(@NonNull View view) {
return view.getLayoutParams() instanceof TaskbarLayoutParams tlp ? tlp.bindInfo : null;
}
@Override
public boolean isContainerSupported(int container) {
return container == CONTAINER_HOTSEAT || container == CONTAINER_HOTSEAT_PREDICTION;
}
@Override
@@ -150,15 +173,6 @@ public class TaskbarModelCallbacks implements
return modified;
}
@Override
public void bindItemsModified(List<ItemInfo> items) {
boolean removed = handleItemsRemoved(ItemInfoMatcher.ofItems(items));
boolean added = handleItemsAdded(items);
if (removed || added) {
commitItemsToUI();
}
}
@Override
public void bindExtraContainerItems(FixedContainerItems item) {
if (item.containerId == Favorites.CONTAINER_HOTSEAT_PREDICTION) {