Search in sources :

Example 16 with RefreshingListenerAdapter

use of me.dkzwm.widget.srl.RefreshingListenerAdapter in project SmoothRefreshLayout by dkzwm.

the class TestNextRefreshAtOnceActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_test_refresh);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setTitle(R.string.enable_next_pull_to_refresh_at_once);
    mTextView = findViewById(R.id.textView_test_refresh_desc);
    mRefreshLayout = findViewById(R.id.smoothRefreshLayout_test_refresh);
    MaterialHeader header = new MaterialHeader(this);
    header.setPadding(0, PixelUtl.dp2px(this, 20), 0, PixelUtl.dp2px(this, 20));
    mRefreshLayout.setHeaderView(header);
    mRefreshLayout.setDisableLoadMore(true);
    mRefreshLayout.setEnableNextPtrAtOnce(true);
    mRefreshLayout.setOnRefreshListener(new RefreshingListenerAdapter() {

        @Override
        public void onRefreshBegin(boolean isRefresh) {
            mCount++;
            mHandler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    mRefreshLayout.refreshComplete();
                    String times = getString(R.string.number_of_refresh) + mCount;
                    mTextView.setText(times);
                }
            }, 2000);
        }
    });
    mRefreshLayout.autoRefresh(true);
}
Also used : MaterialHeader(me.dkzwm.widget.srl.extra.header.MaterialHeader) RefreshingListenerAdapter(me.dkzwm.widget.srl.RefreshingListenerAdapter)

Example 17 with RefreshingListenerAdapter

use of me.dkzwm.widget.srl.RefreshingListenerAdapter in project SmoothRefreshLayout by dkzwm.

the class TestPullToRefreshActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_test_refresh);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setTitle(R.string.pull_to_refresh);
    mTextView = findViewById(R.id.textView_test_refresh_desc);
    mRefreshLayout = findViewById(R.id.smoothRefreshLayout_test_refresh);
    MaterialHeader header = new MaterialHeader(this);
    header.setPadding(0, PixelUtl.dp2px(this, 20), 0, PixelUtl.dp2px(this, 20));
    mRefreshLayout.setHeaderView(header);
    mRefreshLayout.setEnablePullToRefresh(true);
    mRefreshLayout.setDisableLoadMore(true);
    mRefreshLayout.setOnRefreshListener(new RefreshingListenerAdapter() {

        @Override
        public void onRefreshBegin(boolean isRefresh) {
            mCount++;
            mHandler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    mRefreshLayout.refreshComplete();
                    String times = getString(R.string.number_of_refresh) + mCount;
                    mTextView.setText(times);
                }
            }, 2000);
        }
    });
    mRefreshLayout.autoRefresh(false);
}
Also used : MaterialHeader(me.dkzwm.widget.srl.extra.header.MaterialHeader) RefreshingListenerAdapter(me.dkzwm.widget.srl.RefreshingListenerAdapter)

Example 18 with RefreshingListenerAdapter

use of me.dkzwm.widget.srl.RefreshingListenerAdapter 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

RefreshingListenerAdapter (me.dkzwm.widget.srl.RefreshingListenerAdapter)18 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)4 ClassicHeader (me.dkzwm.widget.srl.extra.header.ClassicHeader)4 MaterialHeader (me.dkzwm.widget.srl.extra.header.MaterialHeader)4 RecyclerViewAdapter (me.dkzwm.widget.srl.sample.adapter.RecyclerViewAdapter)4 RecyclerView (android.support.v7.widget.RecyclerView)3 View (android.view.View)3 SmoothRefreshLayout (me.dkzwm.widget.srl.SmoothRefreshLayout)3 IIndicator (me.dkzwm.widget.srl.indicator.IIndicator)3 GridLayoutManager (android.support.v7.widget.GridLayoutManager)2 ArrayList (java.util.ArrayList)2 MaterialFooter (me.dkzwm.widget.srl.extra.footer.MaterialFooter)2 ListViewAdapter (me.dkzwm.widget.srl.sample.adapter.ListViewAdapter)2 ViewPagerAdapter (me.dkzwm.widget.srl.sample.adapter.ViewPagerAdapter)2 PageFragment (me.dkzwm.widget.srl.sample.ui.fragment.PageFragment)2 Nullable (android.support.annotation.Nullable)1 ViewTreeObserver (android.view.ViewTreeObserver)1 TextView (android.widget.TextView)1 DrawerTransformer (com.ToxicBakery.viewpager.transforms.DrawerTransformer)1 BaseQuickAdapter (com.chad.library.adapter.base.BaseQuickAdapter)1