Created
March 11, 2016 15:10
-
-
Save aleien/7e69ebcf4e3bc6fb6af3 to your computer and use it in GitHub Desktop.
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
public Observable<List<String>> uploadImages(List<GalleryImage> images) { | |
return Observable.from(images) | |
.map(galleryImage -> checkImageSize(galleryImage)) | |
.flatMap(galleryImage -> | |
uploadWebService.uploadPic( | |
new TypedFile(Utils.getMimeType(galleryImage.path()), new File(galleryImage.path())))) | |
.map(FileUploadResponse::filename) | |
.toList(); | |
} | |
// супер псевдо-код | |
GalleryImage checkImageSize(GalleryImage galleryImage) { | |
Pair<int, int> size = getBitmapSizesFromUri(galleryImage.uri()); // реализацию в Utils запихнуть | |
if (size.first > 6000 || size.second > 6000) { | |
Bitmap resizedBitmap = Utils.decodeSampledBitmap(galleryImage.uri().path(), 6000, 6000); | |
return Utils.saveTmpPicture(resizedBitmap, ...); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://reactivex.io/documentation/operators/map.html
За компанию прочитай (: