use of me.ccrama.redditslide.Adapters.SubredditNames in project Slide by ccrama.
the class SubredditListView method doAdapter.
public void doAdapter() {
mSwipeRefreshLayout.post(new Runnable() {
@Override
public void run() {
mSwipeRefreshLayout.setRefreshing(true);
}
});
posts = new SubredditNames(where, getContext(), SubredditListView.this);
adapter = new SubredditAdapter(getActivity(), posts, rv, where, this);
rv.setAdapter(adapter);
posts.loadMore(mSwipeRefreshLayout.getContext(), true, where);
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
refresh();
}
});
rv.addOnScrollListener(new ToolbarScrollHideHandler(((BaseActivity) getActivity()).mToolbar, getActivity().findViewById(R.id.header)) {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
if (!posts.loading && !posts.nomore) {
visibleItemCount = rv.getLayoutManager().getChildCount();
totalItemCount = rv.getLayoutManager().getItemCount();
pastVisiblesItems = ((LinearLayoutManager) rv.getLayoutManager()).findFirstVisibleItemPosition();
if ((visibleItemCount + pastVisiblesItems) >= totalItemCount) {
posts.loading = true;
LogUtil.v("Loading more");
posts.loadMore(mSwipeRefreshLayout.getContext(), false, where);
}
}
}
});
}
Aggregations