From d7f302fb4e76742772902e89c9d8a483b5778afa Mon Sep 17 00:00:00 2001 From: Sunny Shao Date: Thu, 11 Nov 2021 15:10:59 +0800 Subject: [PATCH] Fix suw display size flicker problem - Swipe the preview area will invoke the OnGlobalLayoutListener. - Sometime it cause a flicker when scroll view scrolling up and preivew area swiping. - It is no need to scroll up if the height of scroll view does not change. Fixes: 205918748 Test: manual test Change-Id: I8ed5454d32f0cf2a7bc3bac45c7aa054ce929c4b --- .../AccessibilityScreenSizeForSetupWizardActivity.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/accessibility/AccessibilityScreenSizeForSetupWizardActivity.java b/src/com/android/settings/accessibility/AccessibilityScreenSizeForSetupWizardActivity.java index 7894c6e2789..10a0bce5c5a 100644 --- a/src/com/android/settings/accessibility/AccessibilityScreenSizeForSetupWizardActivity.java +++ b/src/com/android/settings/accessibility/AccessibilityScreenSizeForSetupWizardActivity.java @@ -63,6 +63,9 @@ public class AccessibilityScreenSizeForSetupWizardActivity extends InstrumentedA int SCREEN_SIZE = 2; } + // Keep the last height of the scroll view in the {@link GlifLayout} + private int mLastScrollViewHeight; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -143,11 +146,13 @@ public class AccessibilityScreenSizeForSetupWizardActivity extends InstrumentedA * Scrolls to bottom while {@link ScrollView} layout changed. */ private void scrollToBottom() { + mLastScrollViewHeight = 0; final GlifLayout layout = findViewById(R.id.setup_wizard_layout); final ScrollView scrollView = layout.getScrollView(); scrollView.getViewTreeObserver().addOnGlobalLayoutListener(() -> { final int scrollViewHeight = scrollView.getHeight(); - if (scrollViewHeight > 0) { + if (scrollViewHeight > 0 && scrollViewHeight != mLastScrollViewHeight) { + mLastScrollViewHeight = scrollViewHeight; scrollView.post(() -> { // Here is no need to show the scrolling animation. So disabled first and // then enabled it after scrolling finished.