mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-27 15:26:58 +00:00
Merge "Cleaning up some no-op calls during workspace binding" into main
This commit is contained in:
@@ -21,6 +21,7 @@ import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_OPTIMIZE_MEAS
|
||||
import static android.view.accessibility.AccessibilityEvent.TYPE_VIEW_FOCUSED;
|
||||
|
||||
import static com.android.app.animation.Interpolators.EMPHASIZED;
|
||||
import static com.android.launcher3.Flags.enablePredictiveBackGesture;
|
||||
import static com.android.launcher3.Flags.enableUnfoldStateAnimation;
|
||||
import static com.android.launcher3.LauncherConstants.SavedInstanceKeys.PENDING_SPLIT_SELECT_INFO;
|
||||
import static com.android.launcher3.LauncherConstants.SavedInstanceKeys.RUNTIME_STATE;
|
||||
@@ -61,7 +62,6 @@ import static com.android.quickstep.util.SplitAnimationTimings.TABLET_HOME_TO_SP
|
||||
import static com.android.quickstep.views.DesktopTaskView.isDesktopModeSupported;
|
||||
import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_HOME_KEY;
|
||||
import static com.android.wm.shell.common.split.SplitScreenConstants.SNAP_TO_50_50;
|
||||
import static com.android.launcher3.Flags.enablePredictiveBackGesture;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
@@ -1103,21 +1103,11 @@ public class QuickstepLauncher extends Launcher {
|
||||
// populating workspace.
|
||||
// TODO: Find a better place for this
|
||||
WellbeingModel.INSTANCE.get(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitialBindComplete(IntSet boundPages, RunnableList pendingTasks,
|
||||
int workspaceItemCount, boolean isBindSync) {
|
||||
pendingTasks.add(() -> {
|
||||
// This is added in pending task as we need to wait for views to be positioned
|
||||
// correctly before registering them for the animation.
|
||||
if (mLauncherUnfoldAnimationController != null) {
|
||||
// This is needed in case items are rebound while the unfold animation is in
|
||||
// progress.
|
||||
mLauncherUnfoldAnimationController.updateRegisteredViewsIfNeeded();
|
||||
}
|
||||
});
|
||||
super.onInitialBindComplete(boundPages, pendingTasks, workspaceItemCount, isBindSync);
|
||||
if (mLauncherUnfoldAnimationController != null) {
|
||||
// This is needed in case items are rebound while the unfold animation is in progress.
|
||||
mLauncherUnfoldAnimationController.updateRegisteredViewsIfNeeded();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -237,7 +237,6 @@ import com.android.launcher3.util.Themes;
|
||||
import com.android.launcher3.util.Thunk;
|
||||
import com.android.launcher3.util.TouchController;
|
||||
import com.android.launcher3.util.TraceHelper;
|
||||
import com.android.launcher3.util.ViewOnDrawExecutor;
|
||||
import com.android.launcher3.views.ActivityContext;
|
||||
import com.android.launcher3.views.ComposeInitializer;
|
||||
import com.android.launcher3.views.FloatingIconView;
|
||||
@@ -2233,12 +2232,6 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
return info;
|
||||
}
|
||||
|
||||
public void clearPendingExecutor(ViewOnDrawExecutor executor) {
|
||||
if (mModelCallbacks.getPendingExecutor() == executor) {
|
||||
mModelCallbacks.setPendingExecutor(null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call back when ModelCallbacks finish binding the Launcher data.
|
||||
*/
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.android.launcher3
|
||||
import android.annotation.TargetApi
|
||||
import android.os.Build
|
||||
import android.os.Trace
|
||||
import android.view.ViewTreeObserver.OnDrawListener
|
||||
import androidx.annotation.UiThread
|
||||
import com.android.launcher3.LauncherConstants.TraceEvents
|
||||
import com.android.launcher3.WorkspaceLayoutManager.FIRST_SCREEN_ID
|
||||
@@ -18,7 +17,6 @@ import com.android.launcher3.model.data.LauncherAppWidgetInfo
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo
|
||||
import com.android.launcher3.popup.PopupContainerWithArrow
|
||||
import com.android.launcher3.util.ComponentKey
|
||||
import com.android.launcher3.util.Executors
|
||||
import com.android.launcher3.util.IntArray as LIntArray
|
||||
import com.android.launcher3.util.IntSet as LIntSet
|
||||
import com.android.launcher3.util.PackageUserKey
|
||||
@@ -77,11 +75,15 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks {
|
||||
workspaceItemCount: Int,
|
||||
isBindSync: Boolean
|
||||
) {
|
||||
if (Utilities.ATLEAST_S) {
|
||||
Trace.endAsyncSection(
|
||||
TraceEvents.DISPLAY_WORKSPACE_TRACE_METHOD_NAME,
|
||||
TraceEvents.DISPLAY_WORKSPACE_TRACE_COOKIE
|
||||
)
|
||||
}
|
||||
synchronouslyBoundPages = boundPages
|
||||
pagesToBindSynchronously = LIntSet()
|
||||
clearPendingBinds()
|
||||
val executor = ViewOnDrawExecutor(pendingTasks)
|
||||
pendingExecutor = executor
|
||||
if (!launcher.isInState(LauncherState.ALL_APPS)) {
|
||||
launcher.appsView.appsStore.enableDeferUpdates(AllAppsStore.DEFER_UPDATES_NEXT_DRAW)
|
||||
pendingTasks.add {
|
||||
@@ -90,24 +92,15 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks {
|
||||
)
|
||||
}
|
||||
}
|
||||
executor.onLoadAnimationCompleted()
|
||||
executor.attachTo(launcher)
|
||||
if (Utilities.ATLEAST_S) {
|
||||
Trace.endAsyncSection(
|
||||
TraceEvents.DISPLAY_WORKSPACE_TRACE_METHOD_NAME,
|
||||
TraceEvents.DISPLAY_WORKSPACE_TRACE_COOKIE
|
||||
)
|
||||
}
|
||||
launcher.bindComplete(workspaceItemCount, isBindSync)
|
||||
launcher.rootView.viewTreeObserver.addOnDrawListener(
|
||||
object : OnDrawListener {
|
||||
override fun onDraw() {
|
||||
Executors.MAIN_EXECUTOR.handler.postAtFrontOfQueue {
|
||||
launcher.rootView.getViewTreeObserver().removeOnDrawListener(this)
|
||||
}
|
||||
val executor =
|
||||
ViewOnDrawExecutor(pendingTasks) {
|
||||
if (pendingExecutor == it) {
|
||||
pendingExecutor = null
|
||||
}
|
||||
}
|
||||
)
|
||||
pendingExecutor = executor
|
||||
executor.attachTo(launcher)
|
||||
launcher.bindComplete(workspaceItemCount, isBindSync)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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