android.view.WindowInsets#getSystemWindowInsetLeft ( )源码实例Demo

下面列出了android.view.WindowInsets#getSystemWindowInsetLeft ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: TelePlus-Android   文件: DrawerLayoutContainer.java
@SuppressLint("NewApi")
private void applyMarginInsets(MarginLayoutParams lp, Object insets, int drawerGravity, boolean topOnly)
{
    WindowInsets wi = (WindowInsets) insets;
    if (drawerGravity == Gravity.LEFT)
    {
        wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(), wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
    }
    else if (drawerGravity == Gravity.RIGHT)
    {
        wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(), wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
    }
    lp.leftMargin = wi.getSystemWindowInsetLeft();
    lp.topMargin = topOnly ? 0 : wi.getSystemWindowInsetTop();
    lp.rightMargin = wi.getSystemWindowInsetRight();
    lp.bottomMargin = wi.getSystemWindowInsetBottom();
}
 
源代码2 项目: TelePlus-Android   文件: DrawerLayoutContainer.java
@SuppressLint("NewApi")
private void applyMarginInsets(MarginLayoutParams lp, Object insets, int drawerGravity, boolean topOnly)
{
    WindowInsets wi = (WindowInsets) insets;
    if (drawerGravity == Gravity.LEFT)
    {
        wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(), wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
    }
    else if (drawerGravity == Gravity.RIGHT)
    {
        wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(), wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
    }
    lp.leftMargin = wi.getSystemWindowInsetLeft();
    lp.topMargin = topOnly ? 0 : wi.getSystemWindowInsetTop();
    lp.rightMargin = wi.getSystemWindowInsetRight();
    lp.bottomMargin = wi.getSystemWindowInsetBottom();
}
 
源代码3 项目: Interessant   文件: InsetsDrawerLayout.java
@Override
public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
    int l = insets.getSystemWindowInsetLeft();
    int t = insets.getSystemWindowInsetTop();
    int r = insets.getSystemWindowInsetRight();

    toolbar.setPadding(l, toolbar.getPaddingTop() + t, 0, 0);

    final boolean ltr = recyclerView.getLayoutDirection() == View.LAYOUT_DIRECTION_LTR;

    setPadding(getPaddingLeft(), getPaddingTop(), getPaddingEnd() + (ltr ? r : 0),
            getPaddingBottom()
    );

    setOnApplyWindowInsetsListener(null);
    return insets.consumeSystemWindowInsets();
}
 
@TargetApi(Build.VERSION_CODES.KITKAT_WATCH)
public WindowInsets onApplyWindowInsets(@Nullable WindowInsets insets) {
    if (insets != null) {
        mInsets = new Rect(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(),
                insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom());
    }

    for (int i = 0; i < mView.getChildCount(); i++) {
        final View child = mView.getChildAt(i);

        if (!(child instanceof InsetsDispatchReceiver)) {
            InsetsDispatcherLayoutParamsHelper helper = ((InsetsDispatcherLayoutParams) child.getLayoutParams()).getHelper();
            if (helper != null) {
                applyInsets(mInsets, child, helper.useLeftInset, helper.useTopInset, helper.useRightInset, helper.useBottomInset, helper.insetsUseMargin);
            } else {
                applyInsets(mInsets, child, false, false, false, false, false);
            }
        }
    }

    applyInsets(mInsets, mView, mUseLeftInset, mUseTopInset, mUseRightInset, mUseBottomInset, mInsetsUseMargin);

    ViewCompat.postInvalidateOnAnimation(mView);

    return insets;
}
 
源代码5 项目: Telegram-FOSS   文件: DrawerLayoutContainer.java
@Override
protected void onDraw(Canvas canvas) {
    if (Build.VERSION.SDK_INT >= 21 && lastInsets != null) {
        WindowInsets insets = (WindowInsets) lastInsets;

        if (!SharedConfig.smoothKeyboard) {
            int bottomInset = insets.getSystemWindowInsetBottom();
            if (bottomInset > 0) {
                backgroundPaint.setColor(behindKeyboardColor);
                canvas.drawRect(0, getMeasuredHeight() - bottomInset, getMeasuredWidth(), getMeasuredHeight(), backgroundPaint);
            }
        }

        if (hasCutout) {
            backgroundPaint.setColor(0xff000000);
            int left = insets.getSystemWindowInsetLeft();
            if (left != 0) {
                canvas.drawRect(0, 0, left, getMeasuredHeight(), backgroundPaint);
            }
            int right = insets.getSystemWindowInsetRight();
            if (right != 0) {
                canvas.drawRect(right, 0, getMeasuredWidth(), getMeasuredHeight(), backgroundPaint);
            }
        }
    }
}
 
源代码6 项目: Telegram   文件: DrawerLayoutContainer.java
@Override
protected void onDraw(Canvas canvas) {
    if (Build.VERSION.SDK_INT >= 21 && lastInsets != null) {
        WindowInsets insets = (WindowInsets) lastInsets;

        if (!SharedConfig.smoothKeyboard) {
            int bottomInset = insets.getSystemWindowInsetBottom();
            if (bottomInset > 0) {
                backgroundPaint.setColor(behindKeyboardColor);
                canvas.drawRect(0, getMeasuredHeight() - bottomInset, getMeasuredWidth(), getMeasuredHeight(), backgroundPaint);
            }
        }

        if (hasCutout) {
            backgroundPaint.setColor(0xff000000);
            int left = insets.getSystemWindowInsetLeft();
            if (left != 0) {
                canvas.drawRect(0, 0, left, getMeasuredHeight(), backgroundPaint);
            }
            int right = insets.getSystemWindowInsetRight();
            if (right != 0) {
                canvas.drawRect(right, 0, getMeasuredWidth(), getMeasuredHeight(), backgroundPaint);
            }
        }
    }
}
 
@Override
public WindowInsets onApplyWindowInsets(WindowInsets insets) {

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {

        mInsets[0] = insets.getSystemWindowInsetLeft();
        mInsets[1] = insets.getSystemWindowInsetTop();
        mInsets[2] = insets.getSystemWindowInsetRight();

        return super.onApplyWindowInsets(insets.replaceSystemWindowInsets(0, 0, 0, insets.getSystemWindowInsetBottom()));
    }
    else {
        return super.onApplyWindowInsets(insets);
    }
}
 
public static void applyMarginInsets(ViewGroup.MarginLayoutParams lp, Object insets,
        int gravity) {
    WindowInsets wi = (WindowInsets) insets;
    if (gravity == Gravity.LEFT) {
        wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(),
                wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
    } else if (gravity == Gravity.RIGHT) {
        wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(),
                wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
    }
    lp.leftMargin = wi.getSystemWindowInsetLeft();
    lp.topMargin = wi.getSystemWindowInsetTop();
    lp.rightMargin = wi.getSystemWindowInsetRight();
    lp.bottomMargin = wi.getSystemWindowInsetBottom();
}
 
源代码9 项目: ExoMedia   文件: FitsSystemWindowRelativeLayout.java
@Override
@TargetApi(Build.VERSION_CODES.KITKAT_WATCH)
public WindowInsets onApplyWindowInsets(WindowInsets insets) {
    Rect windowInsets = new Rect(
            insets.getSystemWindowInsetLeft(),
            insets.getSystemWindowInsetTop(),
            insets.getSystemWindowInsetRight(),
            insets.getSystemWindowInsetBottom()
    );

    fitSystemWindows(windowInsets);
    return insets;
}
 
源代码10 项目: Dashchan   文件: DrawerLayout.java
@Override
public void applyMarginInsets(MarginLayoutParams lp, Object insets, int drawerGravity) {
	WindowInsets wi = (WindowInsets) insets;
	if (drawerGravity == Gravity.LEFT) {
		wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(),
				wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
	} else if (drawerGravity == Gravity.RIGHT) {
		wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(),
				wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
	}
	lp.leftMargin = wi.getSystemWindowInsetLeft();
	lp.topMargin = wi.getSystemWindowInsetTop();
	lp.rightMargin = wi.getSystemWindowInsetRight();
	lp.bottomMargin = wi.getSystemWindowInsetBottom();
}
 
public static void applyMarginInsets(ViewGroup.MarginLayoutParams lp, Object insets,
        int gravity) {
    WindowInsets wi = (WindowInsets) insets;
    if (gravity == Gravity.LEFT) {
        wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(),
                wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
    } else if (gravity == Gravity.RIGHT) {
        wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(),
                wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
    }
    lp.leftMargin = wi.getSystemWindowInsetLeft();
    lp.topMargin = wi.getSystemWindowInsetTop();
    lp.rightMargin = wi.getSystemWindowInsetRight();
    lp.bottomMargin = wi.getSystemWindowInsetBottom();
}
 
源代码12 项目: debugdrawer   文件: DrawerLayoutCompatApi21.java
public static void applyMarginInsets(ViewGroup.MarginLayoutParams lp, Object insets,
                                     int gravity) {
	WindowInsets wi = (WindowInsets) insets;
	if (gravity == Gravity.LEFT) {
		wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(),
				wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
	} else if (gravity == Gravity.RIGHT) {
		wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(),
				wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
	}
	lp.leftMargin = wi.getSystemWindowInsetLeft();
	lp.topMargin = wi.getSystemWindowInsetTop();
	lp.rightMargin = wi.getSystemWindowInsetRight();
	lp.bottomMargin = wi.getSystemWindowInsetBottom();
}
 
源代码13 项目: Telegram-FOSS   文件: DrawerLayoutContainer.java
@SuppressLint("NewApi")
private void applyMarginInsets(MarginLayoutParams lp, Object insets, int drawerGravity, boolean topOnly) {
    WindowInsets wi = (WindowInsets) insets;
    if (drawerGravity == Gravity.LEFT) {
        wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(), wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
    } else if (drawerGravity == Gravity.RIGHT) {
        wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(), wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
    }
    lp.leftMargin = wi.getSystemWindowInsetLeft();
    lp.topMargin = topOnly ? 0 : wi.getSystemWindowInsetTop();
    lp.rightMargin = wi.getSystemWindowInsetRight();
    lp.bottomMargin = wi.getSystemWindowInsetBottom();
}
 
源代码14 项目: u2020   文件: DrawerLayoutCompatApi21.java
public static void applyMarginInsets(ViewGroup.MarginLayoutParams lp, Object insets,
    int gravity) {
  WindowInsets wi = (WindowInsets) insets;
  if (gravity == Gravity.LEFT) {
    wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(),
        wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
  } else if (gravity == Gravity.RIGHT) {
    wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(),
        wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
  }
  lp.leftMargin = wi.getSystemWindowInsetLeft();
  lp.topMargin = wi.getSystemWindowInsetTop();
  lp.rightMargin = wi.getSystemWindowInsetRight();
  lp.bottomMargin = wi.getSystemWindowInsetBottom();
}
 
源代码15 项目: Telegram   文件: DrawerLayoutContainer.java
@SuppressLint("NewApi")
private void applyMarginInsets(MarginLayoutParams lp, Object insets, int drawerGravity, boolean topOnly) {
    WindowInsets wi = (WindowInsets) insets;
    if (drawerGravity == Gravity.LEFT) {
        wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(), wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
    } else if (drawerGravity == Gravity.RIGHT) {
        wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(), wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
    }
    lp.leftMargin = wi.getSystemWindowInsetLeft();
    lp.topMargin = topOnly ? 0 : wi.getSystemWindowInsetTop();
    lp.rightMargin = wi.getSystemWindowInsetRight();
    lp.bottomMargin = wi.getSystemWindowInsetBottom();
}