Search in sources :

Example 1 with ViewPagerAdapter

use of me.dkzwm.widget.srl.sample.adapter.ViewPagerAdapter 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.setOnRefreshListener(new RefreshingListenerAdapter() {

        @Override
        public void onRefreshing() {
            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.setEnableOverScroll(false);
    CustomLoadDetailFooter footer = new CustomLoadDetailFooter(this);
    mInnerRefreshLayout.setFooterView(footer);
    mInnerRefreshLayout.setOnRefreshListener(new RefreshingListenerAdapter() {

        @Override
        public void onRefreshing() {
        }

        @Override
        public void onLoadingMore() {
            mInnerRefreshLayout.setDurationToClose(0);
            mInnerRefreshLayout.refreshComplete();
            mRefreshLayout.setDurationToClose(0);
            mRefreshLayout.refreshComplete();
            mInnerRefreshLayout.setDurationToClose(500);
            mRefreshLayout.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)

Example 2 with ViewPagerAdapter

use of me.dkzwm.widget.srl.sample.adapter.ViewPagerAdapter in project SmoothRefreshLayout by dkzwm.

the class TestNestedHorizontalViewsActivity method onCreate.

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

        @Override
        public void onRefreshing() {
            mHandler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    mViewPager.setCurrentItem(0, true);
                    mRefreshLayout.refreshComplete();
                    Toast.makeText(TestNestedHorizontalViewsActivity.this, R.string.sr_refresh_complete, Toast.LENGTH_SHORT).show();
                }
            }, 4000);
        }
    });
    mViewPager = findViewById(R.id.viewPager_test_nested_horizontal_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);
    mViewPager.setPageTransformer(true, new DrawerTransformer());
    mRefreshLayout.autoRefresh(false);
}
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) DrawerTransformer(com.ToxicBakery.viewpager.transforms.DrawerTransformer)

Example 3 with ViewPagerAdapter

use of me.dkzwm.widget.srl.sample.adapter.ViewPagerAdapter in project SmoothRefreshLayout by dkzwm.

the class TestNestedWithViewPagerActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_test_nested_with_viewpager);
    final Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.setNavigationIcon(R.drawable.arrow_back_white_72x72);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
    ViewPager viewPager = findViewById(R.id.viewPager_test_nested_with_viewPager);
    mFragments = new ArrayList<>();
    for (int sColor : sColors) {
        mFragments.add(NestedPageFragment.newInstance(sColor));
    }
    ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager(), mFragments);
    viewPager.setAdapter(adapter);
    mRefreshLayout = findViewById(R.id.smoothRefreshLayout_test_nested_with_viewPager);
    mRefreshLayout.setDisableLoadMore(false);
    mRefreshLayout.materialStyle();
    mRefreshLayout.setOnRefreshListener(new SmoothRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefreshing() {
            mHandler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    for (int i = 0; i < mFragments.size(); i++) {
                        NestedPageFragment fragment = mFragments.get(i);
                        fragment.updateData();
                    }
                    mRefreshLayout.refreshComplete();
                }
            }, 2000);
        }

        @Override
        public void onLoadingMore() {
            mHandler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    for (int i = 0; i < mFragments.size(); i++) {
                        NestedPageFragment fragment = mFragments.get(i);
                        fragment.appendData();
                    }
                    mRefreshLayout.refreshComplete();
                }
            }, 2000);
        }
    });
    mRefreshLayout.setDisableWhenAnotherDirectionMove(true);
    mRefreshLayout.autoRefresh(false);
}
Also used : NestedPageFragment(me.dkzwm.widget.srl.sample.ui.fragment.NestedPageFragment) ViewPagerAdapter(me.dkzwm.widget.srl.sample.adapter.ViewPagerAdapter) View(android.view.View) ViewPager(androidx.viewpager.widget.ViewPager) Toolbar(androidx.appcompat.widget.Toolbar) MaterialSmoothRefreshLayout(me.dkzwm.widget.srl.MaterialSmoothRefreshLayout) SmoothRefreshLayout(me.dkzwm.widget.srl.SmoothRefreshLayout)

Example 4 with ViewPagerAdapter

use of me.dkzwm.widget.srl.sample.adapter.ViewPagerAdapter in project SmoothRefreshLayout by dkzwm.

the class WithViewPagerActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_with_viewpager);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setTitle(R.string.with_viewPager);
    mRefreshLayout = findViewById(R.id.smoothRefreshLayout_with_viewPager);
    MaterialHeader header = new MaterialHeader(this);
    header.setPadding(0, PixelUtl.dp2px(this, 20), 0, PixelUtl.dp2px(this, 20));
    mRefreshLayout.setHeaderView(header);
    mRefreshLayout.setEnablePinContentView(true);
    mRefreshLayout.setEnableKeepRefreshView(true);
    mRefreshLayout.setDisableWhenAnotherDirectionMove(true);
    mRefreshLayout.setOnRefreshListener(new RefreshingListenerAdapter() {

        @Override
        public void onRefreshing() {
            mHandler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    mViewPager.setCurrentItem(0, true);
                    mRefreshLayout.refreshComplete();
                    Toast.makeText(WithViewPagerActivity.this, R.string.sr_refresh_complete, Toast.LENGTH_SHORT).show();
                }
            }, 4000);
        }
    });
    mViewPager = findViewById(R.id.viewPager_with_viewPager);
    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);
    mViewPager.setPageTransformer(true, new DrawerTransformer());
    mRefreshLayout.autoRefresh(false);
}
Also used : MaterialHeader(me.dkzwm.widget.srl.extra.header.MaterialHeader) 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) DrawerTransformer(com.ToxicBakery.viewpager.transforms.DrawerTransformer)

Example 5 with ViewPagerAdapter

use of me.dkzwm.widget.srl.sample.adapter.ViewPagerAdapter in project SmoothRefreshLayout by dkzwm.

the class TestNestedViewPagerActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_with_nested_viewpager);
    final Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.setNavigationIcon(R.drawable.arrow_back_white_72x72);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
    ViewPager viewPager = findViewById(R.id.viewPager_with_nested_pager);
    List<NestedPageWithSrlFragment> fragments = new ArrayList<>();
    for (int color : sColors) {
        fragments.add(NestedPageWithSrlFragment.newInstance(color));
    }
    ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager(), fragments);
    viewPager.setAdapter(adapter);
}
Also used : NestedPageWithSrlFragment(me.dkzwm.widget.srl.sample.ui.fragment.NestedPageWithSrlFragment) ArrayList(java.util.ArrayList) ViewPagerAdapter(me.dkzwm.widget.srl.sample.adapter.ViewPagerAdapter) View(android.view.View) ViewPager(androidx.viewpager.widget.ViewPager) Toolbar(androidx.appcompat.widget.Toolbar)

Aggregations

ViewPagerAdapter (me.dkzwm.widget.srl.sample.adapter.ViewPagerAdapter)5 ArrayList (java.util.ArrayList)4 RefreshingListenerAdapter (me.dkzwm.widget.srl.RefreshingListenerAdapter)3 PageFragment (me.dkzwm.widget.srl.sample.ui.fragment.PageFragment)3 View (android.view.View)2 Toolbar (androidx.appcompat.widget.Toolbar)2 ViewPager (androidx.viewpager.widget.ViewPager)2 DrawerTransformer (com.ToxicBakery.viewpager.transforms.DrawerTransformer)2 ClassicHeader (me.dkzwm.widget.srl.extra.header.ClassicHeader)2 MaterialSmoothRefreshLayout (me.dkzwm.widget.srl.MaterialSmoothRefreshLayout)1 SmoothRefreshLayout (me.dkzwm.widget.srl.SmoothRefreshLayout)1 MaterialHeader (me.dkzwm.widget.srl.extra.header.MaterialHeader)1 CustomLoadDetailFooter (me.dkzwm.widget.srl.sample.footer.CustomLoadDetailFooter)1 NestedPageFragment (me.dkzwm.widget.srl.sample.ui.fragment.NestedPageFragment)1 NestedPageWithSrlFragment (me.dkzwm.widget.srl.sample.ui.fragment.NestedPageWithSrlFragment)1