Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.Nullable;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

/**
* A View that measures itself to be as tall as the bottom window inset.
Expand All @@ -48,19 +49,12 @@ public BottomWindowInsetView(Context context, @Nullable AttributeSet attrs,
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
ViewGroup parent = (ViewGroup) getParent();
while (parent != null && !parent.getFitsSystemWindows()) {
parent = (ViewGroup) parent.getParent();
}

if (parent == null) {
return;
}

ViewCompat.setOnApplyWindowInsetsListener(
parent,
this,
(v, insets) -> {
systemWindowInsetBottom = insets.getSystemWindowInsetBottom();
Insets systemWindowInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars());
systemWindowInsetBottom = systemWindowInsets.bottom;

super.setVisibility(systemWindowInsetBottom == 0 ? GONE : VISIBLE);
if (systemWindowInsetBottom > 0) {
requestLayout();
Expand Down