Loading src/com/android/launcher3/model/BaseLauncherBinder.java +15 −27 Original line number Diff line number Diff line Loading @@ -29,6 +29,8 @@ import android.util.Log; import android.util.Pair; import android.view.View; import androidx.annotation.NonNull; import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.LauncherAppState; import com.android.launcher3.LauncherModel.CallbackTask; Loading Loading @@ -321,19 +323,22 @@ public abstract class BaseLauncherBinder { Executor pendingExecutor = pendingTasks::add; RunnableList onCompleteSignal = new RunnableList(); ItemInflater inflater = mCallbacks.getItemInflater(); if (enableWorkspaceInflation()) { if (enableWorkspaceInflation() && inflater != null) { MODEL_EXECUTOR.execute(() -> { setupPendingBind(otherWorkspaceItems, otherAppWidgets, currentScreenIds, pendingExecutor); inflateAsyncAndBind(otherWorkspaceItems, inflater, pendingExecutor); inflateAsyncAndBind(otherAppWidgets, inflater, pendingExecutor); setupPendingBind(currentScreenIds, pendingExecutor); // Wait for the async inflation to complete and then notify the completion // signal on UI thread. MAIN_EXECUTOR.execute(onCompleteSignal::executeAllAndDestroy); }); } else { setupPendingBind( otherWorkspaceItems, otherAppWidgets, currentScreenIds, pendingExecutor); bindItemsInChunks(otherWorkspaceItems, ITEMS_CHUNK, pendingExecutor); bindItemsInChunks(otherAppWidgets, 1, pendingExecutor); setupPendingBind(currentScreenIds, pendingExecutor); onCompleteSignal.executeAllAndDestroy(); } Loading @@ -348,13 +353,8 @@ public abstract class BaseLauncherBinder { } private void setupPendingBind( List<ItemInfo> otherWorkspaceItems, List<ItemInfo> otherAppWidgets, IntSet currentScreenIds, Executor pendingExecutor) { bindItemsInChunks(otherWorkspaceItems, ITEMS_CHUNK, pendingExecutor); bindItemsInChunks(otherAppWidgets, 1, pendingExecutor); StringCache cacheClone = mBgDataModel.stringCache.clone(); executeCallbacksTask(c -> c.bindStringCache(cacheClone), pendingExecutor); Loading @@ -371,18 +371,11 @@ public abstract class BaseLauncherBinder { * Tries to inflate the items asynchronously and bind. Returns true on success or false if * async-binding is not supported in this case. */ private boolean inflateAsyncAndBind(List<ItemInfo> items, Executor executor) { if (!enableWorkspaceInflation()) { return false; } ItemInflater inflater = mCallbacks.getItemInflater(); if (inflater == null) { return false; } private void inflateAsyncAndBind( List<ItemInfo> items, @NonNull ItemInflater inflater, Executor executor) { if (mMyBindingId != mBgDataModel.lastBindId) { Log.d(TAG, "Too many consecutive reloads, skipping obsolete view inflation"); return true; return; } ModelWriter writer = mApp.getModel() Loading @@ -390,15 +383,10 @@ public abstract class BaseLauncherBinder { List<Pair<ItemInfo, View>> bindItems = items.stream().map(i -> Pair.create(i, inflater.inflateItem(i, writer, null))).toList(); executeCallbacksTask(c -> c.bindInflatedItems(bindItems), executor); return true; } private void bindItemsInChunks(List<ItemInfo> workspaceItems, int chunkCount, Executor executor) { if (inflateAsyncAndBind(workspaceItems, executor)) { return; } private void bindItemsInChunks( List<ItemInfo> workspaceItems, int chunkCount, Executor executor) { // Bind the workspace items int count = workspaceItems.size(); for (int i = 0; i < count; i += chunkCount) { Loading Loading
src/com/android/launcher3/model/BaseLauncherBinder.java +15 −27 Original line number Diff line number Diff line Loading @@ -29,6 +29,8 @@ import android.util.Log; import android.util.Pair; import android.view.View; import androidx.annotation.NonNull; import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.LauncherAppState; import com.android.launcher3.LauncherModel.CallbackTask; Loading Loading @@ -321,19 +323,22 @@ public abstract class BaseLauncherBinder { Executor pendingExecutor = pendingTasks::add; RunnableList onCompleteSignal = new RunnableList(); ItemInflater inflater = mCallbacks.getItemInflater(); if (enableWorkspaceInflation()) { if (enableWorkspaceInflation() && inflater != null) { MODEL_EXECUTOR.execute(() -> { setupPendingBind(otherWorkspaceItems, otherAppWidgets, currentScreenIds, pendingExecutor); inflateAsyncAndBind(otherWorkspaceItems, inflater, pendingExecutor); inflateAsyncAndBind(otherAppWidgets, inflater, pendingExecutor); setupPendingBind(currentScreenIds, pendingExecutor); // Wait for the async inflation to complete and then notify the completion // signal on UI thread. MAIN_EXECUTOR.execute(onCompleteSignal::executeAllAndDestroy); }); } else { setupPendingBind( otherWorkspaceItems, otherAppWidgets, currentScreenIds, pendingExecutor); bindItemsInChunks(otherWorkspaceItems, ITEMS_CHUNK, pendingExecutor); bindItemsInChunks(otherAppWidgets, 1, pendingExecutor); setupPendingBind(currentScreenIds, pendingExecutor); onCompleteSignal.executeAllAndDestroy(); } Loading @@ -348,13 +353,8 @@ public abstract class BaseLauncherBinder { } private void setupPendingBind( List<ItemInfo> otherWorkspaceItems, List<ItemInfo> otherAppWidgets, IntSet currentScreenIds, Executor pendingExecutor) { bindItemsInChunks(otherWorkspaceItems, ITEMS_CHUNK, pendingExecutor); bindItemsInChunks(otherAppWidgets, 1, pendingExecutor); StringCache cacheClone = mBgDataModel.stringCache.clone(); executeCallbacksTask(c -> c.bindStringCache(cacheClone), pendingExecutor); Loading @@ -371,18 +371,11 @@ public abstract class BaseLauncherBinder { * Tries to inflate the items asynchronously and bind. Returns true on success or false if * async-binding is not supported in this case. */ private boolean inflateAsyncAndBind(List<ItemInfo> items, Executor executor) { if (!enableWorkspaceInflation()) { return false; } ItemInflater inflater = mCallbacks.getItemInflater(); if (inflater == null) { return false; } private void inflateAsyncAndBind( List<ItemInfo> items, @NonNull ItemInflater inflater, Executor executor) { if (mMyBindingId != mBgDataModel.lastBindId) { Log.d(TAG, "Too many consecutive reloads, skipping obsolete view inflation"); return true; return; } ModelWriter writer = mApp.getModel() Loading @@ -390,15 +383,10 @@ public abstract class BaseLauncherBinder { List<Pair<ItemInfo, View>> bindItems = items.stream().map(i -> Pair.create(i, inflater.inflateItem(i, writer, null))).toList(); executeCallbacksTask(c -> c.bindInflatedItems(bindItems), executor); return true; } private void bindItemsInChunks(List<ItemInfo> workspaceItems, int chunkCount, Executor executor) { if (inflateAsyncAndBind(workspaceItems, executor)) { return; } private void bindItemsInChunks( List<ItemInfo> workspaceItems, int chunkCount, Executor executor) { // Bind the workspace items int count = workspaceItems.size(); for (int i = 0; i < count; i += chunkCount) { Loading