@@ -728,77 +728,68 @@ private void processResultFromGallery(int destType, Intent intent) {
728
728
}
729
729
}
730
730
731
- String fileLocation = FileHelper .getRealPath (uri , this .cordova );
732
- LOG .d (LOG_TAG , "File location is: " + fileLocation );
733
-
734
731
String uriString = uri .toString ();
735
- String finalLocation = fileLocation != null ? fileLocation : uriString ;
736
732
String mimeTypeOfGalleryFile = FileHelper .getMimeType (uriString , this .cordova );
737
733
738
- if (finalLocation == null ) {
739
- this .failPicture ("Error retrieving result." );
734
+ // If you ask for video or the selected file cannot be processed
735
+ // there will be no attempt to resize any returned data.
736
+ if (this .mediaType == VIDEO || !isImageMimeTypeProcessable (mimeTypeOfGalleryFile )) {
737
+ this .callbackContext .success (uriString );
740
738
} else {
741
- // If you ask for video or the selected file cannot be processed
742
- // there will be no attempt to resize any returned data.
743
- if (this .mediaType == VIDEO || !isImageMimeTypeProcessable (mimeTypeOfGalleryFile )) {
744
- this .callbackContext .success (finalLocation );
745
- } else {
746
739
747
- // This is a special case to just return the path as no scaling,
748
- // rotating, nor compressing needs to be done
749
- if (this .targetHeight == -1 && this .targetWidth == -1 &&
750
- destType == FILE_URI && !this .correctOrientation &&
751
- getMimetypeForEncodingType ().equalsIgnoreCase (mimeTypeOfGalleryFile ))
752
- {
753
- this .callbackContext .success (finalLocation );
754
- } else {
755
- Bitmap bitmap = null ;
756
- try {
757
- bitmap = getScaledAndRotatedBitmap (uriString );
758
- } catch (IOException e ) {
759
- e .printStackTrace ();
760
- }
761
- if (bitmap == null ) {
762
- LOG .d (LOG_TAG , "I either have a null image path or bitmap" );
763
- this .failPicture ("Unable to create bitmap!" );
764
- return ;
765
- }
740
+ // This is a special case to just return the path as no scaling,
741
+ // rotating, nor compressing needs to be done
742
+ if (this .targetHeight == -1 && this .targetWidth == -1 &&
743
+ destType == FILE_URI && !this .correctOrientation &&
744
+ getMimetypeForEncodingType ().equalsIgnoreCase (mimeTypeOfGalleryFile ))
745
+ {
746
+ this .callbackContext .success (uriString );
747
+ } else {
748
+ Bitmap bitmap = null ;
749
+ try {
750
+ bitmap = getScaledAndRotatedBitmap (uriString );
751
+ } catch (IOException e ) {
752
+ e .printStackTrace ();
753
+ }
754
+ if (bitmap == null ) {
755
+ LOG .d (LOG_TAG , "I either have a null image path or bitmap" );
756
+ this .failPicture ("Unable to create bitmap!" );
757
+ return ;
758
+ }
766
759
767
- // If sending base64 image back
768
- if (destType == DATA_URL ) {
769
- this .processPicture (bitmap , this .encodingType );
770
- }
760
+ // If sending base64 image back
761
+ if (destType == DATA_URL ) {
762
+ this .processPicture (bitmap , this .encodingType );
763
+ }
771
764
772
- // If sending filename back
773
- else if (destType == FILE_URI ) {
774
- // Did we modify the image?
775
- if ( (this .targetHeight > 0 && this .targetWidth > 0 ) ||
776
- (this .correctOrientation && this .orientationCorrected ) ||
777
- !mimeTypeOfGalleryFile .equalsIgnoreCase (getMimetypeForEncodingType ()))
778
- {
779
- try {
780
- String modifiedPath = this .outputModifiedBitmap (bitmap , uri , mimeTypeOfGalleryFile );
781
- // The modified image is cached by the app in order to get around this and not have to delete you
782
- // application cache I'm adding the current system time to the end of the file url.
783
- this .callbackContext .success ("file://" + modifiedPath + "?" + System .currentTimeMillis ());
784
-
785
- } catch (Exception e ) {
786
- e .printStackTrace ();
787
- this .failPicture ("Error retrieving image: " +e .getLocalizedMessage ());
788
- }
789
- } else {
790
- this .callbackContext .success (finalLocation );
765
+ // If sending filename back
766
+ else if (destType == FILE_URI ) {
767
+ // Did we modify the image?
768
+ if ( (this .targetHeight > 0 && this .targetWidth > 0 ) ||
769
+ (this .correctOrientation && this .orientationCorrected ) ||
770
+ !mimeTypeOfGalleryFile .equalsIgnoreCase (getMimetypeForEncodingType ()))
771
+ {
772
+ try {
773
+ String modifiedPath = this .outputModifiedBitmap (bitmap , uri , mimeTypeOfGalleryFile );
774
+ // The modified image is cached by the app in order to get around this and not have to delete you
775
+ // application cache I'm adding the current system time to the end of the file url.
776
+ this .callbackContext .success ("file://" + modifiedPath + "?" + System .currentTimeMillis ());
777
+
778
+ } catch (Exception e ) {
779
+ e .printStackTrace ();
780
+ this .failPicture ("Error retrieving image: " +e .getLocalizedMessage ());
791
781
}
782
+ } else {
783
+ this .callbackContext .success (uriString );
792
784
}
793
- if (bitmap != null ) {
794
- bitmap .recycle ();
795
- bitmap = null ;
796
- }
797
- System .gc ();
798
785
}
786
+ if (bitmap != null ) {
787
+ bitmap .recycle ();
788
+ bitmap = null ;
789
+ }
790
+ System .gc ();
799
791
}
800
792
}
801
-
802
793
}
803
794
804
795
/**
0 commit comments