Search in sources :

Example 11 with RxPermissions

use of com.tbruyelle.rxpermissions3.RxPermissions in project AndroidUtilLib by SiberiaDante.

the class SDDeviceUtilActivity method checkPermission1.

@SuppressLint("CheckResult")
private void checkPermission1() {
    RxPermissions rxPermissions = new RxPermissions(this);
    rxPermissions.request(Manifest.permission.READ_PHONE_STATE, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.WRITE_CONTACTS, Manifest.permission.READ_CONTACTS).subscribe(new Consumer<Boolean>() {

        @Override
        public void accept(Boolean aBoolean) throws Exception {
            SDLogUtil.d("--------------" + aBoolean);
            if (aBoolean) {
                showResult();
            }
            showResult();
        }
    });
}
Also used : RxPermissions(com.tbruyelle.rxpermissions2.RxPermissions) SuppressLint(android.annotation.SuppressLint)

Example 12 with RxPermissions

use of com.tbruyelle.rxpermissions3.RxPermissions in project PainlessMusicPlayer by Doctoror.

the class DeleteItemDialogFragment method onDeleteClick.

private void onDeleteClick() {
    final Activity activity = getActivity();
    new RxPermissions(activity).request(Manifest.permission.WRITE_EXTERNAL_STORAGE).subscribe(granted -> {
        if (granted) {
            performDelete();
        }
    });
}
Also used : RxPermissions(com.tbruyelle.rxpermissions2.RxPermissions) Activity(android.app.Activity)

Example 13 with RxPermissions

use of com.tbruyelle.rxpermissions3.RxPermissions in project ttdj by soonphe.

the class PublishGoodsFragment method onItemClick.

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    if (parent.getId() == R.id.activity_postmessage_gridview) {
        // 判断是否为最后一个
        if (position == parent.getChildCount() - 1) {
            new RxPermissions(getContext()).request(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA).subscribe(granded -> {
                if (granded) {
                    Matisse.from(this).choose(MimeType.ofAll(), false).countable(true).capture(// 拍照
                    true).captureStrategy(new CaptureStrategy(true, "com.connxun.ltcx.app.fileprovider")).maxSelectable(6).addFilter(new GifSizeFilter(320, 320, 5 * Filter.K * Filter.K)).gridExpectedSize(getResources().getDimensionPixelSize(R.dimen.grid_expected_size)).restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED).thumbnailScale(0.85f).imageEngine(new GlideEngine()).forResult(REQUEST_CODE_CHOOSE);
                } else {
                    ToastUtils.showShort("请先授予应用相关权限");
                    mOperation.showBasicDialog(R.string.error, R.string.grant_permission, (dialog, which) -> {
                        // Intent intent = new Intent(Settings.ACTION_WIRELESS_SETTINGS);    //飞行模式,无线网和网络设置界面
                        // 跳转位置服务界面
                        Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                        startActivity(intent);
                    });
                }
            });
        }
    }
}
Also used : CaptureStrategy(com.zhihu.matisse.internal.entity.CaptureStrategy) RxPermissions(com.tbruyelle.rxpermissions2.RxPermissions) GlideEngine(com.zhihu.matisse.engine.impl.GlideEngine) Intent(android.content.Intent) GifSizeFilter(com.connxun.ltcx.utils.GifSizeFilter)

Example 14 with RxPermissions

use of com.tbruyelle.rxpermissions3.RxPermissions in project ttdj by soonphe.

the class ApplyStoreActivity method onViewClicked.

@OnClick({ R.id.iv_image, R.id.tv_publish })
public void onViewClicked(View view) {
    switch(view.getId()) {
        case R.id.iv_image:
            new RxPermissions(getContext()).request(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA).subscribe(granded -> {
                if (granded) {
                    Matisse.from(getContext()).choose(MimeType.ofAll(), false).countable(true).capture(// 拍照
                    true).captureStrategy(new CaptureStrategy(true, "com.connxun.ltcx.app.fileprovider")).maxSelectable(1).addFilter(new GifSizeFilter(320, 320, 5 * Filter.K * Filter.K)).gridExpectedSize(getResources().getDimensionPixelSize(R.dimen.grid_expected_size)).restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED).thumbnailScale(0.85f).imageEngine(new GlideEngine()).forResult(REQUEST_CODE_CHOOSE);
                } else {
                    ToastUtils.showShort("请先授予应用相关权限");
                    mOperation.showBasicDialog(R.string.error, R.string.grant_permission, (dialog, which) -> {
                        // Intent intent = new Intent(Settings.ACTION_WIRELESS_SETTINGS);    //飞行模式,无线网和网络设置界面
                        // 跳转位置服务界面
                        Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                        startActivity(intent);
                    });
                }
            });
            break;
        case R.id.tv_publish:
            validator.validate();
            break;
    }
}
Also used : CaptureStrategy(com.zhihu.matisse.internal.entity.CaptureStrategy) RxPermissions(com.tbruyelle.rxpermissions2.RxPermissions) GlideEngine(com.zhihu.matisse.engine.impl.GlideEngine) Intent(android.content.Intent) GifSizeFilter(com.connxun.ltcx.utils.GifSizeFilter) OnClick(butterknife.OnClick)

Example 15 with RxPermissions

use of com.tbruyelle.rxpermissions3.RxPermissions in project ttdj by soonphe.

the class MainActivity method doBusiness.

@Override
public void doBusiness(Context mContext) {
    if (Build.VERSION.SDK_INT >= 23) {
        new RxPermissions(getContext()).request(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.READ_PHONE_STATE, Manifest.permission.WRITE_EXTERNAL_STORAGE).subscribe(granded -> {
            if (granded) {
            } else {
                Toast("请先授予应用相关权限");
                mOperation.showBasicDialog(R.string.error, R.string.grant_permission, (dialog, which) -> {
                    // Intent intent = new Intent(Settings.ACTION_WIRELESS_SETTINGS);    //飞行模式,无线网和网络设置界面
                    // 跳转位置服务界面
                    Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                    startActivity(intent);
                });
            }
        });
    }
    Logger.addLogAdapter(new AndroidLogAdapter());
    Logger.d("___________________hello");
// CrashReport.initCrashReport(getApplicationContext());
// CrashReport.testJavaCrash();
// DaoMaster.DevOpenHelper devOpenHelper = new DaoMaster.DevOpenHelper(getApplicationContext(), "lenve.db", null);
// DaoMaster daoMaster = new DaoMaster(devOpenHelper.getWritableDb());
// DaoSession daoSession = daoMaster.newSession();
// 
// VideoClassDao videoClassDao=daoSession.getVideoClassDao();
// 
// VideoClass user = new VideoClass();
// videoClassDao.insert(user);
}
Also used : RxPermissions(com.tbruyelle.rxpermissions2.RxPermissions) AndroidLogAdapter(com.orhanobut.logger.AndroidLogAdapter) Intent(android.content.Intent)

Aggregations

RxPermissions (com.tbruyelle.rxpermissions2.RxPermissions)31 Intent (android.content.Intent)8 SuppressLint (android.annotation.SuppressLint)6 Permission (com.tbruyelle.rxpermissions2.Permission)4 View (android.view.View)3 GifSizeFilter (com.connxun.ltcx.utils.GifSizeFilter)3 RxPermissions (com.tbruyelle.rxpermissions3.RxPermissions)3 Manifest (android.Manifest)2 Uri (android.net.Uri)2 Button (android.widget.Button)2 OnClick (butterknife.OnClick)2 GlideEngine (com.zhihu.matisse.engine.impl.GlideEngine)2 CaptureStrategy (com.zhihu.matisse.internal.entity.CaptureStrategy)2 Consumer (io.reactivex.functions.Consumer)2 IOException (java.io.IOException)2 Activity (android.app.Activity)1 Context (android.content.Context)1 ActivityInfo (android.content.pm.ActivityInfo)1 Cursor (android.database.Cursor)1 Bundle (android.os.Bundle)1