diff --git a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java index 012afb26cb..3652d2318f 100644 --- a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java +++ b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java @@ -742,7 +742,7 @@ public class WindowTransformSwipeHandler extends BaseSwipeInteractionHandler { if (taskView != null) { // Defer finishing the animation until the next launcher frame with the // new thumbnail - ViewOnDrawExecutor executor = new ViewOnDrawExecutor(mMainExecutor) { + ViewOnDrawExecutor executor = new ViewOnDrawExecutor() { @Override public void onViewDetachedFromWindow(View v) { if (!isCompleted()) { diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index b87511af9d..1d474da199 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -304,12 +304,11 @@ public class Launcher extends BaseActivity LauncherAppState app = LauncherAppState.getInstance(this); mOldConfig = new Configuration(getResources().getConfiguration()); + mModel = app.setLauncher(this); initDeviceProfile(app.getInvariantDeviceProfile()); mSharedPrefs = Utilities.getPrefs(this); mIsSafeModeEnabled = getPackageManager().isSafeMode(); - mModel = app.setLauncher(this); - mModelWriter = mModel.getWriter(mDeviceProfile.isVerticalBarLayout()); mIconCache = app.getIconCache(); mAccessibilityDelegate = new LauncherAccessibilityDelegate(this); @@ -434,6 +433,7 @@ public class Launcher extends BaseActivity display.getSize(mwSize); mDeviceProfile = mDeviceProfile.getMultiWindowProfile(this, mwSize); } + mModelWriter = mModel.getWriter(mDeviceProfile.isVerticalBarLayout()); } @Override diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java index a4d188f159..6646b78de4 100644 --- a/src/com/android/launcher3/LauncherModel.java +++ b/src/com/android/launcher3/LauncherModel.java @@ -444,11 +444,7 @@ public class LauncherModel extends BroadcastReceiver if (mCallbacks != null && mCallbacks.get() != null) { final Callbacks oldCallbacks = mCallbacks.get(); // Clear any pending bind-runnables from the synchronized load process. - mUiExecutor.execute(new Runnable() { - public void run() { - oldCallbacks.clearPendingBinds(); - } - }); + mUiExecutor.execute(oldCallbacks::clearPendingBinds); // If there is already one running, tell it to stop. stopLoader(); diff --git a/src/com/android/launcher3/model/LoaderResults.java b/src/com/android/launcher3/model/LoaderResults.java index 24e5b9c58c..5acc790b83 100644 --- a/src/com/android/launcher3/model/LoaderResults.java +++ b/src/com/android/launcher3/model/LoaderResults.java @@ -162,7 +162,7 @@ public class LoaderResults { // This ensures that the first screen is immediately visible (eg. during rotation) // In case of !validFirstPage, bind all pages one after other. final Executor deferredExecutor = - validFirstPage ? new ViewOnDrawExecutor(mUiExecutor) : mainExecutor; + validFirstPage ? new ViewOnDrawExecutor() : mainExecutor; mainExecutor.execute(new Runnable() { @Override diff --git a/src/com/android/launcher3/util/ViewOnDrawExecutor.java b/src/com/android/launcher3/util/ViewOnDrawExecutor.java index 34bdcc9377..acce308607 100644 --- a/src/com/android/launcher3/util/ViewOnDrawExecutor.java +++ b/src/com/android/launcher3/util/ViewOnDrawExecutor.java @@ -34,20 +34,14 @@ public class ViewOnDrawExecutor implements Executor, OnDrawListener, Runnable, OnAttachStateChangeListener { private final ArrayList mTasks = new ArrayList<>(); - private final Executor mExecutor; private Launcher mLauncher; private View mAttachedView; private boolean mCompleted; - private boolean mIsExecuting; private boolean mLoadAnimationCompleted; private boolean mFirstDrawCompleted; - public ViewOnDrawExecutor(Executor executor) { - mExecutor = executor; - } - public void attachTo(Launcher launcher) { attachTo(launcher, launcher.getWorkspace(), true /* waitForLoadAnimation */); } @@ -89,13 +83,6 @@ 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) { @@ -107,7 +94,6 @@ 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; runAllTasks(); } } @@ -115,7 +101,6 @@ 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); @@ -132,7 +117,7 @@ public class ViewOnDrawExecutor implements Executor, OnDrawListener, Runnable, protected void runAllTasks() { for (final Runnable r : mTasks) { - mExecutor.execute(r); + r.run(); } markCompleted(); }