com.gyf.barlibrary.ImmersionBar Java Examples

The following examples show how to use com.gyf.barlibrary.ImmersionBar. 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: MainActivity.java    From music_player with Open Software License 3.0 6 votes vote down vote up
@Subscribe(threadMode = ThreadMode.MAIN)
    public void onMessageEvent(UIChangeEvent event) {
        FloatingActionButton floatingActionButton = (FloatingActionButton) findViewById(R.id.play_or_pause);
        switch (event.event) {
            case MyConstant.initialize:
                mLayout.setPanelHeight((int) (60 * getResources().getDisplayMetrics().density + 0.5f)+ImmersionBar.getNavigationBarHeight(MainActivity.this));
                random_play.hide();
                return;
            case MyConstant.pauseAction:
                floatingActionButton.setImageResource(R.drawable.ic_play_arrow_black_24dp);
                play_pause_button.setImageResource(R.drawable.ic_play_arrow_black_24dp);
                return;
            case MyConstant.playAction:
                floatingActionButton.setImageResource(R.drawable.ic_pause_black_24dp);
                play_pause_button.setImageResource(R.drawable.ic_pause_black_24dp);
                return;
            case MyConstant.mediaChangeAction:
                ChangeScrollingUpPanel(MyApplication.getPositionNow());
                return;
                //???
            case MyConstant.DestoryAction:
                this.finish();
//                MainActivity.this.onDestroy();
//                finish();
        }
    }
 
Example #2
Source File: PropertyFragment.java    From Upchain-wallet with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void onResume() {
    super.onResume();

    ImmersionBar.with(this)
            .titleBar(mToolbar, false)
            .navigationBarColor(R.color.colorPrimary)
            .init();

    tokensViewModel.prepare();

    // 更改货币单位
    if (!currency.equals(tokensViewModel.getCurrency())) {
        currency = tokensViewModel.getCurrency();
        if (currency.equals("CNY")) {
            tvTolalAsset.setText(R.string.property_total_assets_cny);
        } else {
            tvTolalAsset.setText(R.string.property_total_assets_usd);
        }
    }

}
 
Example #3
Source File: CreateWalletActivity.java    From Upchain-wallet with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();
    ImmersionBar.with(this)
            .titleBar(commonToolbar, false)
            .navigationBarColor(R.color.white)
            .init();


    boolean hasPermission = (ContextCompat.checkSelfPermission(this,
            Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED);
    if (!hasPermission) {
        ActivityCompat.requestPermissions(this,
                new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
                REQUEST_WRITE_STORAGE);
    }

}
 
Example #4
Source File: BaseAcitvity.java    From PocketEOS-Android with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SuppressLint("ResourceAsColor")
protected void initImmersionBar() {
    mImmersionBar = ImmersionBar.with(this);
    TextView textView = getId(R.id.tv_title);
    if (!activity.getLocalClassName().contains("Vote")) {
        if (textView != null) {
            if (textView.getCurrentTextColor() == -1) {
                mImmersionBar.fitsSystemWindows(true).statusBarColor(R.color.black_box_color);
                mImmersionBar.statusBarDarkFont(false, 0.2f);
            } else {
                mImmersionBar.fitsSystemWindows(true).statusBarColor(R.color.white);
                mImmersionBar.statusBarDarkFont(true, 0.2f);
            }
        }
    }else {
        mImmersionBar.fitsSystemWindows(true).statusBarColor(R.color.black);
        mImmersionBar.statusBarDarkFont(false, 0.2f);
    }

    mImmersionBar.keyboardEnable(true); //解决软键盘与底部输入框冲突问题;
    KeyboardPatch.patch(this).enable();
    mImmersionBar.init();
}
 
Example #5
Source File: HomeActivity.java    From TikTok with Apache License 2.0 6 votes vote down vote up
/**
 * 初始化沉浸式状态栏
 */
private ImmersionBar statusBarConfig() {
    //在BaseActivity里初始化
    mImmersionBar = ImmersionBar.with(this)
            .statusBarDarkFont(statusBarDarkFont())    //默认状态栏字体颜色为黑色
            .keyboardEnable(false, WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN
                    | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);  //解决软键盘与底部输入框冲突问题,默认为false,还有一个重载方法,可以指定软键盘mode
    //必须设置View树布局变化监听,否则软键盘无法顶上去,还有模式必须是SOFT_INPUT_ADJUST_PAN
    getWindow().getDecorView().getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {

        }
    });
    return mImmersionBar;
}
 
Example #6
Source File: QRCodeScannerActivity.java    From Upchain-wallet with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void configViews() {
    ImmersionBar.with(this)
            .titleBar(scannerToolbar, false)
            .navigationBarColor(R.color.colorPrimary)
            .init();


    rlFlashLight = (RelativeLayout) findViewById(R.id.rl_flash_light);
    rlFlashLight.setOnClickListener(this);

    llBack = (LinearLayout) findViewById(R.id.lly_back);
    llBack.setOnClickListener(this);


    findViewById(R.id.choose_qrcde_from_gallery).setOnClickListener(this);
}
 
Example #7
Source File: BaseActivity.java    From youqu_master with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    isConfigChange=false;
    mRxManager=new RxManager();
    doBeforeSetcontentView();
    setContentView(getLayoutId());

    if(isImmersionEnabled()){
        mImmersionBar = ImmersionBar.with(this);
        mImmersionBar .statusBarDarkFont(true)
                .keyboardEnable(true)  //解决软键盘与底部输入框冲突问题,默认为false,还有一个重载方法,可以指定软键盘mode
                .init();   //所有子类都将继承这些相同的属性
    }


    ButterKnife.bind(this);
    mContext = this;
    mPresenter = TUtil.getT(this, 0);
    mModel=TUtil.getT(this,1);
    if(mPresenter!=null){
        mPresenter.mContext=this;
    }
    this.initPresenter();
    this.initView();
}
 
Example #8
Source File: SplashActivity.java    From TikTok with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);
    ButterKnife.bind(this);
    ImmersionBar.with(this)
            .statusBarDarkFont(true)
            .transparentNavigationBar()//透明导航栏,不写默认黑色(设置此方法,fullScreen()方法自动为true)
            .init();   //默认状态栏字体颜色为黑色

    if (AppSettingUtils.isFirstStart()) {
        //进入第一次欢迎页
        Utils.navigation(SplashActivity.this, RouterHub.APP_WELCONEACTIVITY);
        finish();
    } else {
        initStartAnim();
        //跳转主页
        Observable.timer(2, TimeUnit.SECONDS)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<Long>() {
                    @Override
                    public void accept(Long aLong) throws Exception {
                        Utils.navigation(SplashActivity.this, RouterHub.APP_HOMEACTIVITY);
                        finish();
                    }
                });
    }
}
 
Example #9
Source File: SearchActivity.java    From FriendBook with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void initImmersionBar(ImmersionBar immersionBar) {
    immersionBar
            .statusBarView(R.id.status_bar_view)
            .keyboardEnable(true, WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE
                    | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
            .init();
}
 
Example #10
Source File: BaseActivity.java    From FriendBook with GNU General Public License v3.0 5 votes vote down vote up
protected void initImmersionBar(ImmersionBar immersionBar) {
    View statusBarView = findViewById(R.id.status_bar_view);
    if (statusBarView != null) {
        immersionBar
                .statusBarView(statusBarView)
                .init();
    } else {
        immersionBar
                .fitsSystemWindows(true)
                .statusBarColor(R.color.colorPrimaryDark)
                .init();
    }


}
 
Example #11
Source File: BaseActivity.java    From FriendBook with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onContentChanged() {
    super.onContentChanged();
    //设置沉淀式状态栏
    mImmersionBar = ImmersionBar.with(this);
    initImmersionBar(mImmersionBar);
    if (isEnableSlideFinish()) {
        Slidr.attach(this, new SlidrConfig
                .Builder()
                .edge(true)
                .edgeSize(0.18f)// The % of the screen that counts as the edge, default 18%
                .listener(new SlidrListenerAdapter() {
                    @Override
                    public void onSlideStateChanged(int state) {
                        BaseActivity.this.onSlideStateChanged(state);
                    }

                    @Override
                    public void onSlideOpened() {
                        BaseActivity.this.onSlideCancel();
                    }

                    @Override
                    public void onSlideClosed() {
                        BaseActivity.this.onSlideClosed();
                    }
                })
                .build());
    }
}
 
Example #12
Source File: AppUpdateActivity.java    From PocketEOS-Android with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected void initImmersionBar() {
    super.initImmersionBar();
    if (Utils.getSpUtils().getString("loginmode").equals("phone")) {
        mImmersionBar.statusBarDarkFont(true, 0.2f).init();
    } else {
        mImmersionBar.statusBarDarkFont(false, 0.2f).init();
    }
    ImmersionBar.setTitleBar(AppUpdateActivity.this, mTitle);
}
 
Example #13
Source File: WelcomeActivity.java    From TikTok with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_welcome);
    ButterKnife.bind(this);
    ImmersionBar.with(this)
            .statusBarDarkFont(true)
            .transparentNavigationBar()//透明导航栏,不写默认黑色(设置此方法,fullScreen()方法自动为true)
            .init();   //默认状态栏字体颜色为黑色
    startAnimation();
}
 
Example #14
Source File: CameraLauncherActivity.java    From TikTok with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_camera_launcher);
    ImmersionBar.with(this)
            .statusBarDarkFont(true)
            .transparentNavigationBar()//透明导航栏,不写默认黑色(设置此方法,fullScreen()方法自动为true)
            .init();   //默认状态栏字体颜色为黑色
}
 
Example #15
Source File: WalletDetailActivity.java    From Upchain-wallet with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void configViews() {
    ImmersionBar.with(this)
            .transparentStatusBar()
            .statusBarDarkFont(true, 1f)
            .init();

    tvTitle.setText(walletName);
    etWalletName.setText(walletName);
    tvWalletAddress.setText(walletAddress);

}
 
Example #16
Source File: AddCustomTokenActivity.java    From Upchain-wallet with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void configViews() {
    ImmersionBar.with(this)
            .titleBar(commonToolbar, false)
            .transparentStatusBar()
            .statusBarDarkFont(true, 1f)
            .navigationBarColor(R.color.white)
            .init();
}
 
Example #17
Source File: FollowActivity.java    From SmartLoadingView with MIT License 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    binding = DataBindingUtil.setContentView(this,R.layout.activity_follow);
    binding.setOnclickListener(this);
    mImmersionBar = ImmersionBar.with(this);
    mImmersionBar.init();

}
 
Example #18
Source File: BaseActivity.java    From Upchain-wallet with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void onDestroy() {
    super.onDestroy();
    unbinder.unbind();
    ImmersionBar.with(this).destroy(); //必须调用该方法,防止内存泄漏
    dismissDialog();
}
 
Example #19
Source File: BaseActivity.java    From Upchain-wallet with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(getLayoutId());
    mContext = this;
    ImmersionBar.with(this).init();
    unbinder = ButterKnife.bind(this);

    mCommonToolbar = ButterKnife.findById(this, R.id.common_toolbar);
    if (mCommonToolbar != null) {
        ImmersionBar.with(this)
                .titleBar(mCommonToolbar, false)
                .transparentStatusBar()
                .statusBarDarkFont(true, 1f)
                .navigationBarColor(R.color.white)
                .init();
        initToolBar();
        setSupportActionBar(mCommonToolbar);
    }
    LinearLayout llyBack = (LinearLayout) findViewById(R.id.lly_back);
    if (llyBack != null) {
        llyBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
    initDatas();
    configViews();
}
 
Example #20
Source File: LoginActivity.java    From SmartLoadingView with MIT License 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    binding = DataBindingUtil.setContentView(this, R.layout.activity_login);
    binding.setOnclickListener(this);
    mImmersionBar = ImmersionBar.with(this);
    mImmersionBar.init();
    binding.relativeNormal.setSelected(true);
    binding.editPhone.addTextChangedListener(this);
    binding.editPassWord.addTextChangedListener(this);
}
 
Example #21
Source File: MainActivity.java    From SmartLoadingView with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
    binding.setOnClickListener(this);
    mImmersionBar = ImmersionBar.with(this);
    mImmersionBar.init();


}
 
Example #22
Source File: AppBarLayoutActivity2.java    From RetrofitGO with Apache License 2.0 4 votes vote down vote up
@Override
protected void onDestroy() {
    super.onDestroy();
    ImmersionBar.with(this).destroy();
}
 
Example #23
Source File: AppBarLayoutActivity2.java    From RetrofitGO with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    binding = DataBindingUtil.setContentView(this, R.layout.activity_appbar2);

    ImmersionBar.with(AppBarLayoutActivity2.this).titleBar(binding.toolbar)
            .statusBarDarkFont(false).navigationBarEnable(false)
            .init();

    for(int i = 0; i < 2; i++) {
        binding.tablayout.addTab(binding.tablayout.newTab());
    }

    binding.appbarLayout.addOnOffsetChangedListener(new AppBarStateChangeListener() {
        @Override
        public void onStateChanged(AppBarLayout appBarLayout, State state, int verticalOffset) {
            if( state == State.EXPANDED ) {
                //展开状态
                binding.topTitle.setVisibility(View.INVISIBLE);
                ImmersionBar.with(AppBarLayoutActivity2.this).titleBar(binding.toolbar)
                        .statusBarDarkFont(false)
                        .init();

            }else if(state == State.COLLAPSED || state == State.MIDDLE){
                //折叠状态 或者中间状态
                binding.topTitle.setVisibility(View.VISIBLE);
                ImmersionBar.with(AppBarLayoutActivity2.this).titleBar(binding.toolbar)
                        .statusBarDarkFont(true)
                        .init();
            }else {
                //其它状态
            }
        }
    });

    binding.viewpager.setAdapter(new IFragmentPagerAdapter(getSupportFragmentManager()));

    // tablayout 绑定 viewpager
    binding.tablayout.setupWithViewPager(binding.viewpager);

    binding.tablayout.setTabsFromPagerAdapter(binding.viewpager.getAdapter());//给Tabs设置适配器
}
 
Example #24
Source File: AppBarLayoutActivity.java    From RetrofitGO with Apache License 2.0 4 votes vote down vote up
@Override
protected void onDestroy() {
    super.onDestroy();
    ImmersionBar.with(this).destroy();
}
 
Example #25
Source File: AppBarLayoutActivity.java    From RetrofitGO with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    binding = DataBindingUtil.setContentView(this, R.layout.activity_appbar);

    ImmersionBar.with(AppBarLayoutActivity.this).titleBar(binding.toolbar)
            .statusBarDarkFont(false).navigationBarEnable(false)
            .init();

    for(int i = 0; i < 2; i++) {
        binding.tablayout.addTab(binding.tablayout.newTab());
    }

    binding.appbarLayout.addOnOffsetChangedListener(new AppBarStateChangeListener() {
        @Override
        public void onStateChanged(AppBarLayout appBarLayout, State state, int verticalOffset) {
            if( state == State.EXPANDED ) {
                //展开状态
                binding.topTitle.setVisibility(View.INVISIBLE);
                ImmersionBar.with(AppBarLayoutActivity.this).titleBar(binding.toolbar)
                        .statusBarDarkFont(false)
                        .init();

            }else if(state == State.COLLAPSED || state == State.MIDDLE){
                //折叠状态 或者中间状态
                binding.topTitle.setVisibility(View.VISIBLE);
                ImmersionBar.with(AppBarLayoutActivity.this).titleBar(binding.toolbar)
                        .statusBarDarkFont(true)
                        .init();
            }else {
                //其它状态
            }
        }
    });

    binding.viewpager.setAdapter(new IFragmentPagerAdapter(getSupportFragmentManager()));

    // tablayout 绑定 viewpager
    binding.tablayout.setupWithViewPager(binding.viewpager);

    binding.tablayout.setTabsFromPagerAdapter(binding.viewpager.getAdapter());//给Tabs设置适配器
}
 
Example #26
Source File: MainActivity.java    From music_player with Open Software License 3.0 4 votes vote down vote up
@Override
    public void onResume() {
        super.onResume();
//        return true会重复执行,false只执行一次
        Looper.myQueue().addIdleHandler(new MessageQueue.IdleHandler() {
            @Override
            public boolean queueIdle() {
                SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(MainActivity.this);
                //起始页
                String start_page = sharedPref.getString("start_page", "");
                if (!isfromSc) {
                    switch (start_page) {
                        case "suggestion":
                            viewPager.setCurrentItem(0);
                            break;
                        case "list":
                            viewPager.setCurrentItem(1);
                            break;
                        case "cloud":
                            viewPager.setCurrentItem(2);
                            break;
                        default:
                    }
                }
                //获得颜色设置
                MyApplication.setColor_primary(sharedPref.getInt("default_color", -16738680));
                MyApplication.setColor_accent(sharedPref.getInt("accent_color", -1499549));
                MyApplication.setMain_theme(sharedPref.getString("main_theme", "day"));
                //检测网络模式设置
                Boolean local_net_mode = sharedPref.getBoolean("local_net_mode", false);
                MyApplication.setLocal_net_mode(local_net_mode);
                //设置布局高度
                ViewPager play_now_cover_viewPager = findViewById(R.id.play_now_cover_viewpager);
                View lrcView = findViewById(R.id.other_lrc_view);
                RelativeLayout control_layout = findViewById(R.id.control_layout);
                CardView music_info_cardView = findViewById(R.id.music_info_cardView);
                ViewGroup.LayoutParams lp_control_layout = control_layout.getLayoutParams();
                RelativeLayout.LayoutParams lp_play_now_cover = (RelativeLayout.LayoutParams) play_now_cover_viewPager.getLayoutParams();
                RelativeLayout.LayoutParams lp_lrcView = (RelativeLayout.LayoutParams) lrcView.getLayoutParams();
                ViewGroup.LayoutParams lp_cardView = (ViewGroup.MarginLayoutParams) music_info_cardView.getLayoutParams();
//                ViewGroup.MarginLayoutParams mlp_cardView = music_info_cardView.getLayoutParams();
                int marginLeft_Right = (int)(16 * getResources().getDisplayMetrics().density + 0.5f);
                int marginBottom = (int)(32 * getResources().getDisplayMetrics().density + 0.5f);
                ((ViewGroup.MarginLayoutParams) lp_cardView).setMargins(marginLeft_Right,0,marginLeft_Right,ImmersionBar.getNavigationBarHeight(MainActivity.this)+marginBottom);
                int height = getResources().getDisplayMetrics().heightPixels;
                lp_play_now_cover.height = (int) (height * 0.58);
                lp_lrcView.height = ((int) (height * 0.42));
                lp_control_layout.height = ((int) (height * 0.16));
                lp_cardView.height = ((int) (height * 0.15));
                play_now_cover_viewPager.setLayoutParams(lp_play_now_cover);
                lrcView.setLayoutParams(lp_lrcView);
                control_layout.setLayoutParams(lp_control_layout);
                music_info_cardView.setLayoutParams(lp_cardView);
//                music_info_cardView.
                return false;
            }
        });
    }
 
Example #27
Source File: ReadActivity.java    From FriendBook with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void initImmersionBar(ImmersionBar immersionBar) {
    immersionBar.init();
}
 
Example #28
Source File: BaseActivity.java    From KotlinMVPRxJava2Dagger2GreenDaoRetrofitDemo with Apache License 2.0 4 votes vote down vote up
@Override
protected void onDestroy() {
    super.onDestroy();
    unbinder.unbind();
    ImmersionBar.with(this).destroy(); //不调用该方法,如果界面bar发生改变,在不关闭app的情况下,退出此界面再进入将记忆最后一次bar改变的状态
}
 
Example #29
Source File: SeachActivity.java    From PocketEOS-Android with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected void initImmersionBar() {
    super.initImmersionBar();
    mImmersionBar.statusBarDarkFont(true, 0.2f).init();
    ImmersionBar.setTitleBar(SeachActivity.this, mTitle);
}
 
Example #30
Source File: PaidAnswerActivity.java    From PocketEOS-Android with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected void initImmersionBar() {
    super.initImmersionBar();
    mImmersionBar.statusBarDarkFont(false, 0.2f).init();
    ImmersionBar.setTitleBar(PaidAnswerActivity.this, mCollapsingToolbarLayout);
}