diff options
Diffstat (limited to 'src/com/android/launcher3/ModelCallbacks.kt')
-rw-r--r-- | src/com/android/launcher3/ModelCallbacks.kt | 54 |
1 files changed, 50 insertions, 4 deletions
diff --git a/src/com/android/launcher3/ModelCallbacks.kt b/src/com/android/launcher3/ModelCallbacks.kt index f37a1ecea1..51729992d4 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.LauncherAppWidgetInfo 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 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks { 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 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks { // 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 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks { } 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 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks { * 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 -> |