This repository was archived by the owner on Feb 22, 2023. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[image_picker]Android update cache#4124
Merged
fluttergithubbot merged 35 commits intoflutter:masterfromBaseflow:image_picker/android_update_cacheSep 1, 2021
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes from1 commit
Commits
Show all changes
35 commits Select commitHold shift + click to select a range
df341db Add multiRetrieve method call
ydag2d1a871 Refactor finishWithSuccess to cache list of images
ydag30a067f Refactor retrieveLostImage method
ydag01ad85e Add new MAP_KEY_PATH_LIST key
ydag5a9e99f Refactor saveTypeWithMethodCallName
ydag364c79d Update saveResult method
ydag757da4c Update the getCacheMap method
ydag3418641 Add statement to return null
ydag74f3990 Merge branch 'master' into image_picker/android_update_cache
ydag93de29f Update CHANGELOG and version number
ydag9264ad9 Revert "Refactor finishWithSuccess to cache list of images"
ydage585603 Refactor finishWithSuccess method
ydag33fb183 Update dependency version
ydag226ef21 Merge branch 'master' into image_picker/android_update_cache
ydagec4079e Update version and CHANGELOG
ydaga675352 Add unit tests
ydag91fd73d Update CHANGELOG
ydag56c29b0 Update dependency version
ydag156d845 Remove unused method call
ydagc38ad2b Remove unit tests from deprecated LostData
ydag27f87ca Remove redundant unit test
ydagc567525 Refactor to assign the last item to path to avoid breaking change
ydag0454d80 Refactor retrieveLostData multiple files unit test
ydagdb5d48e Update the dependency version
ydagca9c5b2 Merge branch 'master' into image_picker/android_update_cache
ydage8d71e9 Fix the length call
ydaga1555bb Merge branch 'master' into image_picker/android_update_cache
ydag933931b Update the CHANGELOG
ydagc08c461 Update CHANGELOG
ydaga43ffeb Add null check
ydagced68ec Add unit test
ydag0325f33 Update the example app
ydag29d9e0e Remove redundant comment
ydag4ad0263 Refactor handleMultiImageResult
ydag0764514 Variable rename
BeMacizedFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
Refactor finishWithSuccess to cache list of images
I removed the finishWithListSuccess method since it was a temporary solution to save only the last image when multiple images are picked. With the new implementation of caching, finishWithSuccess method save always a list of images to the cache.
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
commit2d1a871eeaa277be7421b0846ba479c95ee9a167
There are no files selected for viewing
38 changes: 18 additions & 20 deletions...mage_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -488,7 +488,7 @@ private void handleChooseImageResult(int resultCode, Intent data) { | ||
| } | ||
| // User cancelled choosing a picture. | ||
| finishWithSuccess(null, false); | ||
| } | ||
| private void handleChooseMultiImageResult(int resultCode, Intent intent) { | ||
| @@ -506,7 +506,7 @@ private void handleChooseMultiImageResult(int resultCode, Intent intent) { | ||
| } | ||
| // User cancelled choosing a picture. | ||
| finishWithSuccess(null, false); | ||
| } | ||
| private void handleChooseVideoResult(int resultCode, Intent data) { | ||
| @@ -517,7 +517,7 @@ private void handleChooseVideoResult(int resultCode, Intent data) { | ||
| } | ||
| // User cancelled choosing a picture. | ||
| finishWithSuccess(null, false); | ||
| } | ||
| private void handleCaptureImageResult(int resultCode) { | ||
| @@ -536,7 +536,7 @@ public void onPathReady(String path) { | ||
| } | ||
| // User cancelled taking a picture. | ||
| finishWithSuccess(null, false); | ||
| } | ||
| private void handleCaptureVideoResult(int resultCode) { | ||
| @@ -555,7 +555,7 @@ public void onPathReady(String path) { | ||
| } | ||
| // User cancelled taking a picture. | ||
| finishWithSuccess(null, false); | ||
| } | ||
| private void handleMultiImageResult( | ||
| @@ -572,21 +572,23 @@ private void handleMultiImageResult( | ||
| } | ||
| paths.set(i, finalImagePath); | ||
| } | ||
| finishWithSuccess(paths, true); | ||
| } | ||
| } | ||
| private void handleImageResult(String path, boolean shouldDeleteOriginalIfScaled) { | ||
| ArrayList<String> imageList = new ArrayList<String>(); | ||
| if (methodCall != null) { | ||
| String finalImagePath = getResizedImagePath(path); | ||
| //delete original file if scaled | ||
| if (finalImagePath != null && !finalImagePath.equals(path) && shouldDeleteOriginalIfScaled) { | ||
| new File(path).delete(); | ||
| } | ||
| imageList.add(finalImagePath); | ||
| } else { | ||
| imageList.add(path); | ||
| } | ||
| finishWithSuccess(imageList, false); | ||
| } | ||
| private String getResizedImagePath(String path) { | ||
| @@ -598,7 +600,9 @@ private String getResizedImagePath(String path) { | ||
| } | ||
| private void handleVideoResult(String path) { | ||
| ArrayList<String> imageList = new ArrayList<String>(); | ||
| imageList.add(path); | ||
| finishWithSuccess(imageList, false); | ||
| } | ||
| private boolean setPendingMethodCallAndResult( | ||
| @@ -616,23 +620,17 @@ private boolean setPendingMethodCallAndResult( | ||
| return true; | ||
| } | ||
| private void finishWithSuccess(ArrayList<String> imagePath, boolean isMultiImage) { | ||
ydag marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| if (pendingResult == null) { | ||
| cache.saveResult(imagePath, null, null); | ||
| return; | ||
| } | ||
| if (isMultiImage) { | ||
| pendingResult.success(imagePath); | ||
| } else { | ||
| pendingResult.success(imagePath.get(0)); | ||
| } | ||
| clearMethodCallAndResult(); | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.