Search in sources :

Example 6 with MaterialHeader

use of me.dkzwm.widget.srl.extra.header.MaterialHeader 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 7 with MaterialHeader

use of me.dkzwm.widget.srl.extra.header.MaterialHeader 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)

Aggregations

MaterialHeader (me.dkzwm.widget.srl.extra.header.MaterialHeader)7 RefreshingListenerAdapter (me.dkzwm.widget.srl.RefreshingListenerAdapter)6 MaterialFooter (me.dkzwm.widget.srl.extra.footer.MaterialFooter)3 WebView (android.webkit.WebView)1 WebViewClient (android.webkit.WebViewClient)1 GridLayoutManager (androidx.recyclerview.widget.GridLayoutManager)1 DrawerTransformer (com.ToxicBakery.viewpager.transforms.DrawerTransformer)1 ArrayList (java.util.ArrayList)1 HorizontalRecyclerViewAdapter (me.dkzwm.widget.srl.sample.adapter.HorizontalRecyclerViewAdapter)1 ViewPagerAdapter (me.dkzwm.widget.srl.sample.adapter.ViewPagerAdapter)1 PageFragment (me.dkzwm.widget.srl.sample.ui.fragment.PageFragment)1 AutoRefreshUtil (me.dkzwm.widget.srl.util.AutoRefreshUtil)1