summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWinson <winsonc@google.com>2015-08-19 18:02:39 (GMT)
committerWinson <winsonc@google.com>2015-08-19 19:13:20 (GMT)
commit15f8b17adb36e7345e39cc1c431f8c1abd84f832 (patch)
treea0412eb184c190b05ae4fa9a631b5ddb7ec85dc0
parent81056da1def5d872d26b6f8a4e4163f9d94871a3 (diff)
downloadandroid_packages_apps_Trebuchet-15f8b17adb36e7345e39cc1c431f8c1abd84f832.zip
android_packages_apps_Trebuchet-15f8b17adb36e7345e39cc1c431f8c1abd84f832.tar.gz
android_packages_apps_Trebuchet-15f8b17adb36e7345e39cc1c431f8c1abd84f832.tar.bz2
Deferring the move to the default screen until after we callback to the callbacks.
- Since move to default screen starts the scroller immediately, any delays in handling onNewIntent and onHomeIntent in the callbacks will cause the scroller to skip frames the next time it updates. This change will defer updating the page to the default screen until after onNewIntent is called back (and all its posted runnables). Bug: 22929080 Change-Id: Ibab6106938721702d4da23faaca99039861e10dc
-rw-r--r--src/com/android/launcher3/Launcher.java44
1 files changed, 27 insertions, 17 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 298b2c4..203e224 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -1867,29 +1867,22 @@ public class Launcher extends Activity
super.onNewIntent(intent);
// Close the menu
- if (Intent.ACTION_MAIN.equals(intent.getAction())) {
+ Folder openFolder = mWorkspace.getOpenFolder();
+ boolean alreadyOnHome = mHasFocus && ((intent.getFlags() &
+ Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT)
+ != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
+ boolean isActionMain = Intent.ACTION_MAIN.equals(intent.getAction());
+ if (isActionMain) {
// also will cancel mWaitingForResult.
closeSystemDialogs();
- final boolean alreadyOnHome = mHasFocus && ((intent.getFlags() &
- Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT)
- != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
-
if (mWorkspace == null) {
// Can be cases where mWorkspace is null, this prevents a NPE
return;
}
- Folder openFolder = mWorkspace.getOpenFolder();
// In all these cases, only animate if we're already on home
mWorkspace.exitWidgetResizeMode();
- boolean moveToDefaultScreen = mLauncherCallbacks != null ?
- mLauncherCallbacks.shouldMoveToDefaultScreenOnHomeIntent() : true;
- if (alreadyOnHome && mState == State.WORKSPACE && !mWorkspace.isTouchActive() &&
- openFolder == null && moveToDefaultScreen) {
- mWorkspace.moveToDefaultScreen(true);
- }
-
closeFolder();
exitSpringLoadedDragMode();
@@ -1923,13 +1916,30 @@ public class Launcher extends Activity
}
}
- if (DEBUG_RESUME_TIME) {
- Log.d(TAG, "Time spent in onNewIntent: " + (System.currentTimeMillis() - startTime));
- }
-
if (mLauncherCallbacks != null) {
mLauncherCallbacks.onNewIntent(intent);
}
+
+ // Defer moving to the default screen until after we callback to the LauncherCallbacks
+ // as slow logic in the callbacks eat into the time the scroller expects for the snapToPage
+ // animation.
+ if (isActionMain) {
+ boolean moveToDefaultScreen = mLauncherCallbacks != null ?
+ mLauncherCallbacks.shouldMoveToDefaultScreenOnHomeIntent() : true;
+ if (alreadyOnHome && mState == State.WORKSPACE && !mWorkspace.isTouchActive() &&
+ openFolder == null && moveToDefaultScreen) {
+ mWorkspace.post(new Runnable() {
+ @Override
+ public void run() {
+ mWorkspace.moveToDefaultScreen(true);
+ }
+ });
+ }
+ }
+
+ if (DEBUG_RESUME_TIME) {
+ Log.d(TAG, "Time spent in onNewIntent: " + (System.currentTimeMillis() - startTime));
+ }
}
@Override