Skip to content

Instantly share code, notes, and snippets.

@Priyansh-Kedia
Created September 15, 2021 10:19
Show Gist options
  • Save Priyansh-Kedia/2567421d248f8d0b7f2f62f6b2e842ba to your computer and use it in GitHub Desktop.
Save Priyansh-Kedia/2567421d248f8d0b7f2f62f6b2e842ba to your computer and use it in GitHub Desktop.
Observing file upload status RxJava
LiveSubject.FILE_UPLOAD_FILE.subscribe({
when(it) {
is UploadFileStatus.Complete -> {
Glide.with(this).load(it.s3Url).into(image)
toast("Uploaded image")
logD("complete upload")
}
is UploadFileStatus.Error -> {
logE("could not upload")
}
is UploadFileStatus.FileStatus -> {
logV("status is ${it.status}")
progress.progress = it.status
}
is UploadFileStatus.Start -> {
logD("Upload started")
}
}
}, {
logE("Rx threw error, error $it ${it.printStackTrace()}")
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment