Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. private fun resultToViewState(result: Lce<MSMovieResult>) {
  2. currentViewState = when (result) {
  3. is Lce.Content -> {
  4. when (result.packet) {
  5. is ScreenLoadResult -> { currentViewState.copy(searchBoxText = "") }
  6. is SearchMovieResult -> {
  7. val movie: MSMovie = result.packet.movie
  8. currentViewState.copy(
  9. searchedMovieTitle = movie.title,
  10. searchedMovieRating = movie.ratingSummary,
  11. searchedMoviePoster = movie.posterUrl,
  12. searchedMovieReference = movie
  13. )
  14. }
  15. // other results
  16. }
  17. }
  18. is Lce.Loading -> {
  19. currentViewState.copy(
  20. searchBoxText = null,
  21. searchedMovieTitle = "Searching Movie...",
  22. // other fields
  23. )
  24. }
  25. is Lce.Error -> {
  26. when (result.packet) {
  27. is SearchMovieResult -> {
  28. val movie: MSMovie = result.packet.movie
  29. currentViewState.copy(searchedMovieTitle = movie.errorMessage!!)
  30. }
  31. // other results
  32. }
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement