use of me.dkzwm.widget.srl.sample.adapter.LoadMoreRecyclerViewAdapter in project SmoothRefreshLayout by dkzwm.
the class TestBaseRecyclerViewAdapterActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setTitle(R.string.test_base_recyclerView_adapter);
setContentView(R.layout.activity_test_base_recyclerview_adapter);
mRefreshLayout = findViewById(R.id.smoothRefreshLayout_test_base_recyclerView_adapter);
ClassicHeader classicHeader = new ClassicHeader(this);
classicHeader.setLastUpdateTimeKey("header_last_update_time");
mRefreshLayout.setHeaderView(classicHeader);
mRefreshLayout.setOnRefreshListener(new RefreshingListenerAdapter() {
@Override
public void onRefreshing() {
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
List<String> list = DataUtil.createList(mCount, 20);
mCount = list.size();
mAdapter.setNewData(list);
mRefreshLayout.refreshComplete();
}
}, 2000);
}
});
mAdapter = new LoadMoreRecyclerViewAdapter(this);
mAdapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {
@Override
public void onLoadMoreRequested() {
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
List<String> list = DataUtil.createList(mCount, 20);
mCount += list.size();
mAdapter.addData(list);
mAdapter.loadMoreComplete();
mRefreshLayout.refreshComplete();
}
}, 2000);
}
}, mRecyclerView);
mRefreshLayout.autoRefresh(true);
mRecyclerView = findViewById(R.id.recyclerView_test_base_recyclerView_adapter);
mRecyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setAdapter(mAdapter);
}
Aggregations