Java Code Examples for android.view.Window#getContext()

The following examples show how to use android.view.Window#getContext() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WindowInsetsUtils.java    From MobileInfo with Apache License 2.0 6 votes vote down vote up
/**
 * XIAOMI刘海屏高度
 *
 * @param window
 * @return
 */
private static int getNotchHeightOfXiaoMi(Window window) {
    if (!isNotchScreenOfXiaoMi(window)) {
        return 0;
    }

    int result = 0;
    try {
        Context context = window.getContext();
        if (isHideNotch(window.getContext())) {
            result = getStatusBarHeight(context);
        } else {
            result = getRealNotchHeight(context);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return result;
}
 
Example 2
Source File: StatusBarKitkatImpl.java    From status-bar-compat with Apache License 2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.KITKAT)
@Override
public void setStatusBarColor(Window window, int color) {
    window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

    ViewGroup decorViewGroup = (ViewGroup) window.getDecorView();
    View statusBarView = decorViewGroup.findViewWithTag(STATUS_BAR_VIEW_TAG);
    if (statusBarView == null) {
        statusBarView = new StatusBarView(window.getContext());
        statusBarView.setTag(STATUS_BAR_VIEW_TAG);
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
                FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
        params.gravity = Gravity.TOP;
        statusBarView.setLayoutParams(params);
        decorViewGroup.addView(statusBarView);
    }
    statusBarView.setBackgroundColor(color);
    StatusBarCompat.internalSetFitsSystemWindows(window, true);
}
 
Example 3
Source File: UndoBar.java    From Android-UndoBar with MIT License 5 votes vote down vote up
/**
 * Creates a new undo bar instance to be displayed in the given {@link Window}.
 * <p/>
 * The style forces the the undo bar to match the look and feel of a certain API level.<br>
 * By default, it uses the style of the device's current API level.
 * <p/>
 * This is useful, for example, if you want to show a consistent
 * Lollipop style across all API levels.
 */
public UndoBar(Window window, Style style) {
    if (style == null) {
        style = Style.DEFAULT;
    }

    mContext = window.getContext();
    mStyle = style;
    mView = getView(window);
    mView.setOnUndoClickListener(mOnUndoClickListener);
    mViewCompat = new ViewCompatImpl(mView);

    hide(false);
}