mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-28 15:56:49 +00:00
Cleaning up some no-op calls during workspace binding
Bug: 318539160 Flag: None Test: Manual Change-Id: Ida21d849a06ed9c0ebf5671214dd9ee8525288d3
This commit is contained in:
@@ -20,6 +20,8 @@ import android.view.View;
|
||||
import android.view.View.OnAttachStateChangeListener;
|
||||
import android.view.ViewTreeObserver.OnDrawListener;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.android.launcher3.Launcher;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
@@ -31,26 +33,23 @@ public class ViewOnDrawExecutor implements OnDrawListener, Runnable,
|
||||
OnAttachStateChangeListener {
|
||||
|
||||
private final RunnableList mTasks;
|
||||
|
||||
private Consumer<ViewOnDrawExecutor> mOnClearCallback;
|
||||
private final Consumer<ViewOnDrawExecutor> mOnClearCallback;
|
||||
private View mAttachedView;
|
||||
private boolean mCompleted;
|
||||
|
||||
private boolean mLoadAnimationCompleted;
|
||||
private boolean mFirstDrawCompleted;
|
||||
|
||||
private boolean mCancelled;
|
||||
|
||||
public ViewOnDrawExecutor(RunnableList tasks) {
|
||||
public ViewOnDrawExecutor(RunnableList tasks,
|
||||
@NonNull Consumer<ViewOnDrawExecutor> onClearCallback) {
|
||||
mTasks = tasks;
|
||||
mOnClearCallback = onClearCallback;
|
||||
}
|
||||
|
||||
public void attachTo(Launcher launcher) {
|
||||
mOnClearCallback = launcher::clearPendingExecutor;
|
||||
mAttachedView = launcher.getWorkspace();
|
||||
|
||||
mAttachedView.addOnAttachStateChangeListener(this);
|
||||
|
||||
if (mAttachedView.isAttachedToWindow()) {
|
||||
attachObserver();
|
||||
}
|
||||
@@ -77,17 +76,10 @@ public class ViewOnDrawExecutor implements OnDrawListener, Runnable,
|
||||
mAttachedView.post(this);
|
||||
}
|
||||
|
||||
public void onLoadAnimationCompleted() {
|
||||
mLoadAnimationCompleted = true;
|
||||
if (mAttachedView != null) {
|
||||
mAttachedView.post(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// Post the pending tasks after both onDraw and onLoadAnimationCompleted have been called.
|
||||
if (mLoadAnimationCompleted && mFirstDrawCompleted && !mCompleted) {
|
||||
// Post the pending tasks after first draw
|
||||
if (mFirstDrawCompleted && !mCompleted) {
|
||||
markCompleted();
|
||||
}
|
||||
}
|
||||
@@ -104,9 +96,8 @@ public class ViewOnDrawExecutor implements OnDrawListener, Runnable,
|
||||
mAttachedView.getViewTreeObserver().removeOnDrawListener(this);
|
||||
mAttachedView.removeOnAttachStateChangeListener(this);
|
||||
}
|
||||
if (mOnClearCallback != null) {
|
||||
mOnClearCallback.accept(this);
|
||||
}
|
||||
|
||||
mOnClearCallback.accept(this);
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
|
||||
Reference in New Issue
Block a user