public DrawerScrimInsetsFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
final TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.DrawerScrimInsetsFrameLayout, defStyleAttr,
R.style.Widget_Drawer_DrawerScrimInsetsFrameLayout);
mInsetForeground = a.getDrawable(R.styleable.DrawerScrimInsetsFrameLayout_insetForeground);
a.recycle();
setWillNotDraw(true);
ViewCompat.setOnApplyWindowInsetsListener(this,
(v, insets) -> {
if (null == mInsets) {
mInsets = new Rect();
}
mInsets.set(insets.getSystemWindowInsetLeft(),
insets.getSystemWindowInsetTop(),
insets.getSystemWindowInsetRight(),
insets.getSystemWindowInsetBottom());
onInsetsChanged(insets);
setWillNotDraw(!insets.hasSystemWindowInsets() || mInsetForeground == null);
ViewCompat.postInvalidateOnAnimation(DrawerScrimInsetsFrameLayout.this);
return insets.consumeSystemWindowInsets();
});
}