Skip to content

Instantly share code, notes, and snippets.

@thanhtoan1196
Created October 26, 2016 13:58
Show Gist options
  • Save thanhtoan1196/894d27c017fdf28f7757dde8f67277e7 to your computer and use it in GitHub Desktop.
Save thanhtoan1196/894d27c017fdf28f7757dde8f67277e7 to your computer and use it in GitHub Desktop.
RxRecyclerView.scrollEvents(binding.recyclerView)
.compose(bindUntilEvent(ActivityEvent.DESTROY))
.map(scrollEvent -> {
boolean isBottom = false;
if (ConfigUtils.isOrientationPortrait(this)) {
isBottom = layoutManager.findLastCompletelyVisibleItemPositions(
new int[2])[1] >= mImages.size() - 4;
} else if (ConfigUtils.isOrientationLandscape(this)) {
isBottom = layoutManager.findLastCompletelyVisibleItemPositions(
new int[3])[2] >= mImages.size() - 4;
}
return isBottom;
})
.filter(isBottom -> !binding.refreshLayout.isRefreshing() && isBottom)
.subscribe(recyclerViewScrollEvent ->{
if (refreshing) {
page = 0;
refreshing = false;
}
page += 1;
binding.refreshLayout.setRefreshing(true);
fetchGirlData();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment