diff options
author | Tony Wickham <twickham@google.com> | 2017-08-04 18:52:59 +0000 |
---|---|---|
committer | Tony Wickham <twickham@google.com> | 2017-08-04 18:52:59 +0000 |
commit | cebcfbce9433c407e495cf5956ed4a77482c6c71 (patch) | |
tree | d5f567ede12284620861950d11293f4ef7810c85 /src/com/android/launcher3/util | |
parent | c1c54a9a18b89d0e34fdeece7ff7cba4f40d5c96 (diff) | |
parent | 2917a8bf2b83c0d17400b1475f01a9a8d9137f62 (diff) | |
download | android_packages_apps_Trebuchet-cebcfbce9433c407e495cf5956ed4a77482c6c71.tar.gz android_packages_apps_Trebuchet-cebcfbce9433c407e495cf5956ed4a77482c6c71.tar.bz2 android_packages_apps_Trebuchet-cebcfbce9433c407e495cf5956ed4a77482c6c71.zip |
[automerger] Defer some work until after workspace fade-in am: 2917a8bf2b
Change-Id: Ibd5f3343a58158376576853b139a8dd3e5b98e26
Diffstat (limited to 'src/com/android/launcher3/util')
-rw-r--r-- | src/com/android/launcher3/util/ViewOnDrawExecutor.java | 14 |
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); } } |