From 9e22d509e878c2c2991061c11a2198a6e46e919e Mon Sep 17 00:00:00 2001 From: calderwoodra Date: Tue, 17 Apr 2018 16:49:07 -0700 Subject: 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 --- java/com/android/dialer/main/impl/toolbar/MainToolbar.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'java') diff --git a/java/com/android/dialer/main/impl/toolbar/MainToolbar.java b/java/com/android/dialer/main/impl/toolbar/MainToolbar.java index 5e5db2c8c..851d7a0b4 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 @@ public final class MainToolbar extends Toolbar implements PopupMenu.OnMenuItemCl 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 @@ public final class MainToolbar extends Toolbar implements PopupMenu.OnMenuItemCl /** 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; -- cgit v1.2.3