summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/states
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2018-01-17 10:00:23 -0800
committerWinson Chung <winsonc@google.com>2018-01-29 14:14:07 -0800
commit1a341002fcd8b6491701f6b7a8583c6e02ee34ba (patch)
tree669342e4f6ce419f707399d0eb886fc027f21946 /src/com/android/launcher3/states
parentd30e74b58cc45b08665cb48b98dc8b3b21b4b265 (diff)
downloadandroid_packages_apps_Trebuchet-1a341002fcd8b6491701f6b7a8583c6e02ee34ba.tar.gz
android_packages_apps_Trebuchet-1a341002fcd8b6491701f6b7a8583c6e02ee34ba.tar.bz2
android_packages_apps_Trebuchet-1a341002fcd8b6491701f6b7a8583c6e02ee34ba.zip
Add code path for the recents animation using window transitions.
Test: Enable in settings, swipe up Change-Id: I1053f9e519c2f612bd3db0b66cd16ad9a30bfeb4
Diffstat (limited to 'src/com/android/launcher3/states')
-rw-r--r--src/com/android/launcher3/states/InternalStateHandler.java56
1 files changed, 49 insertions, 7 deletions
diff --git a/src/com/android/launcher3/states/InternalStateHandler.java b/src/com/android/launcher3/states/InternalStateHandler.java
index f084fd256..4c3ef4b2a 100644
--- a/src/com/android/launcher3/states/InternalStateHandler.java
+++ b/src/com/android/launcher3/states/InternalStateHandler.java
@@ -21,7 +21,11 @@ import android.os.Bundle;
import android.os.IBinder;
import com.android.launcher3.Launcher;
-import com.android.launcher3.Launcher.OnResumeCallback;
+import com.android.launcher3.LauncherAppState;
+import com.android.launcher3.LauncherModel.Callbacks;
+import com.android.launcher3.util.Preconditions;
+
+import java.lang.ref.WeakReference;
/**
* Utility class to sending state handling logic to Launcher from within the same process.
@@ -29,11 +33,17 @@ import com.android.launcher3.Launcher.OnResumeCallback;
* Extending {@link Binder} ensures that the platform maintains a single instance of each object
* which allows this object to safely navigate the system process.
*/
-public abstract class InternalStateHandler extends Binder implements OnResumeCallback {
+public abstract class InternalStateHandler extends Binder {
public static final String EXTRA_STATE_HANDLER = "launcher.state_handler";
- protected abstract void init(Launcher launcher, boolean alreadyOnHome);
+ private static WeakReference<InternalStateHandler> sPendingHandler = new WeakReference<>(null);
+
+ /**
+ * Initializes the handler when the launcher is ready.
+ * @return true if the handler wants to stay alive.
+ */
+ protected abstract boolean init(Launcher launcher, boolean alreadyOnHome);
public final Intent addToIntent(Intent intent) {
Bundle extras = new Bundle();
@@ -42,6 +52,29 @@ public abstract class InternalStateHandler extends Binder implements OnResumeCal
return intent;
}
+ public final void initWhenReady() {
+ Preconditions.assertUIThread();
+ sPendingHandler = new WeakReference<>(this);
+ LauncherAppState app = LauncherAppState.getInstanceNoCreate();
+ if (app == null) {
+ return;
+ }
+ Callbacks cb = app.getModel().getCallback();
+ if (!(cb instanceof Launcher)) {
+ return;
+ }
+ Launcher launcher = (Launcher) cb;
+ if (!init(launcher, launcher.isStarted())) {
+ sPendingHandler.clear();
+ }
+ }
+
+ public void clearReference() {
+ if (sPendingHandler.get() == this) {
+ sPendingHandler.clear();
+ }
+ }
+
public static boolean handleCreate(Launcher launcher, Intent intent) {
return handleIntent(launcher, intent, false);
}
@@ -57,12 +90,21 @@ public abstract class InternalStateHandler extends Binder implements OnResumeCal
IBinder stateBinder = intent.getExtras().getBinder(EXTRA_STATE_HANDLER);
if (stateBinder instanceof InternalStateHandler) {
InternalStateHandler handler = (InternalStateHandler) stateBinder;
- launcher.setOnResumeCallback(handler);
- handler.init(launcher, alreadyOnHome);
+ if (!handler.init(launcher, alreadyOnHome)) {
+ intent.getExtras().remove(EXTRA_STATE_HANDLER);
+ }
+ result = true;
+ }
+ }
+ if (!result) {
+ InternalStateHandler pendingHandler = sPendingHandler.get();
+ if (pendingHandler != null) {
+ if (!pendingHandler.init(launcher, alreadyOnHome)) {
+ sPendingHandler.clear();
+ }
result = true;
}
- intent.getExtras().remove(EXTRA_STATE_HANDLER);
}
return result;
}
-}
+} \ No newline at end of file