Lifecycle aware, testable and reusable UI components for Android.
Droidcon SF 2018 Talk (Comming Soon)
...
LoadingComponent(container, EventBusFactory.get(this))
...
...
bus.getSafeManagedObservable(ScreenStateEvent::class.java)
.subscribe {
when (it) {
ScreenStateEvent.Loading -> {
uiView.show()
}
ScreenStateEvent.Loaded -> {
uiView.hide()
}
ScreenStateEvent.Error -> {
uiView.hide()
}
}
}
...
class LoadingView(container: ViewGroup) : UIView<UserInteractionEvent>(container) {
private val view: View =
LayoutInflater.from(container.context).inflate(R.layout.loading, container, true)
.findViewById(R.id.loadingSpinner)
...