summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/util
diff options
context:
space:
mode:
authorTony <twickham@google.com>2017-07-31 23:29:42 -0700
committerTony Wickham <twickham@google.com>2017-08-04 11:52:42 -0700
commit2917a8bf2b83c0d17400b1475f01a9a8d9137f62 (patch)
tree997ee0bcefeac147867f0e8612594ea739ed3048 /src/com/android/launcher3/util
parent00abdaca619d3a91aad9f9cc2c192650705c6b98 (diff)
downloadandroid_packages_apps_Trebuchet-2917a8bf2b83c0d17400b1475f01a9a8d9137f62.tar.gz
android_packages_apps_Trebuchet-2917a8bf2b83c0d17400b1475f01a9a8d9137f62.tar.bz2
android_packages_apps_Trebuchet-2917a8bf2b83c0d17400b1475f01a9a8d9137f62.zip
Defer some work until after workspace fade-in
Defer: - Setting all apps - Setting widgets Also set the launcher-loader thread to THREAD_PRIORITY_BACKGROUND for the duration of the animation. Bug: 37965432 Change-Id: I8364940805b84aecb8353a473ab4d575c27bfec4
Diffstat (limited to 'src/com/android/launcher3/util')
-rw-r--r--src/com/android/launcher3/util/ViewOnDrawExecutor.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/com/android/launcher3/util/ViewOnDrawExecutor.java b/src/com/android/launcher3/util/ViewOnDrawExecutor.java
index 4cb6ca831..e5c1dd1b4 100644
--- a/src/com/android/launcher3/util/ViewOnDrawExecutor.java
+++ b/src/com/android/launcher3/util/ViewOnDrawExecutor.java
@@ -16,11 +16,13 @@
package com.android.launcher3.util;
+import android.os.Process;
import android.view.View;
import android.view.View.OnAttachStateChangeListener;
import android.view.ViewTreeObserver.OnDrawListener;
import com.android.launcher3.Launcher;
+import com.android.launcher3.LauncherModel;
import java.util.ArrayList;
import java.util.concurrent.Executor;
@@ -37,6 +39,7 @@ public class ViewOnDrawExecutor implements Executor, OnDrawListener, Runnable,
private Launcher mLauncher;
private View mAttachedView;
private boolean mCompleted;
+ private boolean mIsExecuting;
private boolean mLoadAnimationCompleted;
private boolean mFirstDrawCompleted;
@@ -62,6 +65,7 @@ public class ViewOnDrawExecutor implements Executor, OnDrawListener, Runnable,
@Override
public void execute(Runnable command) {
mTasks.add(command);
+ LauncherModel.setWorkerPriority(Process.THREAD_PRIORITY_BACKGROUND);
}
@Override
@@ -78,6 +82,13 @@ public class ViewOnDrawExecutor implements Executor, OnDrawListener, Runnable,
mAttachedView.post(this);
}
+ /**
+ * Returns whether the executor is still queuing tasks and hasn't yet executed them.
+ */
+ public boolean canQueue() {
+ return !mIsExecuting && !mCompleted;
+ }
+
public void onLoadAnimationCompleted() {
mLoadAnimationCompleted = true;
if (mAttachedView != null) {
@@ -89,6 +100,7 @@ public class ViewOnDrawExecutor implements Executor, OnDrawListener, Runnable,
public void run() {
// Post the pending tasks after both onDraw and onLoadAnimationCompleted have been called.
if (mLoadAnimationCompleted && mFirstDrawCompleted && !mCompleted) {
+ mIsExecuting = true;
for (final Runnable r : mTasks) {
mExecutor.execute(r);
}
@@ -99,6 +111,7 @@ public class ViewOnDrawExecutor implements Executor, OnDrawListener, Runnable,
public void markCompleted() {
mTasks.clear();
mCompleted = true;
+ mIsExecuting = false;
if (mAttachedView != null) {
mAttachedView.getViewTreeObserver().removeOnDrawListener(this);
mAttachedView.removeOnAttachStateChangeListener(this);
@@ -106,5 +119,6 @@ public class ViewOnDrawExecutor implements Executor, OnDrawListener, Runnable,
if (mLauncher != null) {
mLauncher.clearPendingExecutor(this);
}
+ LauncherModel.setWorkerPriority(Process.THREAD_PRIORITY_DEFAULT);
}
}