@@ -488,7 +488,7 @@ private void handleChooseImageResult(int resultCode, Intent data) {
488
488
}
489
489
490
490
// User cancelled choosing a picture.
491
- finishWithSuccess (null );
491
+ finishWithSuccess (null , false );
492
492
}
493
493
494
494
private void handleChooseMultiImageResult (int resultCode , Intent intent ) {
@@ -506,7 +506,7 @@ private void handleChooseMultiImageResult(int resultCode, Intent intent) {
506
506
}
507
507
508
508
// User cancelled choosing a picture.
509
- finishWithSuccess (null );
509
+ finishWithSuccess (null , false );
510
510
}
511
511
512
512
private void handleChooseVideoResult (int resultCode , Intent data ) {
@@ -517,7 +517,7 @@ private void handleChooseVideoResult(int resultCode, Intent data) {
517
517
}
518
518
519
519
// User cancelled choosing a picture.
520
- finishWithSuccess (null );
520
+ finishWithSuccess (null , false );
521
521
}
522
522
523
523
private void handleCaptureImageResult (int resultCode ) {
@@ -536,7 +536,7 @@ public void onPathReady(String path) {
536
536
}
537
537
538
538
// User cancelled taking a picture.
539
- finishWithSuccess (null );
539
+ finishWithSuccess (null , false );
540
540
}
541
541
542
542
private void handleCaptureVideoResult (int resultCode ) {
@@ -555,7 +555,7 @@ public void onPathReady(String path) {
555
555
}
556
556
557
557
// User cancelled taking a picture.
558
- finishWithSuccess (null );
558
+ finishWithSuccess (null , false );
559
559
}
560
560
561
561
private void handleMultiImageResult (
@@ -572,21 +572,23 @@ private void handleMultiImageResult(
572
572
}
573
573
paths .set (i , finalImagePath );
574
574
}
575
- finishWithListSuccess (paths );
575
+ finishWithSuccess (paths , true );
576
576
}
577
577
}
578
578
579
579
private void handleImageResult (String path , boolean shouldDeleteOriginalIfScaled ) {
580
+ ArrayList <String > imageList = new ArrayList <String >();
580
581
if (methodCall != null ) {
581
582
String finalImagePath = getResizedImagePath (path );
582
583
//delete original file if scaled
583
584
if (finalImagePath != null && !finalImagePath .equals (path ) && shouldDeleteOriginalIfScaled ) {
584
585
new File (path ).delete ();
585
586
}
586
- finishWithSuccess (finalImagePath );
587
+ imageList . add (finalImagePath );
587
588
} else {
588
- finishWithSuccess (path );
589
+ imageList . add (path );
589
590
}
591
+ finishWithSuccess (imageList , false );
590
592
}
591
593
592
594
private String getResizedImagePath (String path ) {
@@ -598,7 +600,9 @@ private String getResizedImagePath(String path) {
598
600
}
599
601
600
602
private void handleVideoResult (String path ) {
601
- finishWithSuccess (path );
603
+ ArrayList <String > imageList = new ArrayList <String >();
604
+ imageList .add (path );
605
+ finishWithSuccess (imageList , false );
602
606
}
603
607
604
608
private boolean setPendingMethodCallAndResult (
@@ -616,23 +620,17 @@ private boolean setPendingMethodCallAndResult(
616
620
return true ;
617
621
}
618
622
619
- private void finishWithSuccess (String imagePath ) {
623
+ private void finishWithSuccess (ArrayList < String > imagePath , boolean isMultiImage ) {
620
624
if (pendingResult == null ) {
621
625
cache .saveResult (imagePath , null , null );
622
626
return ;
623
627
}
624
- pendingResult .success (imagePath );
625
- clearMethodCallAndResult ();
626
- }
627
628
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 ));
634
633
}
635
- pendingResult .success (imagePaths );
636
634
clearMethodCallAndResult ();
637
635
}
638
636
0 commit comments