Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private fun resultToViewState(result: Lce<MSMovieResult>) {
- currentViewState = when (result) {
- is Lce.Content -> {
- when (result.packet) {
- is ScreenLoadResult -> { currentViewState.copy(searchBoxText = "") }
- is SearchMovieResult -> {
- val movie: MSMovie = result.packet.movie
- currentViewState.copy(
- searchedMovieTitle = movie.title,
- searchedMovieRating = movie.ratingSummary,
- searchedMoviePoster = movie.posterUrl,
- searchedMovieReference = movie
- )
- }
- // other results
- }
- }
- is Lce.Loading -> {
- currentViewState.copy(
- searchBoxText = null,
- searchedMovieTitle = "Searching Movie...",
- // other fields
- )
- }
- is Lce.Error -> {
- when (result.packet) {
- is SearchMovieResult -> {
- val movie: MSMovie = result.packet.movie
- currentViewState.copy(searchedMovieTitle = movie.errorMessage!!)
- }
- // other results
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement