use of me.ccrama.redditslide.Fragments.SubmissionsView in project Slide by ccrama.
the class MainActivity method scrollToTop.
public void scrollToTop() {
int[] firstVisibleItems;
int pastVisiblesItems = 0;
if (((adapter.getCurrentFragment()) == null))
return;
firstVisibleItems = ((CatchStaggeredGridLayoutManager) (((SubmissionsView) adapter.getCurrentFragment()).rv.getLayoutManager())).findFirstVisibleItemPositions(null);
if (firstVisibleItems != null && firstVisibleItems.length > 0) {
for (int firstVisibleItem : firstVisibleItems) {
pastVisiblesItems = firstVisibleItem;
}
}
if (pastVisiblesItems > 8) {
((SubmissionsView) adapter.getCurrentFragment()).rv.scrollToPosition(0);
header.animate().translationY(header.getHeight()).setInterpolator(new LinearInterpolator()).setDuration(0);
} else {
((SubmissionsView) adapter.getCurrentFragment()).rv.smoothScrollToPosition(0);
}
((SubmissionsView) adapter.getCurrentFragment()).resetScroll();
}
Aggregations