Search in sources :

Example 1 with MultiplePermissionsListener

use of com.karumi.dexter.listener.multi.MultiplePermissionsListener in project Dexter by Karumi.

the class SampleActivity method createPermissionListeners.

private void createPermissionListeners() {
    PermissionListener feedbackViewPermissionListener = new SamplePermissionListener(this);
    MultiplePermissionsListener feedbackViewMultiplePermissionListener = new SampleMultiplePermissionListener(this);
    allPermissionsListener = new CompositeMultiplePermissionsListener(feedbackViewMultiplePermissionListener, SnackbarOnAnyDeniedMultiplePermissionsListener.Builder.with(contentView, R.string.all_permissions_denied_feedback).withOpenSettingsButton(R.string.permission_rationale_settings_button_text).build());
    contactsPermissionListener = new CompositePermissionListener(feedbackViewPermissionListener, SnackbarOnDeniedPermissionListener.Builder.with(contentView, R.string.contacts_permission_denied_feedback).withOpenSettingsButton(R.string.permission_rationale_settings_button_text).withCallback(new Snackbar.Callback() {

        @Override
        public void onShown(Snackbar snackbar) {
            super.onShown(snackbar);
        }

        @Override
        public void onDismissed(Snackbar snackbar, int event) {
            super.onDismissed(snackbar, event);
        }
    }).build());
    PermissionListener dialogOnDeniedPermissionListener = DialogOnDeniedPermissionListener.Builder.withContext(this).withTitle(R.string.audio_permission_denied_dialog_title).withMessage(R.string.audio_permission_denied_dialog_feedback).withButtonText(android.R.string.ok).withIcon(R.mipmap.ic_logo_karumi).build();
    audioPermissionListener = new CompositePermissionListener(feedbackViewPermissionListener, dialogOnDeniedPermissionListener);
    cameraPermissionListener = new SampleBackgroundThreadPermissionListener(this);
    errorListener = new SampleErrorListener();
}
Also used : MultiplePermissionsListener(com.karumi.dexter.listener.multi.MultiplePermissionsListener) SnackbarOnAnyDeniedMultiplePermissionsListener(com.karumi.dexter.listener.multi.SnackbarOnAnyDeniedMultiplePermissionsListener) CompositeMultiplePermissionsListener(com.karumi.dexter.listener.multi.CompositeMultiplePermissionsListener) SnackbarOnDeniedPermissionListener(com.karumi.dexter.listener.single.SnackbarOnDeniedPermissionListener) CompositePermissionListener(com.karumi.dexter.listener.single.CompositePermissionListener) PermissionListener(com.karumi.dexter.listener.single.PermissionListener) DialogOnDeniedPermissionListener(com.karumi.dexter.listener.single.DialogOnDeniedPermissionListener) CompositeMultiplePermissionsListener(com.karumi.dexter.listener.multi.CompositeMultiplePermissionsListener) CompositePermissionListener(com.karumi.dexter.listener.single.CompositePermissionListener) Snackbar(com.google.android.material.snackbar.Snackbar)

Example 2 with MultiplePermissionsListener

use of com.karumi.dexter.listener.multi.MultiplePermissionsListener in project Dexter by Karumi.

the class DexterInstance method checkSinglePermission.

private void checkSinglePermission(PermissionListener listener, String permission, Thread thread) {
    MultiplePermissionsListener adapter = new MultiplePermissionsListenerToPermissionListenerAdapter(listener);
    checkMultiplePermissions(adapter, Collections.singleton(permission), thread);
}
Also used : MultiplePermissionsListener(com.karumi.dexter.listener.multi.MultiplePermissionsListener) BaseMultiplePermissionsListener(com.karumi.dexter.listener.multi.BaseMultiplePermissionsListener)

Example 3 with MultiplePermissionsListener

use of com.karumi.dexter.listener.multi.MultiplePermissionsListener in project Dexter by Karumi.

the class DexterInstance method onPermissionsChecked.

private void onPermissionsChecked(Collection<String> permissions) {
    if (pendingPermissions.isEmpty()) {
        return;
    }
    synchronized (pendingPermissionsMutex) {
        pendingPermissions.removeAll(permissions);
        if (pendingPermissions.isEmpty()) {
            // the permission is checked. Issues #243 and #221
            if (activity != null) {
                activity.finish();
            }
            isRequestingPermission.set(false);
            rationaleAccepted.set(false);
            isShowingNativeDialog.set(false);
            MultiplePermissionsListener currentListener = listener;
            listener = EMPTY_LISTENER;
            currentListener.onPermissionsChecked(multiplePermissionsReport);
        }
    }
}
Also used : MultiplePermissionsListener(com.karumi.dexter.listener.multi.MultiplePermissionsListener) BaseMultiplePermissionsListener(com.karumi.dexter.listener.multi.BaseMultiplePermissionsListener)

Aggregations

MultiplePermissionsListener (com.karumi.dexter.listener.multi.MultiplePermissionsListener)3 BaseMultiplePermissionsListener (com.karumi.dexter.listener.multi.BaseMultiplePermissionsListener)2 Snackbar (com.google.android.material.snackbar.Snackbar)1 CompositeMultiplePermissionsListener (com.karumi.dexter.listener.multi.CompositeMultiplePermissionsListener)1 SnackbarOnAnyDeniedMultiplePermissionsListener (com.karumi.dexter.listener.multi.SnackbarOnAnyDeniedMultiplePermissionsListener)1 CompositePermissionListener (com.karumi.dexter.listener.single.CompositePermissionListener)1 DialogOnDeniedPermissionListener (com.karumi.dexter.listener.single.DialogOnDeniedPermissionListener)1 PermissionListener (com.karumi.dexter.listener.single.PermissionListener)1 SnackbarOnDeniedPermissionListener (com.karumi.dexter.listener.single.SnackbarOnDeniedPermissionListener)1