com.blankj.utilcode.utils.ToastUtils Java Examples

The following examples show how to use com.blankj.utilcode.utils.ToastUtils. 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: SplashActivity.java    From Bailan with Apache License 2.0 6 votes vote down vote up
/**
 * 申请权限结果回调
 * @param requestCode 请求码
 * @param permissions 申请权限的数组
 * @param grantResults 申请权限成功与否的结果
 */
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    switch (requestCode){
        case 1:
            if (grantResults.length > 0 && grantResults[0]==PackageManager.PERMISSION_GRANTED){
                //申请成功
                ToastUtils.showShortToast("授权SD卡权限成功");
            }else {
                //申请失败
                ToastUtils.showShortToast("授权SD卡权限失败 可能会影响应用的使用");
            }
            break;
    }

}
 
Example #2
Source File: SplashActivity.java    From Bailan with Apache License 2.0 6 votes vote down vote up
/**
 * 申请权限结果回调
 * @param requestCode 请求码
 * @param permissions 申请权限的数组
 * @param grantResults 申请权限成功与否的结果
 */
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    switch (requestCode){
        case 1:
            if (grantResults.length > 0 && grantResults[0]==PackageManager.PERMISSION_GRANTED){
                //申请成功
                ToastUtils.showShortToast("授权SD卡权限成功");
            }else {
                //申请失败
                ToastUtils.showShortToast("授权SD卡权限失败 可能会影响应用的使用");
            }
            break;
    }

}
 
Example #3
Source File: LivePlayChatFragment.java    From C9MJ with Apache License 2.0 6 votes vote down vote up
@OnClick(R.id.tv_send)
public void onClick() {
    String danmu = et_danmu.getText().toString();
    if (TextUtils.isEmpty(danmu)) {
        ToastUtils.showShortToast("发送弹幕内容不能为空");
        return;
    } else if (activity == null) {
        ToastUtils.showShortToast("发送弹幕内容失败");
        return;
    }

    //新建弹幕对象
    DanmuBean danmuBean = new DanmuBean();
    DanmuBean.DataBean dataBean = new DanmuBean.DataBean();
    DanmuBean.DataBean.FromBean fromBean = new DanmuBean.DataBean.FromBean();
    fromBean.setNickName(getString(R.string.chat_name));
    fromBean.setUserName(getString(R.string.chat_name));
    dataBean.setFrom(fromBean);
    dataBean.setContent(danmu);
    danmuBean.setData(dataBean);

    activity.addDanmuOnDanmakuView(danmuBean, true);
    this.addDanmuOnRecyclerView(danmuBean);

    et_danmu.setText(null);
}
 
Example #4
Source File: MainFragment.java    From C9MJ with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onBackPressedSupport() {
    if (System.currentTimeMillis() - exitTime > 2000) {
        exitTime = System.currentTimeMillis();
        ToastUtils.showShortToast(getString(R.string.second_exit));
        return true;
    } else {
        return super.onBackPressedSupport();
    }
}
 
Example #5
Source File: App.java    From C9MJ with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    instance = this;
    LeakCanary.install(this);
    Utils.init(getApplicationContext());
    ToastUtils.init(true);
    spUtils = new SPUtils(getString(R.string.app_name));
    RxPaparazzo.register(this);
}
 
Example #6
Source File: BaseSwipeActivity.java    From C9MJ with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //6.0权限申请
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        RxPermissions rxPermissions = new RxPermissions(this);
        rxPermissions
                .requestEach(
                        Manifest.permission.CAMERA,
                        Manifest.permission.INTERNET,
                        Manifest.permission.READ_EXTERNAL_STORAGE,
                        Manifest.permission.WRITE_EXTERNAL_STORAGE)
                .subscribe(permission -> {
                    if (permission.granted) {
                        // `permission.name` is granted !
                    } else if (permission.shouldShowRequestPermissionRationale) {
                        // Denied permission without ask never again
                    } else {
                        // Denied permission with ask never again
                        // Need to go to the settings
                        ToastUtils.showShortToast(getString(R.string.error_grant));
                    }

                });
    }
    ;
}
 
Example #7
Source File: BaseActivity.java    From C9MJ with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //6.0权限申请
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        RxPermissions rxPermissions = new RxPermissions(this);
        rxPermissions
                .requestEach(
                        Manifest.permission.CAMERA,
                        Manifest.permission.INTERNET,
                        Manifest.permission.READ_EXTERNAL_STORAGE,
                        Manifest.permission.WRITE_EXTERNAL_STORAGE)
                .subscribe(permission -> {
                    if (permission.granted) {
                        // `permission.name` is granted !
                    } else if (permission.shouldShowRequestPermissionRationale) {
                        // Denied permission without ask never again
                    } else {
                        // Denied permission with ask never again
                        // Need to go to the settings
                        ToastUtils.showShortToast(getString(R.string.error_grant));
                    }

                });
    }
    ;
}
 
Example #8
Source File: GalleryActivity.java    From C9MJ with Apache License 2.0 4 votes vote down vote up
@Override
public void showError(String message) {
    ToastUtils.showShortToast(message);
}
 
Example #9
Source File: DemoListFragment.java    From C9MJ with Apache License 2.0 4 votes vote down vote up
@Override
public void showError(String message) {
    ProgressUtil.dismiss();
    ToastUtils.showShortToast(message);
}
 
Example #10
Source File: ExploreDetailFragment.java    From C9MJ with Apache License 2.0 4 votes vote down vote up
@Override
public void showError(String message) {
    ToastUtils.showShortToast(message);
}
 
Example #11
Source File: ExploreListFragment.java    From C9MJ with Apache License 2.0 4 votes vote down vote up
@Override
public void showError(String message) {
    refreshLayout.setRefreshing(false);
    adapter.loadMoreFail();//在加载失败的时候调用showLoadMoreFailedView()就能显示加载失败的footer了,点击footer会重新加载
    ToastUtils.showShortToast(message);
}
 
Example #12
Source File: LiveListFragment.java    From C9MJ with Apache License 2.0 4 votes vote down vote up
@Override
public void showError(String message) {
    refreshLayout.setRefreshing(false);
    adapter.loadMoreFail();//在加载失败的时候调用showLoadMoreFailedView()就能显示加载失败的footer了,点击footer会重新加载
    ToastUtils.showShortToast(message);
}
 
Example #13
Source File: LivePlayActivity.java    From C9MJ with Apache License 2.0 4 votes vote down vote up
@Override
public void showError(String message) {
    ToastUtils.showShortToast(message);
}
 
Example #14
Source File: DemoNormalFragment.java    From C9MJ with Apache License 2.0 4 votes vote down vote up
@Override
public void showError(String message) {
    ProgressUtil.dismiss();
    ToastUtils.showShortToast(message);
}