Search in sources :

Example 1 with DrawerTransformer

use of com.ToxicBakery.viewpager.transforms.DrawerTransformer 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 onRefreshBegin(boolean isRefresh) {
            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.setEnableCheckInsideAnotherDirectionView(true);
    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 2 with DrawerTransformer

use of com.ToxicBakery.viewpager.transforms.DrawerTransformer 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 SmoothRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefreshBegin(boolean isRefresh) {
            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);
        }

        @Override
        public void onRefreshComplete(boolean isSuccessful) {
        }
    });
    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) ArrayList(java.util.ArrayList) PageFragment(me.dkzwm.widget.srl.sample.ui.fragment.PageFragment) ViewPagerAdapter(me.dkzwm.widget.srl.sample.adapter.ViewPagerAdapter) SmoothRefreshLayout(me.dkzwm.widget.srl.SmoothRefreshLayout) DrawerTransformer(com.ToxicBakery.viewpager.transforms.DrawerTransformer)

Aggregations

DrawerTransformer (com.ToxicBakery.viewpager.transforms.DrawerTransformer)2 ArrayList (java.util.ArrayList)2 ViewPagerAdapter (me.dkzwm.widget.srl.sample.adapter.ViewPagerAdapter)2 PageFragment (me.dkzwm.widget.srl.sample.ui.fragment.PageFragment)2 RefreshingListenerAdapter (me.dkzwm.widget.srl.RefreshingListenerAdapter)1 SmoothRefreshLayout (me.dkzwm.widget.srl.SmoothRefreshLayout)1 ClassicHeader (me.dkzwm.widget.srl.extra.header.ClassicHeader)1 MaterialHeader (me.dkzwm.widget.srl.extra.header.MaterialHeader)1