how do we show progress indicators in 2019? like t...
# android
t
how do we show progress indicators in 2019? like the spinning circle
a
I would like to add to this question, whats the best way to show progress indicators that won't hog main thread
t
yeah, like something non-blocking or whatever is recommended by google
t
Expose UI state in a LiveData. You could define a sealed class having a
Loading
implementation, and show a
ProgressBar
if it is
Loading
, and hide it otherwise
b
another option is using something like facebook’s shimmer: https://github.com/facebook/shimmer-android or creating a similar placeholder view
t
@tseisel @Brian both perfect, thank you
đź‘Ť 1
a
I use a Lottie animation, our loading indicators are branded
device-2019-11-06-171501.mp4
v
I use a
Resource
(like [1] from Google examples) class which can hold both state (
LOADING
,
ERROR
,
SUCCESS
etc.) and data. Then I will return a
LiveData<Resource<List>>
and observe it. Once the LD delivers an update, I will check the state inside the resource and update the UI accordingly. [1] https://github.com/android/architecture-components-samples/blob/master/GithubBrowserSample/app/src/main/java/com/android/example/github/vo/Resource.kt