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();
}
Aggregations