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 - Fork 9.7k
[image_picker]Android update cache #4124
Merged
fluttergithubbot
merged 35 commits into
flutter:master
from
Baseflow:image_picker/android_update_cache
Sep 1, 2021
Merged
Changes from 19 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
df341db
Add multiRetrieve method call
ydag 2d1a871
Refactor finishWithSuccess to cache list of images
ydag 30a067f
Refactor retrieveLostImage method
ydag 01ad85e
Add new MAP_KEY_PATH_LIST key
ydag 5a9e99f
Refactor saveTypeWithMethodCallName
ydag 364c79d
Update saveResult method
ydag 757da4c
Update the getCacheMap method
ydag 3418641
Add statement to return null
ydag 74f3990
Merge branch 'master' into image_picker/android_update_cache
ydag 93de29f
Update CHANGELOG and version number
ydag 9264ad9
Revert "Refactor finishWithSuccess to cache list of images"
ydag e585603
Refactor finishWithSuccess method
ydag 33fb183
Update dependency version
ydag 226ef21
Merge branch 'master' into image_picker/android_update_cache
ydag ec4079e
Update version and CHANGELOG
ydag a675352
Add unit tests
ydag 91fd73d
Update CHANGELOG
ydag 56c29b0
Update dependency version
ydag 156d845
Remove unused method call
ydag c38ad2b
Remove unit tests from deprecated LostData
ydag 27f87ca
Remove redundant unit test
ydag c567525
Refactor to assign the last item to path to avoid breaking change
ydag 0454d80
Refactor retrieveLostData multiple files unit test
ydag db5d48e
Update the dependency version
ydag ca9c5b2
Merge branch 'master' into image_picker/android_update_cache
ydag e8d71e9
Fix the length call
ydag a1555bb
Merge branch 'master' into image_picker/android_update_cache
ydag 933931b
Update the CHANGELOG
ydag c08c461
Update CHANGELOG
ydag a43ffeb
Add null check
ydag ced68ec
Add unit test
ydag 0325f33
Update the example app
ydag 29d9e0e
Remove redundant comment
ydag 4ad0263
Refactor handleMultiImageResult
ydag 0764514
Variable rename
BeMacized File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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 |
|---|---|---|
|
|
@@ -229,17 +229,21 @@ void saveStateBeforeResult() { | |
|
|
||
| void retrieveLostImage(MethodChannel.Result result) { | ||
| Map<String, Object> resultMap = cache.getCacheMap(); | ||
| String path = (String) resultMap.get(cache.MAP_KEY_PATH); | ||
| if (path != null) { | ||
| Double maxWidth = (Double) resultMap.get(cache.MAP_KEY_MAX_WIDTH); | ||
| Double maxHeight = (Double) resultMap.get(cache.MAP_KEY_MAX_HEIGHT); | ||
| int imageQuality = | ||
| resultMap.get(cache.MAP_KEY_IMAGE_QUALITY) == null | ||
| ? 100 | ||
| : (int) resultMap.get(cache.MAP_KEY_IMAGE_QUALITY); | ||
|
|
||
| String newPath = imageResizer.resizeImageIfNeeded(path, maxWidth, maxHeight, imageQuality); | ||
| resultMap.put(cache.MAP_KEY_PATH, newPath); | ||
| ArrayList<String> pathList = (ArrayList<String>) resultMap.get(cache.MAP_KEY_PATH_LIST); | ||
| ArrayList<String> newPathList = new ArrayList<>(); | ||
| if (pathList != null) { | ||
| for (String path : pathList) { | ||
| Double maxWidth = (Double) resultMap.get(cache.MAP_KEY_MAX_WIDTH); | ||
| Double maxHeight = (Double) resultMap.get(cache.MAP_KEY_MAX_HEIGHT); | ||
| int imageQuality = | ||
| resultMap.get(cache.MAP_KEY_IMAGE_QUALITY) == null | ||
| ? 100 | ||
| : (int) resultMap.get(cache.MAP_KEY_IMAGE_QUALITY); | ||
|
|
||
| newPathList.add(imageResizer.resizeImageIfNeeded(path, maxWidth, maxHeight, imageQuality)); | ||
| } | ||
| resultMap.put(cache.MAP_KEY_PATH_LIST, newPathList); | ||
| resultMap.put(cache.MAP_KEY_PATH, newPathList.get(0)); | ||
| } | ||
| if (resultMap.isEmpty()) { | ||
| result.success(null); | ||
|
|
@@ -619,21 +623,21 @@ private boolean setPendingMethodCallAndResult( | |
|
|
||
| private void finishWithSuccess(String imagePath) { | ||
| if (pendingResult == null) { | ||
| cache.saveResult(imagePath, null, null); | ||
| ArrayList<String> pathList = new ArrayList<>(); | ||
| pathList.add(imagePath); | ||
| cache.saveResult(pathList, null, null); | ||
| return; | ||
| } | ||
| pendingResult.success(imagePath); | ||
| clearMethodCallAndResult(); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To prevent code duplication you can update this method to use the private void finishWithSuccess(String imagePath) {
ArrayList<String> imagePaths = new ArrayList<String>();
imagePaths.add(imagePath);
this.finishWithListSuccess(imagePaths);
}
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mvanbeusekom This solution won't actually work as |
||
|
|
||
| private void finishWithListSuccess(ArrayList<String> imagePaths) { | ||
| private void finishWithListSuccess(ArrayList<String> imagePath) { | ||
BeMacized marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (pendingResult == null) { | ||
| for (String imagePath : imagePaths) { | ||
| cache.saveResult(imagePath, null, null); | ||
| } | ||
| cache.saveResult(imagePath, null, null); | ||
| return; | ||
| } | ||
| pendingResult.success(imagePaths); | ||
| pendingResult.success(imagePath); | ||
| clearMethodCallAndResult(); | ||
| } | ||
|
|
||
|
|
||
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
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.