Don't slide the toolbar up if we've scheduled a runnable to slide it up.

Bug: 78132954
Test: listnr
PiperOrigin-RevId: 193279654
Change-Id: I0d6e2e39d2f695b2e7d51ddf8c5abbc689187fbd
diff --git a/java/com/android/dialer/main/impl/toolbar/MainToolbar.java b/java/com/android/dialer/main/impl/toolbar/MainToolbar.java
index 5e5db2c..851d7a0 100644
--- a/java/com/android/dialer/main/impl/toolbar/MainToolbar.java
+++ b/java/com/android/dialer/main/impl/toolbar/MainToolbar.java
@@ -42,6 +42,7 @@
   private SearchBarListener listener;
   private MainToolbarMenu overflowMenu;
   private boolean isSlideUp;
+  private boolean hasGlobalLayoutListener;
 
   public MainToolbar(Context context, AttributeSet attrs) {
     super(context, attrs);
@@ -72,9 +73,20 @@
 
   /** Slides the toolbar up and off the screen. */
   public void slideUp(boolean animate, View container) {
+    if (hasGlobalLayoutListener) {
+      // Return early since we've already scheduled the toolbar to slide up
+      return;
+    }
+
     Assert.checkArgument(!isSlideUp);
     if (getHeight() == 0) {
-      ViewUtil.doOnGlobalLayout(this, view -> slideUp(animate, container));
+      hasGlobalLayoutListener = true;
+      ViewUtil.doOnGlobalLayout(
+          this,
+          view -> {
+            hasGlobalLayoutListener = false;
+            slideUp(animate, container);
+          });
       return;
     }
     isSlideUp = true;