mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-19 10:48:19 +00:00
Adding support for storing container based item list in the model
These items get updated automatically during various model tasks. Also simplifying the pinned shortcut state, by calculating the list of ppined shortcut on demand, instead of storing a refCount. Bug: 160748731 Change-Id: I3169d293552b05b4f4d6c529397fbc761887a282
This commit is contained in:
@@ -22,7 +22,9 @@ import com.android.launcher3.LauncherModel;
|
||||
import com.android.launcher3.LauncherModel.CallbackTask;
|
||||
import com.android.launcher3.LauncherModel.ModelUpdateTask;
|
||||
import com.android.launcher3.model.BgDataModel.Callbacks;
|
||||
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.model.data.WorkspaceItemInfo;
|
||||
import com.android.launcher3.util.ComponentKey;
|
||||
import com.android.launcher3.util.ItemInfoMatcher;
|
||||
@@ -30,7 +32,10 @@ import com.android.launcher3.widget.WidgetListRowEntry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Extension of {@link ModelUpdateTask} with some utility methods
|
||||
@@ -88,11 +93,27 @@ public abstract class BaseModelUpdateTask implements ModelUpdateTask {
|
||||
return mModel.getWriter(false /* hasVerticalHotseat */, false /* verifyChanges */);
|
||||
}
|
||||
|
||||
|
||||
public void bindUpdatedWorkspaceItems(final ArrayList<WorkspaceItemInfo> updatedShortcuts) {
|
||||
if (!updatedShortcuts.isEmpty()) {
|
||||
scheduleCallbackTask(c -> c.bindWorkspaceItemsChanged(updatedShortcuts));
|
||||
public void bindUpdatedWorkspaceItems(List<WorkspaceItemInfo> allUpdates) {
|
||||
// Bind workspace items
|
||||
List<WorkspaceItemInfo> workspaceUpdates = allUpdates.stream()
|
||||
.filter(info -> info.id != ItemInfo.NO_ID)
|
||||
.collect(Collectors.toList());
|
||||
if (!workspaceUpdates.isEmpty()) {
|
||||
scheduleCallbackTask(c -> c.bindWorkspaceItemsChanged(workspaceUpdates));
|
||||
}
|
||||
|
||||
// Bind extra items if any
|
||||
allUpdates.stream()
|
||||
.mapToInt(info -> info.container)
|
||||
.distinct()
|
||||
.mapToObj(mDataModel.extraItems::get)
|
||||
.filter(Objects::nonNull)
|
||||
.forEach(this::bindExtraContainerItems);
|
||||
}
|
||||
|
||||
public void bindExtraContainerItems(FixedContainerItems item) {
|
||||
FixedContainerItems copy = item.clone();
|
||||
scheduleCallbackTask(c -> c.bindExtraContainerItems(copy));
|
||||
}
|
||||
|
||||
public void bindDeepShortcuts(BgDataModel dataModel) {
|
||||
|
||||
Reference in New Issue
Block a user