SHARE
TWEET

Untitled

a guest Feb 20th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fun ListState.render(): Unit? = when (this) {
  2.     is ListState.Screen -> {
  3.         when(loadingMode) {
  4.             ListState.Mode.REFRESH -> { swipeRefreshLayout.isRefreshing = true }
  5.             ListState.Mode.LOAD_MORE -> adapter.showFooter()
  6.             ListState.Mode.IDLE_LOAD_MORE -> {
  7.                 adapter.addItems(giphies)
  8.                 isLoading = false
  9.  
  10.                 restoreRecyclerView(giphies)
  11.             }
  12.             ListState.Mode.IDLE_REFRESH -> {
  13.                 swipeRefreshLayout.isRefreshing = false
  14.                 adapter.list = giphies
  15.                 isLoading = false
  16.  
  17.                 restoreRecyclerView(giphies)
  18.             }
  19.         }
  20.     }
  21.     is ListState.Error -> {
  22.         swipeRefreshLayout.isRefreshing = false
  23.         showSnackbar(errorMessage)
  24.     }
  25.     is ListState.GoToDetail -> view
  26.         ?.findNavController()
  27.         ?.navigate(R.id.action_giphyListFragment_to_giphyDetailFragment,
  28.             GiphyDetailFragment.getBundle(giphy))
  29.         ?.also {
  30.             pendingRestore = recyclerView.layoutManager?.onSaveInstanceState()
  31.         }
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top