Search in sources :

Example 6 with ImageConfig

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

the class ImageConfigTest method testGetActualFile.

@Test
public void testGetActualFile() {
    ImageConfig originalConfig = new ImageConfig(new File("original.txt"), null, 0, 0, 0, 0, false);
    ImageConfig resizedConfig = originalConfig.withResizedFile(new File("resized.txt"));
    assertEquals("For config which has got only original file", "original.txt", originalConfig.getActualFile().getName());
    assertEquals("For config which has got resized file too", "resized.txt", resizedConfig.getActualFile().getName());
}
Also used : ImageConfig(com.imagepicker.media.ImageConfig) File(java.io.File) Test(org.junit.Test)

Example 7 with ImageConfig

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

the class ImagePickerModule method showImagePicker.

@ReactMethod
public void showImagePicker(final ReadableMap options, final Callback callback) {
    Activity currentActivity = getCurrentActivity();
    if (currentActivity == null) {
        responseHelper.invokeError(callback, "can't find current Activity");
        return;
    }
    this.callback = callback;
    this.options = options;
    imageConfig = new ImageConfig(null, null, 0, 0, 100, 0, false);
    final AlertDialog dialog = UI.chooseDialog(this, options, new UI.OnAction() {

        @Override
        public void onTakePhoto(@NonNull final ImagePickerModule module) {
            if (module == null) {
                return;
            }
            module.launchCamera();
        }

        @Override
        public void onUseLibrary(@NonNull final ImagePickerModule module) {
            if (module == null) {
                return;
            }
            module.launchImageLibrary();
        }

        @Override
        public void onCancel(@NonNull final ImagePickerModule module) {
            if (module == null) {
                return;
            }
            module.doOnCancel();
        }

        @Override
        public void onCustomButton(@NonNull final ImagePickerModule module, @NonNull final String action) {
            if (module == null) {
                return;
            }
            module.invokeCustomButton(action);
        }
    });
    dialog.show();
}
Also used : ImageConfig(com.imagepicker.media.ImageConfig) AlertDialog(android.support.v7.app.AlertDialog) UI(com.imagepicker.utils.UI) ReactActivity(com.facebook.react.ReactActivity) Activity(android.app.Activity) ReactMethod(com.facebook.react.bridge.ReactMethod)

Aggregations

ImageConfig (com.imagepicker.media.ImageConfig)7 File (java.io.File)4 Test (org.junit.Test)4 IOException (java.io.IOException)2 Activity (android.app.Activity)1 Bitmap (android.graphics.Bitmap)1 BitmapFactory (android.graphics.BitmapFactory)1 Matrix (android.graphics.Matrix)1 ExifInterface (android.media.ExifInterface)1 NonNull (android.support.annotation.NonNull)1 Nullable (android.support.annotation.Nullable)1 AlertDialog (android.support.v7.app.AlertDialog)1 ReactActivity (com.facebook.react.ReactActivity)1 ReactMethod (com.facebook.react.bridge.ReactMethod)1 WritableMap (com.facebook.react.bridge.WritableMap)1 UI (com.imagepicker.utils.UI)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 FileOutputStream (java.io.FileOutputStream)1