com.blankj.utilcode.util.BarUtils Java Examples

The following examples show how to use com.blankj.utilcode.util.BarUtils. 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: MemberTopicFragment.java    From V2EX with GNU General Public License v3.0 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                         @Nullable Bundle savedInstanceState) {
    if (savedView !=null){
        return savedView;
    }
    savedView = inflater.inflate(R.layout.frag_member_topic, container, false);
    ButterKnife.bind(this, savedView);

    mRecyclerViewAdapter = new TopicRecyclerViewAdapter(getContext(), mTopics);
    mRecyclerViewAdapter.setBottomPadding(BarUtils.getNavBarHeight());
    mRecyclerViewAdapter.setIsSimpleView(true);
    LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    mRvTopics.setLayoutManager(layoutManager);
    mRvTopics.setNestedScrollingEnabled(false);
    mRvTopics.setAdapter(mRecyclerViewAdapter);

    mSwipeRefreshLayout.setOnRefreshListener(this::onRefresh);
    mSwipeRefreshLayout.setRefreshing(true);
    setSwipeRefreshTheme(mSwipeRefreshLayout);
    onRefresh();
    return savedView;
}
 
Example #2
Source File: BaseActivity.java    From Android-IM with Apache License 2.0 6 votes vote down vote up
@Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        BarUtils.setNavBarImmersive(this);
//        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N){
//            try {
//                Class decorViewClazz = Class.forName("com.android.internal.policy.DecorView");
//                Field field = decorViewClazz.getDeclaredField("mSemiTransparentStatusBarColor");
//                field.setAccessible(true);
//                field.setInt(getWindow().getDecorView(), Color.TRANSPARENT);  //改为透明
//            } catch (Exception e) {}
//        }
        setContentView(rootContentView());
        ButterKnife.bind(this);
        new SystemStatusManager(this).setTranslucentStatus(R.drawable.shape_titlebar);
        JMessageClient.registerEventReceiver(this);
        mContext = BaseActivity.this;
        helper=SharedPrefHelper.getInstance();
        initView();
        initData();
    }
 
Example #3
Source File: FragmentHitokoto.java    From Pixiv-Shaft with MIT License 5 votes vote down vote up
@Override
void initData() {
    BarUtils.setNavBarColor(mActivity, getResources().getColor(R.color.hito_bg));
    baseBind.next.setOnClickListener(v -> freshData());
    baseBind.hitoText.setOnLongClickListener(v -> {
        ClipBoardUtils.putTextIntoClipboard(mContext, baseBind.hitoText.getText().toString());
        return true;
    });
    baseBind.like.setOnClickListener(v -> Common.showToast("下版本更新再做吧?"));
    freshData();
}
 
Example #4
Source File: ImageDetailActivity.java    From Pixiv-Shaft with MIT License 5 votes vote down vote up
@Override
protected int initLayout() {
    BarUtils.setStatusBarColor(this, ColorUtils.getColor(R.color.qmui_config_color_transparent));
    if (BarUtils.isSupportNavBar()) {
        BarUtils.setNavBarVisibility(this, false);
    }
    return R.layout.activity_image_detail;
}
 
Example #5
Source File: BaseActivity.java    From Pixiv-Shaft with MIT License 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mLayoutID = initLayout();

    mContext = this;
    mActivity = this;

    Intent intent = getIntent();
    if (intent != null) {
        Bundle bundle = intent.getExtras();
        if (bundle != null) {
            initBundle(bundle);
        }
    }

    if (hideStatusBar()) {
        getWindow().setStatusBarColor(Color.TRANSPARENT);
        getWindow().getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
                        View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
    }

    baseBind = DataBindingUtil.setContentView(mActivity, mLayoutID);
    BarUtils.setNavBarColor(mActivity, getResources().getColor(R.color.trans));


    initView();
    initData();
}
 
Example #6
Source File: DetailAudioFragment.java    From YCAudioPlayer with Apache License 2.0 5 votes vote down vote up
private void initToolBar() {
    int statusBarHeight = BarUtils.getStatusBarHeight();
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, SizeUtils.dp2px(50));
    params.topMargin = statusBarHeight;
    toolbar.setLayoutParams(params);
}
 
Example #7
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 #8
Source File: TopicFragment.java    From V2EX with GNU General Public License v3.0 5 votes vote down vote up
@Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        if (this.savedView != null)
            return savedView;

        savedView = inflater.inflate(R.layout.frag_topic, container,false);

        ButterKnife.bind(this, savedView);
        LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);

//        recyclerView.setRecycledViewPool(sRecyclerViewPool);
        recyclerView.setFocusableInTouchMode(false);
        recyclerView.setFocusable(false);
        recyclerView.setLayoutManager(layoutManager);
        recyclerView.setHasFixedSize(true);
        recyclerView.setDrawingCacheEnabled(true);
        recyclerView.setDrawingCacheQuality(RecyclerView.DRAWING_CACHE_QUALITY_LOW);
        mAdapter = new PullRefreshReplyAdapter(getContext(),
                new TopicRecyclerViewAdapter(getContext(), topics));
        mAdapter.setBottomPadding(BarUtils.getNavBarHeight());

        recyclerView.setAdapter(mAdapter);
        swipeRefreshLayout.setOnRefreshListener(this::onRefresh);

        setSwipeRefreshTheme(swipeRefreshLayout);
        swipeRefreshLayout.setRefreshing(true);
        if (mTabType.getType() == TabEnum.NODE){
            mAdapter.setOnPullUpListener(() -> {
                mCurrentPage ++;
                TopicService.getTopicByNode(this, mTabType.getTitle(),
                        mCurrentPage, mResponseListener);
            });
        }else{
            mAdapter.setStatus(PullRefreshReplyAdapter.FooterStatus.COMPLETE);
        }
        return savedView;
    }
 
Example #9
Source File: LoadingActivity.java    From Android-IM with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_loading);
    BarUtils.setNotificationBarVisibility(false);
    BarUtils.setStatusBarVisibility(this,false);
    initView();
}
 
Example #10
Source File: CommonActivityTitleView.java    From AndroidUtilCode with Apache License 2.0 5 votes vote down vote up
public View getContentView() {
    baseTitleRootLayout = mBaseActivity.findViewById(R.id.baseTitleRootLayout);
    baseTitleToolbar = mBaseActivity.findViewById(R.id.baseTitleToolbar);
    if (mIsSupportScroll) {
        mViewStub = mBaseActivity.findViewById(R.id.baseTitleStubScroll);
    } else {
        mViewStub = mBaseActivity.findViewById(R.id.baseTitleStubNoScroll);
    }
    mViewStub.setVisibility(View.VISIBLE);
    baseTitleContentView = mBaseActivity.findViewById(R.id.commonTitleContentView);
    setTitleBar();
    BarUtils.setStatusBarColor(mBaseActivity, ColorUtils.getColor(R.color.colorPrimary));
    BarUtils.addMarginTopEqualStatusBarHeight(baseTitleRootLayout);
    return baseTitleContentView;
}
 
Example #11
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;
}