Search in sources :

Example 6 with RxPermissions

use of com.tbruyelle.rxpermissions3.RxPermissions in project DevRing by LJYcoder.

the class PermissionManager method requestEachCombined.

// 请求多个权限建议用这个
public void requestEachCombined(Activity activity, final PermissionListener listener, String... permissions) {
    if (activity != null) {
        RxPermissions rxPermissions = new RxPermissions(activity);
        rxPermissions.requestEachCombined(permissions).subscribe(new Consumer<Permission>() {

            @Override
            public void accept(Permission permission) throws Exception {
                if (permission.granted) {
                    // All permissions are granted !
                    if (listener != null) {
                        listener.onGranted(permission.name);
                    }
                } else if (permission.shouldShowRequestPermissionRationale) {
                    // At least one denied permission without ask never again
                    if (listener != null) {
                        listener.onDenied(permission.name);
                    }
                } else {
                    // Need to go to the settings
                    if (listener != null) {
                        listener.onDeniedWithNeverAsk(permission.name);
                    }
                }
            }
        });
    }
}
Also used : RxPermissions(com.tbruyelle.rxpermissions2.RxPermissions) Permission(com.tbruyelle.rxpermissions2.Permission)

Example 7 with RxPermissions

use of com.tbruyelle.rxpermissions3.RxPermissions in project DevRing by LJYcoder.

the class PermissionManager method requestEach.

// 请求单个权限建议用这个
public void requestEach(Activity activity, final PermissionListener listener, String... permissions) {
    if (activity != null) {
        RxPermissions rxPermissions = new RxPermissions(activity);
        rxPermissions.requestEach(permissions).subscribe(new Consumer<Permission>() {

            @Override
            public void accept(Permission permission) throws Exception {
                if (permission.granted) {
                    // `permission.name` is granted !
                    if (listener != null) {
                        listener.onGranted(permission.name);
                    }
                } else if (permission.shouldShowRequestPermissionRationale) {
                    // Denied permission without ask never again
                    if (listener != null) {
                        listener.onDenied(permission.name);
                    }
                } else {
                    // Need to go to the settings
                    if (listener != null) {
                        listener.onDeniedWithNeverAsk(permission.name);
                    }
                }
            }
        });
    }
}
Also used : RxPermissions(com.tbruyelle.rxpermissions2.RxPermissions) Permission(com.tbruyelle.rxpermissions2.Permission)

Example 8 with RxPermissions

use of com.tbruyelle.rxpermissions3.RxPermissions in project DevRing by LJYcoder.

the class PermissionManager method requestEachCombined.

// 请求多个权限建议用这个
public void requestEachCombined(FragmentActivity activity, final PermissionListener listener, String... permissions) {
    if (activity != null) {
        RxPermissions rxPermissions = new RxPermissions(activity);
        rxPermissions.requestEachCombined(permissions).subscribe(new Consumer<Permission>() {

            @Override
            public void accept(Permission permission) throws Exception {
                if (permission.granted) {
                    // All permissions are granted !
                    if (listener != null) {
                        listener.onGranted(permission.name);
                    }
                } else if (permission.shouldShowRequestPermissionRationale) {
                    // At least one denied permission without ask never again
                    if (listener != null) {
                        listener.onDenied(permission.name);
                    }
                } else {
                    // Need to go to the settings
                    if (listener != null) {
                        listener.onDeniedWithNeverAsk(permission.name);
                    }
                }
            }
        });
    }
}
Also used : RxPermissions(com.tbruyelle.rxpermissions2.RxPermissions) Permission(com.tbruyelle.rxpermissions2.Permission)

Example 9 with RxPermissions

use of com.tbruyelle.rxpermissions3.RxPermissions in project CustomViews by AndroidStudy233.

the class LoginActivity method initView.

@SuppressLint("CheckResult")
@Override
public void initView() {
    rxPermissions = new RxPermissions(this);
    rxPermissions.request(Manifest.permission.READ_PHONE_STATE).subscribe(new Consumer<Boolean>() {

        @Override
        public void accept(Boolean aBoolean) throws Exception {
            if (aBoolean) {
                Imei = CommonUtils.getImeiOrMeid(LoginActivity.this);
            }
        }
    });
    btnLogin = findViewById(R.id.btn_enter);
}
Also used : RxPermissions(com.tbruyelle.rxpermissions2.RxPermissions) SuppressLint(android.annotation.SuppressLint)

Example 10 with RxPermissions

use of com.tbruyelle.rxpermissions3.RxPermissions in project CustomViews by AndroidStudy233.

the class BaseActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.savedInstanceState = savedInstanceState;
    // transparentNavigationBar();
    try {
        rxPermissions = new RxPermissions(this);
        AppManagerUtil.getAppManager().addActivity(this);
        setContentView(layoutId());
        // ButterKnife.bind(this);
        initToolbar();
        baseBundle = getIntent().getBundleExtra("bundle");
        initView();
        BindEvent();
        dialogProgress = new DialogProgress(this, R.style.DialogTheme);
        inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    } catch (Exception e) {
        e.printStackTrace();
    }
    loadProcess = new DialogProgress(this, R.style.DialogTheme);
}
Also used : RxPermissions(com.tbruyelle.rxpermissions2.RxPermissions) DialogProgress(qwy.anenda.com.baselib.widget.DialogProgress) InvocationTargetException(java.lang.reflect.InvocationTargetException)

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