From 05c27d4b698a71551905a938db23f688ce5ca0e7 Mon Sep 17 00:00:00 2001 From: Derek Prothro Date: Tue, 10 Dec 2013 14:00:37 -0500 Subject: Bind the workspace synchronously if started on -1 screen. Previously, LoaderTask would be run asynchronously to bind the workspace when started on -1 which would cause the user's wallpaper to briefly flash when rotating the device on -1. Bug: 11802691 Change-Id: I3a1a7a32fa28a81e041a283a93d808d5a8884133 --- src/com/android/launcher3/LauncherModel.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/com/android/launcher3/LauncherModel.java') diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java index 4e01996ee..44ea79003 100644 --- a/src/com/android/launcher3/LauncherModel.java +++ b/src/com/android/launcher3/LauncherModel.java @@ -85,6 +85,7 @@ public class LauncherModel extends BroadcastReceiver { public static final boolean UPGRADE_USE_MORE_APPS_FOLDER = false; private static final int ITEMS_CHUNK = 6; // batch size for the workspace icons + private static final long INVALID_SCREEN_ID = -1L; private final boolean mAppsCanBeOnRemoveableStorage; private final LauncherAppState mApp; @@ -1220,7 +1221,7 @@ public class LauncherModel extends BroadcastReceiver { } } if (runLoader) { - startLoader(false, -1); + startLoader(false, PagedView.INVALID_RESTORE_PAGE); } } @@ -1254,7 +1255,8 @@ public class LauncherModel extends BroadcastReceiver { // also, don't downgrade isLaunching if we're already running isLaunching = isLaunching || stopLoaderLocked(); mLoaderTask = new LoaderTask(mApp.getContext(), isLaunching); - if (synchronousBindPage > -1 && mAllAppsLoaded && mWorkspaceLoaded) { + if (synchronousBindPage != PagedView.INVALID_RESTORE_PAGE + && mAllAppsLoaded && mWorkspaceLoaded) { mLoaderTask.runBindSynchronousPage(synchronousBindPage); } else { sWorkerThread.setPriority(Thread.NORM_PRIORITY); @@ -1491,7 +1493,7 @@ public class LauncherModel extends BroadcastReceiver { } void runBindSynchronousPage(int synchronousBindPage) { - if (synchronousBindPage < 0) { + if (synchronousBindPage == PagedView.INVALID_RESTORE_PAGE) { // Ensure that we have a valid page index to load synchronously throw new RuntimeException("Should not call runBindSynchronousPage() without " + "valid page index"); @@ -2417,16 +2419,17 @@ public class LauncherModel extends BroadcastReceiver { orderedScreenIds.addAll(sBgWorkspaceScreens); } - final boolean isLoadingSynchronously = (synchronizeBindPage > -1); + final boolean isLoadingSynchronously = + synchronizeBindPage != PagedView.INVALID_RESTORE_PAGE; int currScreen = isLoadingSynchronously ? synchronizeBindPage : oldCallbacks.getCurrentWorkspaceScreen(); if (currScreen >= orderedScreenIds.size()) { // There may be no workspace screens (just hotseat items and an empty page). - currScreen = -1; + currScreen = PagedView.INVALID_RESTORE_PAGE; } final int currentScreen = currScreen; - final long currentScreenId = - currentScreen < 0 ? -1 : orderedScreenIds.get(currentScreen); + final long currentScreenId = currentScreen < 0 + ? INVALID_SCREEN_ID : orderedScreenIds.get(currentScreen); // Load all the items that are on the current page first (and in the process, unbind // all the existing workspace items before we call startBinding() below. @@ -2471,7 +2474,7 @@ public class LauncherModel extends BroadcastReceiver { r = new Runnable() { public void run() { Callbacks callbacks = tryGetCallbacks(oldCallbacks); - if (callbacks != null && currentScreen >= 0) { + if (callbacks != null && currentScreen != PagedView.INVALID_RESTORE_PAGE) { callbacks.onPageBoundSynchronously(currentScreen); } } -- cgit v1.2.3