@@ -488,7 +488,7 @@ private void handleChooseImageResult(int resultCode, Intent data) {
488488 }
489489
490490 // User cancelled choosing a picture.
491- finishWithSuccess (null );
491+ finishWithSuccess (null , false );
492492 }
493493
494494 private void handleChooseMultiImageResult (int resultCode , Intent intent ) {
@@ -506,7 +506,7 @@ private void handleChooseMultiImageResult(int resultCode, Intent intent) {
506506 }
507507
508508 // User cancelled choosing a picture.
509- finishWithSuccess (null );
509+ finishWithSuccess (null , false );
510510 }
511511
512512 private void handleChooseVideoResult (int resultCode , Intent data ) {
@@ -517,7 +517,7 @@ private void handleChooseVideoResult(int resultCode, Intent data) {
517517 }
518518
519519 // User cancelled choosing a picture.
520- finishWithSuccess (null );
520+ finishWithSuccess (null , false );
521521 }
522522
523523 private void handleCaptureImageResult (int resultCode ) {
@@ -536,7 +536,7 @@ public void onPathReady(String path) {
536536 }
537537
538538 // User cancelled taking a picture.
539- finishWithSuccess (null );
539+ finishWithSuccess (null , false );
540540 }
541541
542542 private void handleCaptureVideoResult (int resultCode ) {
@@ -555,7 +555,7 @@ public void onPathReady(String path) {
555555 }
556556
557557 // User cancelled taking a picture.
558- finishWithSuccess (null );
558+ finishWithSuccess (null , false );
559559 }
560560
561561 private void handleMultiImageResult (
@@ -572,21 +572,23 @@ private void handleMultiImageResult(
572572 }
573573 paths .set (i , finalImagePath );
574574 }
575- finishWithListSuccess (paths );
575+ finishWithSuccess (paths , true );
576576 }
577577 }
578578
579579 private void handleImageResult (String path , boolean shouldDeleteOriginalIfScaled ) {
580+ ArrayList <String > imageList = new ArrayList <String >();
580581 if (methodCall != null ) {
581582 String finalImagePath = getResizedImagePath (path );
582583 //delete original file if scaled
583584 if (finalImagePath != null && !finalImagePath .equals (path ) && shouldDeleteOriginalIfScaled ) {
584585 new File (path ).delete ();
585586 }
586- finishWithSuccess (finalImagePath );
587+ imageList . add (finalImagePath );
587588 } else {
588- finishWithSuccess (path );
589+ imageList . add (path );
589590 }
591+ finishWithSuccess (imageList , false );
590592 }
591593
592594 private String getResizedImagePath (String path ) {
@@ -598,7 +600,9 @@ private String getResizedImagePath(String path) {
598600 }
599601
600602 private void handleVideoResult (String path ) {
601- finishWithSuccess (path );
603+ ArrayList <String > imageList = new ArrayList <String >();
604+ imageList .add (path );
605+ finishWithSuccess (imageList , false );
602606 }
603607
604608 private boolean setPendingMethodCallAndResult (
@@ -616,23 +620,17 @@ private boolean setPendingMethodCallAndResult(
616620 return true ;
617621 }
618622
619- private void finishWithSuccess (String imagePath ) {
623+ private void finishWithSuccess (ArrayList < String > imagePath , boolean isMultiImage ) {
620624 if (pendingResult == null ) {
621625 cache .saveResult (imagePath , null , null );
622626 return ;
623627 }
624- pendingResult .success (imagePath );
625- clearMethodCallAndResult ();
626- }
627628
628- private void finishWithListSuccess (ArrayList <String > imagePaths ) {
629- if (pendingResult == null ) {
630- for (String imagePath : imagePaths ) {
631- cache .saveResult (imagePath , null , null );
632- }
633- return ;
629+ if (isMultiImage ) {
630+ pendingResult .success (imagePath );
631+ } else {
632+ pendingResult .success (imagePath .get (0 ));
634633 }
635- pendingResult .success (imagePaths );
636634 clearMethodCallAndResult ();
637635 }
638636
0 commit comments