use of com.codeest.geeknews.ui.wechat.adapter.WechatAdapter in project GeekNews by codeestX.
the class WechatMainFragment method initEventAndData.
@Override
protected void initEventAndData() {
mList = new ArrayList<>();
mAdapter = new WechatAdapter(mContext, mList);
rvWechatList.setLayoutManager(new LinearLayoutManager(mContext));
rvWechatList.setAdapter(mAdapter);
rvWechatList.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
int lastVisibleItem = ((LinearLayoutManager) rvWechatList.getLayoutManager()).findLastVisibleItemPosition();
int totalItemCount = rvWechatList.getLayoutManager().getItemCount();
if (lastVisibleItem >= totalItemCount - 2 && dy > 0) {
//还剩2个Item时加载更多
if (!isLoadingMore) {
isLoadingMore = true;
mPresenter.getMoreWechatData();
}
}
}
});
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
mPresenter.getWechatData();
}
});
ivProgress.start();
mPresenter.getWechatData();
}
Aggregations