Java Code Examples for com.blankj.utilcode.util.BarUtils#getNavBarHeight()

The following examples show how to use com.blankj.utilcode.util.BarUtils#getNavBarHeight() . 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: BaseActivity.java    From V2EX with GNU General Public License v3.0 5 votes vote down vote up
@Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // 未捕获的异常, 记录错误上传
//        UnexpectedExceptionHandler.getInstance().init();

        mStatusBarHeight = BarUtils.getStatusBarHeight();
        mNavBarHeight = BarUtils.getNavBarHeight();
        setTheme();
    }
 
Example 2
Source File: NormalDokitViewManager.java    From DoraemonKit with Apache License 2.0 4 votes vote down vote up
/**
 * @return rootView
 */
private FrameLayout getDokitRootContentView(final Activity activity, FrameLayout decorView) {
    FrameLayout dokitRootView = decorView.findViewById(R.id.dokit_contentview_id);
    if (dokitRootView != null) {
        return dokitRootView;
    }

    dokitRootView = new DokitFrameLayout(mContext);
    //普通模式的返回按键监听
    dokitRootView.setOnKeyListener(new View.OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            //LogHelper.i(TAG, "keyCode===>" + keyCode + " " + v.getClass().getSimpleName());
            //监听返回键
            if (keyCode == KeyEvent.KEYCODE_BACK) {
                Map<String, AbsDokitView> dokitViews = getDokitViews(activity);
                if (dokitViews == null || dokitViews.size() == 0) {
                    return false;
                }
                for (AbsDokitView dokitView : dokitViews.values()) {
                    if (dokitView.shouldDealBackKey()) {
                        return dokitView.onBackPressed();
                    }
                }
                return false;
            }
            return false;
        }
    });
    dokitRootView.setClipChildren(false);
    //解决无法获取返回按键的问题
    dokitRootView.setFocusable(true);
    dokitRootView.setFocusableInTouchMode(true);
    dokitRootView.requestFocus();
    dokitRootView.setId(R.id.dokit_contentview_id);
    FrameLayout.LayoutParams dokitParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    try {
        //解决由于项目集成SwipeBackLayout而出现的dokit入口不显示
        if (BarUtils.isStatusBarVisible(activity)) {
            dokitParams.topMargin = BarUtils.getStatusBarHeight();
        }
        if (BarUtils.isSupportNavBar()) {
            if (BarUtils.isNavBarVisible(activity)) {
                dokitParams.bottomMargin = BarUtils.getNavBarHeight();
            }
        }
    } catch (Exception e) {
        //e.printStackTrace();
    }
    dokitRootView.setLayoutParams(dokitParams);
    //添加到DecorView中 为了不和用户自己往根布局中添加view干扰
    decorView.addView(dokitRootView);

    return dokitRootView;
}