Skip to content

Instantly share code, notes, and snippets.

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 KowalczykBartek/5ccda12717daa823949bb8f2ddf0d69d to your computer and use it in GitHub Desktop.
Save KowalczykBartek/5ccda12717daa823949bb8f2ddf0d69d to your computer and use it in GitHub Desktop.
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