Example usage for android.support.v4.view WindowInsetsCompat getSystemWindowInsetTop

List of usage examples for android.support.v4.view WindowInsetsCompat getSystemWindowInsetTop

Introduction

In this page you can find the example usage for android.support.v4.view WindowInsetsCompat getSystemWindowInsetTop.

Prototype

public int getSystemWindowInsetTop() 

Source Link

Usage

From source file:meizhi.meizhi.malin.utils.WindowInsetsCompatUtil.java

@SuppressLint("RtlHardcoded")
private static WindowInsetsCompat copyExcluded(WindowInsetsCompat source, int gravity) {
    int l = (gravity & Gravity.LEFT) == Gravity.LEFT ? 0 : source.getSystemWindowInsetLeft();
    int t = (gravity & Gravity.TOP) == Gravity.TOP ? 0 : source.getSystemWindowInsetTop();
    int r = (gravity & Gravity.RIGHT) == Gravity.RIGHT ? 0 : source.getSystemWindowInsetRight();
    int b = (gravity & Gravity.BOTTOM) == Gravity.BOTTOM ? 0 : source.getSystemWindowInsetBottom();
    return source.replaceSystemWindowInsets(l, t, r, b);
}

From source file:ooo.oxo.mr.util.WindowInsetsCompatUtil.java

@SuppressLint("RtlHardcoded")
public static WindowInsetsCompat copyExcluded(WindowInsetsCompat source, int gravity) {
    int l = (gravity & Gravity.LEFT) == Gravity.LEFT ? 0 : source.getSystemWindowInsetLeft();
    int t = (gravity & Gravity.TOP) == Gravity.TOP ? 0 : source.getSystemWindowInsetTop();
    int r = (gravity & Gravity.RIGHT) == Gravity.RIGHT ? 0 : source.getSystemWindowInsetRight();
    int b = (gravity & Gravity.BOTTOM) == Gravity.BOTTOM ? 0 : source.getSystemWindowInsetBottom();
    return source.replaceSystemWindowInsets(l, t, r, b);
}

From source file:meizhi.meizhi.malin.widget.InsetsToolbar.java

public InsetsToolbar(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4.view.OnApplyWindowInsetsListener() {
        @Override//from www .j  a va 2s.com
        public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
            final int l = insets.getSystemWindowInsetLeft();
            final int t = insets.getSystemWindowInsetTop();
            final int r = insets.getSystemWindowInsetRight();
            setPadding(l, t, r, 0);
            return insets.consumeSystemWindowInsets();
        }
    });
}

From source file:net.xpece.android.widget.ScrimInsetsNonConsumingSelfPaddingNestedScrollView.java

protected void onInsetsChanged(WindowInsetsCompat insets) {
    setPadding(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(),
            insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom());
}

From source file:org.mariotaku.twidere.view.TintedStatusFrameLayout.java

public TintedStatusFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TintedStatusLayout);
    setSetPaddingEnabled(a.getBoolean(R.styleable.TintedStatusLayout_setPadding, false));
    a.recycle();//from  w  w  w .j av  a 2s  .  co m
    mColorPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mSystemWindowsInsets = new Rect();
    setWillNotDraw(false);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        setSystemUiVisibility(SYSTEM_UI_FLAG_LAYOUT_STABLE | SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
        ViewCompat.setOnApplyWindowInsetsListener(this,
                new android.support.v4.view.OnApplyWindowInsetsListener() {
                    @Override
                    public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
                        final int top = insets.getSystemWindowInsetTop();
                        final int left = insets.getSystemWindowInsetLeft();
                        final int right = insets.getSystemWindowInsetRight();
                        final int bottom = insets.getSystemWindowInsetBottom();
                        if (mSetPadding) {
                            setPadding(left, top, right, bottom);
                        }
                        setStatusBarHeight(top);
                        if (mWindowInsetsListener != null) {
                            mWindowInsetsListener.onApplyWindowInsets(left, top, right, bottom);
                        }
                        return insets.consumeSystemWindowInsets();
                    }
                });
    }
}

From source file:com.cqu.lightutils.widget.ScrimInsetsFrameLayout.java

public ScrimInsetsFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsFrameLayoutCompat,
            defStyleAttr, R.style.LightUtilsWidget_Design_ScrimInsetsFrameLayoutCompat);
    mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsFrameLayoutCompat_insetsForeground);
    a.recycle();// w ww. j a  va  2 s  .c  o  m
    setWillNotDraw(true); // No need to draw until the insets are adjusted

    ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4.view.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {

            mInsets.set(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(),
                    insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom());
            setWillNotDraw(mInsets.isEmpty() || mInsetForeground == null);
            ViewCompat.postInvalidateOnAnimation(ScrimInsetsFrameLayout.this);
            return insets.consumeSystemWindowInsets();
        }
    });
}

From source file:at.linuxtage.companion.widgets.ScrimInsetsFrameLayout.java

public ScrimInsetsFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsFrameLayout, defStyleAttr,
            R.style.Widget_Design_ScrimInsetsFrameLayout);
    mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsFrameLayout_insetForeground);
    a.recycle();/*from  w  ww . ja  v a2s . co  m*/
    setWillNotDraw(true); // No need to draw until the insets are adjusted
    ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4.view.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
            if (null == mInsets) {
                mInsets = new Rect();
            }
            mInsets.set(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(),
                    insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom());
            setWillNotDraw(mInsets.isEmpty() || mInsetForeground == null);
            ViewCompat.postInvalidateOnAnimation(ScrimInsetsFrameLayout.this);
            return insets.consumeSystemWindowInsets();
        }
    });
}

From source file:android.support.design.internal.ScrimInsetsRelativeLayout.java

public ScrimInsetsRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsFrameLayout, defStyleAttr,
            R.style.Widget_Design_ScrimInsetsFrameLayout);
    mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsFrameLayout_insetForeground);
    a.recycle();// ww w.  ja  v  a  2s. co m
    setWillNotDraw(true); // No need to draw until the insets are adjusted

    ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4.view.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
            if (null == mInsets) {
                mInsets = new Rect();
            }
            mInsets.set(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(),
                    insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom());
            setWillNotDraw(mInsets.isEmpty() || mInsetForeground == null);
            ViewCompat.postInvalidateOnAnimation(ScrimInsetsRelativeLayout.this);
            return insets.consumeSystemWindowInsets();
        }
    });
}

From source file:net.xpece.android.widget.ScrimInsetsNonConsumingChildPaddingFrameLayout.java

protected void onInsetsChanged(WindowInsetsCompat insets) {
    for (int i = 0, z = getChildCount(); i < z; i++) {
        final View child = getChildAt(i);
        child.setPadding(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(),
                insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom());
    }//from ww w .ja v a 2  s  .co m
}

From source file:android.support.design.internal.ScrimInsetsFrameLayout.java

public ScrimInsetsFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsFrameLayout, defStyleAttr,
            R.style.Widget_Design_ScrimInsetsFrameLayout);
    mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsFrameLayout_insetForeground);
    a.recycle();//from ww w.  j  av  a2  s .  c  o m
    setWillNotDraw(true); // No need to draw until the insets are adjusted

    ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4.view.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat 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(ScrimInsetsFrameLayout.this);
            return insets.consumeSystemWindowInsets();
        }
    });
}