mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 00:06:47 +00:00
Adding SecondaryDisplayLauncher in Launcher using common listener
Bug: 141596722 Change-Id: I480bfadf592f7d0309f17c33a3fe14bb77fb5586
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user