Search in sources :

Example 1 with ImagePickerModule

use of com.imagepicker.ImagePickerModule in project react-native-image-picker by marcshilling.

the class PermissionUtils method explainingDialog.

@Nullable
public static AlertDialog explainingDialog(@NonNull final ImagePickerModule module, @NonNull final ReadableMap options, @NonNull final OnExplainingPermissionCallback callback) {
    if (module.getContext() == null) {
        return null;
    }
    final ReadableMap permissionDenied = options.getMap("permissionDenied");
    final String title = permissionDenied.getString("title");
    final String text = permissionDenied.getString("text");
    final String btnReTryTitle = permissionDenied.getString("reTryTitle");
    final String btnOkTitle = permissionDenied.getString("okTitle");
    final WeakReference<ImagePickerModule> reference = new WeakReference<>(module);
    final Activity activity = module.getActivity();
    if (activity == null) {
        return null;
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(activity, module.getDialogThemeId());
    builder.setTitle(title).setMessage(text).setCancelable(false).setNegativeButton(btnOkTitle, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(final DialogInterface dialogInterface, int i) {
            callback.onCancel(reference, dialogInterface);
        }
    }).setPositiveButton(btnReTryTitle, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            callback.onReTry(reference, dialogInterface);
        }
    });
    return builder.create();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) ImagePickerModule(com.imagepicker.ImagePickerModule) Activity(android.app.Activity) WeakReference(java.lang.ref.WeakReference) ReadableMap(com.facebook.react.bridge.ReadableMap) Nullable(android.support.annotation.Nullable)

Aggregations

Activity (android.app.Activity)1 DialogInterface (android.content.DialogInterface)1 Nullable (android.support.annotation.Nullable)1 AlertDialog (android.support.v7.app.AlertDialog)1 ReadableMap (com.facebook.react.bridge.ReadableMap)1 ImagePickerModule (com.imagepicker.ImagePickerModule)1 WeakReference (java.lang.ref.WeakReference)1