Skip to content

Instantly share code, notes, and snippets.

@aleien
Created March 11, 2016 15:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aleien/7e69ebcf4e3bc6fb6af3 to your computer and use it in GitHub Desktop.
Save aleien/7e69ebcf4e3bc6fb6af3 to your computer and use it in GitHub Desktop.
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, ...);
}
}
@aleien
Copy link
Author

aleien commented Mar 11, 2016

http://reactivex.io/documentation/operators/map.html
За компанию прочитай (:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment