SHARE
TWEET

Untitled

a guest Feb 20th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fun actions() = Observable.merge<ListAction>(
  2.     recyclerView.scrollEvents()
  3.         // filter when we do a scroll up
  4.         .filter { it.dy > 0 }
  5.         // filter when recyclerView is currently loading
  6.         .filter { !isLoading }
  7.         // filter threshold
  8.         .filter {
  9.             val layoutManager = it.view.layoutManager as StaggeredGridLayoutManager
  10.             val visibleItemCount = recyclerView.childCount
  11.             val totalItemCount = layoutManager.itemCount
  12.             val firstVisibleItem = layoutManager.findFirstVisibleItemPositions(null).first()
  13.  
  14.             totalItemCount - visibleItemCount <= firstVisibleItem + GiphyListFragment.VISIBLE_THRESHOLD
  15.         }
  16.         .map { ListAction.LoadMore(adapter.list.size) }
  17.         .doOnNext { isLoading = true },
  18.     swipeRefreshLayout.refreshes().map { ListAction.Refresh() },
  19.     giphyViewItem.itemClick().map { ListAction.OnItemClick(it) }
  20. )
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