@Override protected void processLogic(Bundle savedInstanceState) { mRefreshLayout.setCustomHeaderView(DataEngine.getCustomHeaderView(mApp), true); mRefreshLayout.setRefreshViewHolder(new BGANormalRefreshViewHolder(mApp, true)); StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL); mDataRv.setLayoutManager(layoutManager); mDataRv.setAdapter(mAdapter); }
@Override protected void onUserVisible() { mNewPageNumber = 0; mMorePageNumber = 0; DataEngine.loadDefaultStaggeredData( new DataEngine.StaggeredModelResponseHandler() { @Override public void onFailure() {} @Override public void onSuccess(List<StaggeredModel> staggeredModels) { mAdapter.setDatas(staggeredModels); } }); }
@Override public boolean onBGARefreshLayoutBeginLoadingMore(BGARefreshLayout refreshLayout) { mMorePageNumber++; if (mMorePageNumber > 5) { mRefreshLayout.endLoadingMore(); showToast("没有更多数据了"); return false; } DataEngine.loadMoreStaggeredData( mMorePageNumber, new DataEngine.StaggeredModelResponseHandler() { @Override public void onFailure() { mRefreshLayout.endLoadingMore(); } @Override public void onSuccess(List<StaggeredModel> staggeredModels) { mRefreshLayout.endLoadingMore(); mAdapter.addMoreDatas(staggeredModels); } }); return true; }
@Override public void onBGARefreshLayoutBeginRefreshing(BGARefreshLayout refreshLayout) { mNewPageNumber++; if (mNewPageNumber > 4) { mRefreshLayout.endRefreshing(); showToast("没有最新数据了"); return; } DataEngine.loadNewStaggeredData( mNewPageNumber, new DataEngine.StaggeredModelResponseHandler() { @Override public void onFailure() { mRefreshLayout.endRefreshing(); } @Override public void onSuccess(List<StaggeredModel> staggeredModels) { mRefreshLayout.endRefreshing(); mAdapter.addNewDatas(staggeredModels); mDataRv.smoothScrollToPosition(0); } }); }