From 1fde79244ed24a6ce9c4173df8adea2dd0095da4 Mon Sep 17 00:00:00 2001 From: Suphon Thanakornpakapong Date: Thu, 19 May 2022 00:49:57 +0700 Subject: [PATCH] Fix OnComputeInsetsListener --- .../system/ViewTreeObserverWrapper.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/SystemUIShared/src/com/android/systemui/shared/system/ViewTreeObserverWrapper.java b/SystemUIShared/src/com/android/systemui/shared/system/ViewTreeObserverWrapper.java index cfb23f9e4f..270bf5241c 100644 --- a/SystemUIShared/src/com/android/systemui/shared/system/ViewTreeObserverWrapper.java +++ b/SystemUIShared/src/com/android/systemui/shared/system/ViewTreeObserverWrapper.java @@ -21,6 +21,7 @@ import android.annotation.Nullable; import android.graphics.Rect; import android.graphics.Region; import android.view.ViewTreeObserver; +import android.view.ViewTreeObserver.InternalInsetsInfo; import android.view.ViewTreeObserver.OnComputeInternalInsetsListener; import java.util.HashMap; @@ -42,16 +43,19 @@ public class ViewTreeObserverWrapper { */ public static void addOnComputeInsetsListener( @NonNull ViewTreeObserver observer, @NonNull OnComputeInsetsListener listener) { - final OnComputeInternalInsetsListener internalListener = internalInOutInfo -> { - final InsetsInfo inOutInfo = new InsetsInfo(); - inOutInfo.contentInsets.set(internalInOutInfo.contentInsets); - inOutInfo.visibleInsets.set(internalInOutInfo.visibleInsets); - inOutInfo.touchableRegion.set(internalInOutInfo.touchableRegion); - listener.onComputeInsets(inOutInfo); - internalInOutInfo.contentInsets.set(inOutInfo.contentInsets); - internalInOutInfo.visibleInsets.set(inOutInfo.visibleInsets); - internalInOutInfo.touchableRegion.set(inOutInfo.touchableRegion); - internalInOutInfo.setTouchableInsets(inOutInfo.mTouchableInsets); + final OnComputeInternalInsetsListener internalListener = new OnComputeInternalInsetsListener() { + @Override + public void onComputeInternalInsets(InternalInsetsInfo internalInOutInfo) { + final InsetsInfo inOutInfo = new InsetsInfo(); + inOutInfo.contentInsets.set(internalInOutInfo.contentInsets); + inOutInfo.visibleInsets.set(internalInOutInfo.visibleInsets); + inOutInfo.touchableRegion.set(internalInOutInfo.touchableRegion); + listener.onComputeInsets(inOutInfo); + internalInOutInfo.contentInsets.set(inOutInfo.contentInsets); + internalInOutInfo.visibleInsets.set(inOutInfo.visibleInsets); + internalInOutInfo.touchableRegion.set(inOutInfo.touchableRegion); + internalInOutInfo.setTouchableInsets(inOutInfo.mTouchableInsets); + } }; sListenerObserverMap.put(listener, observer); sListenerInternalListenerMap.put(listener, internalListener);