use of me.dkzwm.widget.srl.sample.adapter.RecyclerViewAdapter in project SmoothRefreshLayout by dkzwm.
the class NestedPageFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_nested_page, container, false);
RecyclerView recyclerView = view.findViewById(R.id.recyclerView_nested_page);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.setHasFixedSize(true);
mAdapter = new RecyclerViewAdapter(getActivity(), inflater);
recyclerView.setAdapter(mAdapter);
mRefreshLayout = view.findViewById(R.id.smoothRefreshLayout_nested_page);
mRefreshLayout.setDisableLoadMore(false);
mRefreshLayout.materialStyle();
mRefreshLayout.setEnableNextPtrAtOnce(false);
mRefreshLayout.setDisableWhenAnotherDirectionMove(true);
mRefreshLayout.setOnRefreshListener(new RefreshingListenerAdapter() {
@Override
public void onRefreshBegin(final boolean isRefresh) {
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
if (isRefresh) {
mCount = 0;
List<String> list = DataUtil.createList(mCount, 20);
mCount += 20;
mAdapter.updateData(list);
} else {
List<String> list = DataUtil.createList(mCount, 20);
mCount += 20;
mAdapter.appendData(list);
}
mRefreshLayout.refreshComplete();
}
}, 2000);
}
});
mRefreshLayout.setBackgroundColor(mColor);
mRefreshLayout.autoRefresh(true);
return view;
}
Aggregations