Fix flash when switching from app window to snapshot.

- If there is any delay in launcher draw, then we will finish the
  transition and hide the app window before launcher has had a chance to
  draw the task view with the updated snapshot.

Change-Id: I81c5b467f32520fd7474bde0e89819336292e84f
This commit is contained in:
Winson Chung
2018-02-22 15:05:41 -08:00
parent 79f40becb3
commit a7843583be
3 changed files with 69 additions and 21 deletions

View File

@@ -49,9 +49,16 @@ public class ViewOnDrawExecutor implements Executor, OnDrawListener, Runnable,
}
public void attachTo(Launcher launcher) {
attachTo(launcher, launcher.getWorkspace(), true /* waitForLoadAnimation */);
}
public void attachTo(Launcher launcher, View attachedView, boolean waitForLoadAnimation) {
mLauncher = launcher;
mAttachedView = launcher.getWorkspace();
mAttachedView = attachedView;
mAttachedView.addOnAttachStateChangeListener(this);
if (!waitForLoadAnimation) {
mLoadAnimationCompleted = true;
}
attachObserver();
}
@@ -74,7 +81,7 @@ public class ViewOnDrawExecutor implements Executor, OnDrawListener, Runnable,
}
@Override
public void onViewDetachedFromWindow(View v) { }
public void onViewDetachedFromWindow(View v) {}
@Override
public void onDraw() {
@@ -101,10 +108,7 @@ public class ViewOnDrawExecutor implements Executor, OnDrawListener, Runnable,
// 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);
}
markCompleted();
runAllTasks();
}
}
@@ -121,4 +125,15 @@ public class ViewOnDrawExecutor implements Executor, OnDrawListener, Runnable,
}
LauncherModel.setWorkerPriority(Process.THREAD_PRIORITY_DEFAULT);
}
protected boolean isCompleted() {
return mCompleted;
}
protected void runAllTasks() {
for (final Runnable r : mTasks) {
mExecutor.execute(r);
}
markCompleted();
}
}