https://kotlinlang.org logo
Title
t

Tim

11/06/2019, 4:34 PM
how do we show progress indicators in 2019? like the spinning circle
a

Alex Crafford

11/06/2019, 4:42 PM
I would like to add to this question, whats the best way to show progress indicators that won't hog main thread
t

Tim

11/06/2019, 4:43 PM
yeah, like something non-blocking or whatever is recommended by google
t

tseisel

11/06/2019, 5:19 PM
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

Brian

11/06/2019, 5:22 PM
another option is using something like facebook’s shimmer: https://github.com/facebook/shimmer-android or creating a similar placeholder view
t

Tim

11/06/2019, 5:24 PM
@tseisel @Brian both perfect, thank you
👍 1
a

andrew

11/06/2019, 10:14 PM
I use a Lottie animation, our loading indicators are branded
v

Vishnu Haridas

11/07/2019, 9:07 AM
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