Adding SecondaryDisplayLauncher in Launcher using common listener

Bug: 141596722
Change-Id: I480bfadf592f7d0309f17c33a3fe14bb77fb5586
This commit is contained in:
Sunny Goyal
2020-01-07 13:07:55 -08:00
parent ae5e991f5e
commit 9c2b96090b
33 changed files with 1369 additions and 255 deletions

View File

@@ -29,6 +29,7 @@ import com.android.launcher3.Launcher;
import java.util.ArrayList;
import java.util.concurrent.Executor;
import java.util.function.Consumer;
/**
* An executor which runs all the tasks after the first onDraw is called on the target view.
@@ -38,7 +39,7 @@ public class ViewOnDrawExecutor implements Executor, OnDrawListener, Runnable,
private final ArrayList<Runnable> mTasks = new ArrayList<>();
private Launcher mLauncher;
private Consumer<ViewOnDrawExecutor> mOnClearCallback;
private View mAttachedView;
private boolean mCompleted;
@@ -46,11 +47,16 @@ public class ViewOnDrawExecutor implements Executor, OnDrawListener, Runnable,
private boolean mFirstDrawCompleted;
public void attachTo(Launcher launcher) {
attachTo(launcher, launcher.getWorkspace(), true /* waitForLoadAnimation */);
attachTo(launcher.getWorkspace(), true /* waitForLoadAnimation */,
launcher::clearPendingExecutor);
}
public void attachTo(Launcher launcher, View attachedView, boolean waitForLoadAnimation) {
mLauncher = launcher;
/**
* Attached the executor to the existence of the view
*/
public void attachTo(View attachedView, boolean waitForLoadAnimation,
Consumer<ViewOnDrawExecutor> onClearCallback) {
mOnClearCallback = onClearCallback;
mAttachedView = attachedView;
mAttachedView.addOnAttachStateChangeListener(this);
if (!waitForLoadAnimation) {
@@ -110,8 +116,8 @@ public class ViewOnDrawExecutor implements Executor, OnDrawListener, Runnable,
mAttachedView.getViewTreeObserver().removeOnDrawListener(this);
mAttachedView.removeOnAttachStateChangeListener(this);
}
if (mLauncher != null) {
mLauncher.clearPendingExecutor(this);
if (mOnClearCallback != null) {
mOnClearCallback.accept(this);
}
MODEL_EXECUTOR.setThreadPriority(Process.THREAD_PRIORITY_DEFAULT);
}