Search in sources :

Example 6 with RecyclerViewAdapter

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;
}
Also used : RefreshingListenerAdapter(me.dkzwm.widget.srl.RefreshingListenerAdapter) RecyclerView(android.support.v7.widget.RecyclerView) RecyclerViewAdapter(me.dkzwm.widget.srl.sample.adapter.RecyclerViewAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) Nullable(android.support.annotation.Nullable)

Aggregations

RecyclerViewAdapter (me.dkzwm.widget.srl.sample.adapter.RecyclerViewAdapter)6 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)5 RecyclerView (android.support.v7.widget.RecyclerView)4 RefreshingListenerAdapter (me.dkzwm.widget.srl.RefreshingListenerAdapter)4 View (android.view.View)3 SmoothRefreshLayout (me.dkzwm.widget.srl.SmoothRefreshLayout)3 Toolbar (android.support.v7.widget.Toolbar)2 Nullable (android.support.annotation.Nullable)1 GridLayoutManager (android.support.v7.widget.GridLayoutManager)1 MaterialSmoothRefreshLayout (me.dkzwm.widget.srl.MaterialSmoothRefreshLayout)1 ClassicFooter (me.dkzwm.widget.srl.extra.footer.ClassicFooter)1 ClassicHeader (me.dkzwm.widget.srl.extra.header.ClassicHeader)1 IIndicator (me.dkzwm.widget.srl.indicator.IIndicator)1 QuickConfigAppBarUtil (me.dkzwm.widget.srl.utils.QuickConfigAppBarUtil)1 QuickConfigAutoRefreshUtil (me.dkzwm.widget.srl.utils.QuickConfigAutoRefreshUtil)1