Search in sources :

Example 1 with CustomLoadDetailFooter

use of me.dkzwm.widget.srl.sample.footer.CustomLoadDetailFooter in project SmoothRefreshLayout by dkzwm.

the class TestMultiDirectionViewsActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_test_multi_direction_views);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setTitle(R.string.test_multi_direction_views);
    mRefreshLayout = findViewById(R.id.smoothRefreshLayout_test_multi_direction_views);
    ClassicHeader header = new ClassicHeader(this);
    mRefreshLayout.setHeaderView(header);
    mRefreshLayout.setEnableKeepRefreshView(true);
    mRefreshLayout.setDisableWhenAnotherDirectionMove(true);
    mRefreshLayout.setEnableCheckInsideAnotherDirectionView(true);
    mRefreshLayout.setOnRefreshListener(new RefreshingListenerAdapter() {

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

                @Override
                public void run() {
                    mViewPager.setCurrentItem(0, true);
                    mRefreshLayout.refreshComplete();
                }
            }, 2000);
        }
    });
    mViewPager = findViewById(R.id.viewPager_test_multi_direction_views_pager);
    List<PageFragment> fragments = new ArrayList<>();
    for (int i = 0; i < sColors.length; i++) {
        fragments.add(PageFragment.newInstance(i, sColors[i]));
    }
    mAdapter = new ViewPagerAdapter(getSupportFragmentManager(), fragments);
    mViewPager.setAdapter(mAdapter);
    mRefreshLayout.autoRefresh(false);
    mTextView = findViewById(R.id.textView_load_detail_footer_details);
    mScrollView = findViewById(R.id.scrollView_test_multi_direction_views);
    mInnerRefreshLayout = findViewById(R.id.smoothRefreshLayout_test_multi_direction_views_inner);
    mInnerRefreshLayout.setDisableRefresh(true);
    mInnerRefreshLayout.setDisableLoadMore(false);
    mInnerRefreshLayout.setLoadingMinTime(0);
    mInnerRefreshLayout.setEnableOverScroll(false);
    CustomLoadDetailFooter footer = new CustomLoadDetailFooter(this);
    mInnerRefreshLayout.setFooterView(footer);
    mInnerRefreshLayout.setOnRefreshListener(new RefreshingListenerAdapter() {

        @Override
        public void onRefreshBegin(boolean isRefresh) {
            mInnerRefreshLayout.setDurationToClose(500);
            mInnerRefreshLayout.refreshComplete();
            mInnerRefreshLayout.setDurationToClose(500);
            mScrollView.smoothScrollTo(0, mTextView.getTop());
        }
    });
}
Also used : ClassicHeader(me.dkzwm.widget.srl.extra.header.ClassicHeader) RefreshingListenerAdapter(me.dkzwm.widget.srl.RefreshingListenerAdapter) ArrayList(java.util.ArrayList) PageFragment(me.dkzwm.widget.srl.sample.ui.fragment.PageFragment) ViewPagerAdapter(me.dkzwm.widget.srl.sample.adapter.ViewPagerAdapter) CustomLoadDetailFooter(me.dkzwm.widget.srl.sample.footer.CustomLoadDetailFooter)

Aggregations

ArrayList (java.util.ArrayList)1 RefreshingListenerAdapter (me.dkzwm.widget.srl.RefreshingListenerAdapter)1 ClassicHeader (me.dkzwm.widget.srl.extra.header.ClassicHeader)1 ViewPagerAdapter (me.dkzwm.widget.srl.sample.adapter.ViewPagerAdapter)1 CustomLoadDetailFooter (me.dkzwm.widget.srl.sample.footer.CustomLoadDetailFooter)1 PageFragment (me.dkzwm.widget.srl.sample.ui.fragment.PageFragment)1