Removing UI dependency from LauncherModel in case of 2-panel layout

Bug: 175939730
Bug: 192431856
Bug: 185515153
Test: Manual
Change-Id: I8baa1cf9e5a8a04d5b8bc38c1f4b0755265cd8a9
This commit is contained in:
Sunny Goyal
2021-07-15 14:31:58 -07:00
parent 12a0357c31
commit 12e3f1f2f7
14 changed files with 110 additions and 449 deletions

View File

@@ -165,25 +165,7 @@ public abstract class BaseLoaderResults {
}
private void bind() {
IntSet currentScreenIndices;
{
// Create an anonymous scope to calculate currentScreen as it has to be a
// final variable.
IntSet screenIndices = mCallbacks.getPagesToBindSynchronously();
if (screenIndices == null || screenIndices.isEmpty()
|| screenIndices.getArray().get(screenIndices.size() - 1)
>= mOrderedScreenIds.size()) {
// There maybe no workspace screens (just hotseat items and an empty page).
// Also we want to prevent IndexOutOfBoundsExceptions.
screenIndices = new IntSet();
}
currentScreenIndices = screenIndices;
}
IntSet currentScreenIds = new IntSet();
currentScreenIndices.forEach(
index -> currentScreenIds.add(mOrderedScreenIds.get(index)));
IntSet currentScreenIds = mCallbacks.getPagesToBindSynchronously(mOrderedScreenIds);
// Separate the items that are on the current screen, and all the other remaining items
ArrayList<ItemInfo> currentWorkspaceItems = new ArrayList<>();
@@ -218,7 +200,7 @@ public abstract class BaseLoaderResults {
Executor pendingExecutor = pendingTasks::add;
bindWorkspaceItems(otherWorkspaceItems, pendingExecutor);
bindAppWidgets(otherAppWidgets, pendingExecutor);
executeCallbacksTask(c -> c.finishBindingItems(currentScreenIndices), pendingExecutor);
executeCallbacksTask(c -> c.finishBindingItems(currentScreenIds), pendingExecutor);
pendingExecutor.execute(
() -> {
MODEL_EXECUTOR.setThreadPriority(Process.THREAD_PRIORITY_DEFAULT);
@@ -229,7 +211,7 @@ public abstract class BaseLoaderResults {
executeCallbacksTask(
c -> {
MODEL_EXECUTOR.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
c.onInitialBindComplete(currentScreenIndices, pendingTasks);
c.onInitialBindComplete(currentScreenIds, pendingTasks);
}, mUiExecutor);
}