Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ValeryPonomarenko/12ea29b487d3e761c61b86c4f506ab9a to your computer and use it in GitHub Desktop.
Save ValeryPonomarenko/12ea29b487d3e761c61b86c4f506ab9a to your computer and use it in GitHub Desktop.
//EmptyQuery state
class EmptyQueryViewStateRenderer @Inject constructor(): ViewStateRenderer<DestinationViewState> {
override fun render(view: View, viewState: DestinationViewState) {
view.text_message.visibility = View.VISIBLE
view.progress.visibility = View.GONE
view.recyclerView_destinations.visibility = View.GONE
view.text_message.text = "Enter the city you want to flight"
}
}
//Loading state
class LoadingViewStateRenderer @Inject constructor() : ViewStateRenderer<DestinationViewState> {
override fun render(view: View, viewState: DestinationViewState) {
view.progress.visibility = View.VISIBLE
view.text_message.visibility = View.GONE
}
}
//EmptyResult state
class EmptyViewStateRenderer @Inject constructor(): ViewStateRenderer<DestinationViewState> {
override fun render(view: View, viewState: DestinationViewState) {
view.text_message.visibility = View.VISIBLE
view.progress.visibility = View.GONE
view.recyclerView_destinations.visibility = View.GONE
view.text_message.text = Oooops! Do you really want to travel to ${viewState.query}?
}
}
//Loaded state
class RegularViewStateRenderer @Inject constructor(
private val adapter: DestinationsAdapter
) : ViewStateRenderer<DestinationViewState> {
override fun render(view: View, viewState: DestinationViewState) {
view.progress.visibility = View.GONE
view.text_message.visibility = View.GONE
view.recyclerView_destinations.visibility = View.VISIBLE
adapter.update(viewState.destinations)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment