Retrofit: is it possible to show progress bar (percent) when downloading file in retrofit 2, android.

Created on 26 Apr 2016  路  3Comments  路  Source: square/retrofit

is it possible to show progress bar (percent) when downloading file in retrofit 2, android.

Most helpful comment

can you explain it in more detail

All 3 comments

If you use @Streaming + ResponseBody in your endpoint declaration...

@Streaming
@GET("/path/to/file")
Call<ResponseBody> getFile();

then you can use the progress sample code from OkHttp to decorate the ResponseBody with one that tracks progress: https://github.com/square/okhttp/blob/209c6c5589d7b0a0f10b4ce78ac6be0740a5cea8/samples/guide/src/main/java/okhttp3/recipes/Progress.java#L68

can you explain it in more detail

@JakeWharton just want to add to the info provided here. This call https://github.com/square/okhttp/blob/209c6c5589d7b0a0f10b4ce78ac6be0740a5cea8/samples/guide/src/main/java/okhttp3/recipes/Progress.java#L102 will be made repeatedly, hence one might want to have a check here to update the UI like after every second.

Was this page helpful?
0 / 5 - 0 ratings