Skip to content

Commit ca46cd8

Browse files
pubiqqpekingme
authored andcommitted
[Catalog] Fix BottomWindowInsetView
Resolves #4700 Resolves #4699 GIT_ORIGIN_REV_ID=c0dc162ad0e67a7f8f4477fece5e4bdd6cd4ce90 PiperOrigin-RevId: 757914922
1 parent 6b35213 commit ca46cd8

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

catalog/java/io/material/catalog/feature/BottomWindowInsetView.java

+6-12
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020
import android.content.Context;
2121
import android.util.AttributeSet;
2222
import android.view.View;
23-
import android.view.ViewGroup;
2423
import androidx.annotation.Nullable;
24+
import androidx.core.graphics.Insets;
2525
import androidx.core.view.ViewCompat;
26+
import androidx.core.view.WindowInsetsCompat;
2627

2728
/**
2829
* A View that measures itself to be as tall as the bottom window inset.
@@ -48,19 +49,12 @@ public BottomWindowInsetView(Context context, @Nullable AttributeSet attrs,
4849
@Override
4950
protected void onAttachedToWindow() {
5051
super.onAttachedToWindow();
51-
ViewGroup parent = (ViewGroup) getParent();
52-
while (parent != null && !parent.getFitsSystemWindows()) {
53-
parent = (ViewGroup) parent.getParent();
54-
}
55-
56-
if (parent == null) {
57-
return;
58-
}
59-
6052
ViewCompat.setOnApplyWindowInsetsListener(
61-
parent,
53+
this,
6254
(v, insets) -> {
63-
systemWindowInsetBottom = insets.getSystemWindowInsetBottom();
55+
Insets systemWindowInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars());
56+
systemWindowInsetBottom = systemWindowInsets.bottom;
57+
6458
super.setVisibility(systemWindowInsetBottom == 0 ? GONE : VISIBLE);
6559
if (systemWindowInsetBottom > 0) {
6660
requestLayout();

0 commit comments

Comments
 (0)