Created
October 26, 2016 13:58
-
-
Save thanhtoan1196/894d27c017fdf28f7757dde8f67277e7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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