Created
April 24, 2019 19:45
-
-
Save ValeryPonomarenko/12ea29b487d3e761c61b86c4f506ab9a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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