Created
January 31, 2017 17:16
-
-
Save KowalczykBartek/5ccda12717daa823949bb8f2ddf0d69d to your computer and use it in GitHub Desktop.
This file contains 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
photos.flatMap(it -> Observable.from(it)) | |
.delay(1, TimeUnit.SECONDS) | |
.subscribeOn(AndroidSchedulers.mainThread()) | |
.flatMap(it -> { | |
view.pictureUploadProgress(it.getPictureType().name()); //to jest ustawienie widoku że wysyłam it element | |
client.uploadDriverPicture(reservationId, pictureInput) //to jest observable który wykonuje potem zapytanie i zwraca response | |
.subscribeOn(Schedulers.io()) // na tym wątku muszę wykonać zapytanie sieciowe | |
.observeOn(AndroidSchedulers.main()) //na tym wątku mogę robić update widoku, ale nie chcę tego robić tutaj | |
.doOnNext(response -> {}) | |
.doOnError(e -> Crashlytics.logException(e))) | |
.doOnError(e -> view.syncError()) | |
.doOnCompleted(() -> view.customerPicturesUploaded()) //tutaj ustawiam info że wysłałem już wszystkie zdjęcia | |
.subscribe(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment