Move onInitialBindComplete to ModelCallbacks
Changes are part of go/launcher_SoR .
Flag: NA
Bug: 301108526
Test: TaplWorkspace
Change-Id: I1a12309897a04f3ae1642fcdc9f984f7f274ba13
diff --git a/src/com/android/launcher3/ModelCallbacks.kt b/src/com/android/launcher3/ModelCallbacks.kt
index c05158b..c686cbe 100644
--- a/src/com/android/launcher3/ModelCallbacks.kt
+++ b/src/com/android/launcher3/ModelCallbacks.kt
@@ -1,6 +1,11 @@
package com.android.launcher3
+import android.annotation.TargetApi
+import android.os.Build
+import android.os.Trace
+import android.view.ViewTreeObserver.OnDrawListener
import androidx.annotation.UiThread
+import com.android.launcher3.LauncherConstants.TraceEvents
import com.android.launcher3.WorkspaceLayoutManager.FIRST_SCREEN_ID
import com.android.launcher3.allapps.AllAppsStore
import com.android.launcher3.config.FeatureFlags
@@ -13,11 +18,12 @@
import com.android.launcher3.model.data.WorkspaceItemInfo
import com.android.launcher3.popup.PopupContainerWithArrow
import com.android.launcher3.util.ComponentKey
+import com.android.launcher3.util.Executors
import com.android.launcher3.util.IntArray as LIntArray
import com.android.launcher3.util.IntSet as LIntSet
-import com.android.launcher3.util.IntSet
import com.android.launcher3.util.PackageUserKey
import com.android.launcher3.util.Preconditions
+import com.android.launcher3.util.RunnableList
import com.android.launcher3.util.TraceHelper
import com.android.launcher3.util.ViewOnDrawExecutor
import com.android.launcher3.widget.PendingAddWidgetInfo
@@ -64,6 +70,46 @@
TraceHelper.INSTANCE.endSection()
}
+ @TargetApi(Build.VERSION_CODES.S)
+ override fun onInitialBindComplete(
+ boundPages: LIntSet,
+ pendingTasks: RunnableList,
+ workspaceItemCount: Int,
+ isBindSync: Boolean
+ ) {
+ synchronouslyBoundPages = boundPages
+ pagesToBindSynchronously = LIntSet()
+ clearPendingBinds()
+ val executor = ViewOnDrawExecutor(pendingTasks)
+ pendingExecutor = executor
+ if (!launcher.isInState(LauncherState.ALL_APPS)) {
+ launcher.appsView.appsStore.enableDeferUpdates(AllAppsStore.DEFER_UPDATES_NEXT_DRAW)
+ pendingTasks.add {
+ launcher.appsView.appsStore.disableDeferUpdates(
+ AllAppsStore.DEFER_UPDATES_NEXT_DRAW
+ )
+ }
+ }
+ executor.onLoadAnimationCompleted()
+ executor.attachTo(launcher)
+ if (Utilities.ATLEAST_S) {
+ Trace.endAsyncSection(
+ TraceEvents.DISPLAY_WORKSPACE_TRACE_METHOD_NAME,
+ TraceEvents.DISPLAY_WORKSPACE_TRACE_COOKIE
+ )
+ }
+ launcher.bindComplete(workspaceItemCount, isBindSync)
+ launcher.rootView.viewTreeObserver.addOnDrawListener(
+ object : OnDrawListener {
+ override fun onDraw() {
+ Executors.MAIN_EXECUTOR.handler.postAtFrontOfQueue {
+ launcher.rootView.getViewTreeObserver().removeOnDrawListener(this)
+ }
+ }
+ }
+ )
+ }
+
/**
* Callback saying that there aren't any more items to bind.
*
@@ -83,7 +129,7 @@
// Since we are just resetting the current page without user interaction,
// override the previous page so we don't log the page switch.
launcher.workspace.setCurrentPage(currentPage, currentPage /* overridePrevPage */)
- pagesToBindSynchronously = IntSet()
+ pagesToBindSynchronously = LIntSet()
// Cache one page worth of icons
launcher.viewCache.setCacheSize(
@@ -319,7 +365,7 @@
} else {
// Some empty pages might have been removed while the phone was in a single panel
// mode, so we want to add those empty pages back.
- val screenIds = IntSet.wrap(orderedScreenIds)
+ val screenIds = LIntSet.wrap(orderedScreenIds)
orderedScreenIds.forEach { screenId: Int ->
screenIds.add(launcher.workspace.getScreenPair(screenId))
}
@@ -343,7 +389,7 @@
* if not present.
*/
private fun filterTwoPanelScreenIds(orderedScreenIds: LIntArray): LIntArray {
- val screenIds = IntSet.wrap(orderedScreenIds)
+ val screenIds = LIntSet.wrap(orderedScreenIds)
orderedScreenIds
.filter { screenId -> screenId % 2 == 1 }
.forEach { screenId ->