Cloned from Juliano Moraes Repo. https://github.com/julianomoraes/componentizationArch
...
LoadingPresenter(
LoadingView(rootViewContainer),
screenStateEvent,
destroyObservable
)
...
...
screenStateEvent
.takeUntil(destroyObservable)
.subscribeBy(
onNext = {
when (it) {
ScreenStateEvent.Loading -> {
uiView.show()
}
ScreenStateEvent.Loaded -> {
uiView.hide()
}
ScreenStateEvent.Error -> {
uiView.hide()
}
}
}
)
...
class LoadingView(container: ViewGroup) : UIView<UserInteractionEvent>(container) {
override val view: View = LayoutInflater.from(container.context).inflate(R.layout.loading, container, false)
init {
container.addView(view)
}
}