@@ -605,7 +605,7 @@ private synchronized void processImage(MutableImage mutableImage, ReadableMap op
605
605
606
606
addToMediaStore (cameraRollFile .getAbsolutePath ());
607
607
608
- resolve (cameraRollFile , promise );
608
+ resolveImage (cameraRollFile , promise , true );
609
609
610
610
break ;
611
611
}
@@ -623,7 +623,7 @@ private synchronized void processImage(MutableImage mutableImage, ReadableMap op
623
623
return ;
624
624
}
625
625
626
- resolve (pictureFile , promise );
626
+ resolveImage (pictureFile , promise , false );
627
627
628
628
break ;
629
629
}
@@ -641,7 +641,7 @@ private synchronized void processImage(MutableImage mutableImage, ReadableMap op
641
641
return ;
642
642
}
643
643
644
- resolve (tempFile , promise );
644
+ resolveImage (tempFile , promise , false );
645
645
646
646
break ;
647
647
}
@@ -764,27 +764,31 @@ public void onHostDestroy() {
764
764
// ... do nothing
765
765
}
766
766
767
- private void resolve (final File imageFile , final Promise promise ) {
767
+ private void resolveImage (final File imageFile , final Promise promise , boolean addToMediaStore ) {
768
768
final WritableMap response = new WritableNativeMap ();
769
769
response .putString ("path" , Uri .fromFile (imageFile ).toString ());
770
770
771
- // borrowed from react-native CameraRollManager, it finds and returns the 'internal'
772
- // representation of the image uri that was just saved.
773
- // e.g. content://media/external/images/media/123
774
- MediaScannerConnection .scanFile (
775
- _reactContext ,
776
- new String []{imageFile .getAbsolutePath ()},
777
- null ,
778
- new MediaScannerConnection .OnScanCompletedListener () {
779
- @ Override
780
- public void onScanCompleted (String path , Uri uri ) {
781
- if (uri != null ) {
782
- response .putString ("mediaUri" , uri .toString ());
771
+ if (addToMediaStore ) {
772
+ // borrowed from react-native CameraRollManager, it finds and returns the 'internal'
773
+ // representation of the image uri that was just saved.
774
+ // e.g. content://media/external/images/media/123
775
+ MediaScannerConnection .scanFile (
776
+ _reactContext ,
777
+ new String []{imageFile .getAbsolutePath ()},
778
+ null ,
779
+ new MediaScannerConnection .OnScanCompletedListener () {
780
+ @ Override
781
+ public void onScanCompleted (String path , Uri uri ) {
782
+ if (uri != null ) {
783
+ response .putString ("mediaUri" , uri .toString ());
784
+ }
785
+
786
+ promise .resolve (response );
783
787
}
784
-
785
- promise . resolve ( response );
786
- }
787
- });
788
+ });
789
+ } else {
790
+ promise . resolve ( response );
791
+ }
788
792
}
789
793
790
794
}
0 commit comments