Search in sources :

Example 1 with ClassicHeader

use of me.dkzwm.widget.srl.extra.header.ClassicHeader in project SmoothRefreshLayout by dkzwm.

the class TestQQActivityStyleActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_test_qq_activity_style);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setTitle(R.string.test_qq_activity_style);
    mRecyclerView = findViewById(R.id.recyclerView_test_qq_activity_style);
    mRadioGroup = findViewById(R.id.radioGroup_test_qq_activity_style_container);
    mRadioButtonNormal = findViewById(R.id.radioButton_test_qq_activity_style_normal);
    mRadioButtonActivity = findViewById(R.id.radioButton_test_qq_activity_style_activity);
    mRadioGroup.setOnCheckedChangeListener(this);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mRecyclerView.setHasFixedSize(true);
    mAdapter = new RecyclerViewAdapter(this, getLayoutInflater());
    mRecyclerView.setAdapter(mAdapter);
    mRefreshLayout = findViewById(R.id.smoothRefreshLayout_test_qq_activity_style);
    mClassicHeader = new ClassicHeader(this);
    mClassicHeader.setLastUpdateTimeKey("header_last_update_time");
    mClassicFooter = new ClassicFooter(this);
    mClassicFooter.setLastUpdateTimeKey("footer_last_update_time");
    mRefreshLayout.setHeaderView(mClassicHeader);
    mRefreshLayout.setFooterView(mClassicFooter);
    mRefreshLayout.setEnableKeepRefreshView(true);
    mRefreshLayout.setDisableLoadMore(false);
    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.addOnUIPositionChangedListener(new SmoothRefreshLayout.OnUIPositionChangedListener() {

        @Override
        public void onChanged(byte status, IIndicator indicator) {
            if (mRefreshLayout.isInStartPosition()) {
                mRadioGroup.setEnabled(true);
                mRadioButtonNormal.setEnabled(true);
                mRadioButtonActivity.setEnabled(true);
            } else {
                mRadioGroup.setEnabled(false);
                mRadioButtonNormal.setEnabled(false);
                mRadioButtonActivity.setEnabled(false);
            }
        }
    });
    mRefreshLayout.autoRefresh(false);
}
Also used : ClassicHeader(me.dkzwm.widget.srl.extra.header.ClassicHeader) RefreshingListenerAdapter(me.dkzwm.widget.srl.RefreshingListenerAdapter) ClassicFooter(me.dkzwm.widget.srl.extra.footer.ClassicFooter) RecyclerViewAdapter(me.dkzwm.widget.srl.sample.adapter.RecyclerViewAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SmoothRefreshLayout(me.dkzwm.widget.srl.SmoothRefreshLayout) IIndicator(me.dkzwm.widget.srl.indicator.IIndicator)

Example 2 with ClassicHeader

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

Example 3 with ClassicHeader

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

use of me.dkzwm.widget.srl.extra.header.ClassicHeader in project SmoothRefreshLayout by dkzwm.

the class DemoApplication method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    LeakCanary.install(this);
    SmoothRefreshLayout.setDefaultCreator(new IRefreshViewCreator() {

        @Override
        public void createHeader(SmoothRefreshLayout layout) {
            ClassicHeader header = new ClassicHeader(layout.getContext());
            header.setLastUpdateTimeKey("header_last_update_time");
            layout.setHeaderView(header);
        }

        @Override
        public void createFooter(SmoothRefreshLayout layout) {
            ClassicFooter footer = new ClassicFooter(layout.getContext());
            footer.setLastUpdateTimeKey("footer_last_update_time");
            layout.setFooterView(footer);
        }
    });
}
Also used : ClassicHeader(me.dkzwm.widget.srl.extra.header.ClassicHeader) IRefreshViewCreator(me.dkzwm.widget.srl.IRefreshViewCreator) ClassicFooter(me.dkzwm.widget.srl.extra.footer.ClassicFooter) SmoothRefreshLayout(me.dkzwm.widget.srl.SmoothRefreshLayout)

Example 5 with ClassicHeader

use of me.dkzwm.widget.srl.extra.header.ClassicHeader in project SmoothRefreshLayout by dkzwm.

the class TestBaseRecyclerViewAdapterActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setTitle(R.string.test_base_recyclerView_adapter);
    setContentView(R.layout.activity_test_base_recyclerview_adapter);
    mRefreshLayout = findViewById(R.id.smoothRefreshLayout_test_base_recyclerView_adapter);
    ClassicHeader classicHeader = new ClassicHeader(this);
    classicHeader.setLastUpdateTimeKey("header_last_update_time");
    mRefreshLayout.setHeaderView(classicHeader);
    mRefreshLayout.setOnRefreshListener(new RefreshingListenerAdapter() {

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

                @Override
                public void run() {
                    mCount = 0;
                    List<String> list = DataUtil.createList(mCount, 20);
                    mCount += 20;
                    mAdapter.setNewData(list);
                    mRefreshLayout.refreshComplete();
                }
            }, 2000);
        }
    });
    mAdapter = new LoadMoreRecyclerViewAdapter(this);
    mAdapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {

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

                @Override
                public void run() {
                    List<String> list = DataUtil.createList(mCount, 20);
                    mCount += 20;
                    mAdapter.addData(list);
                    mAdapter.loadMoreComplete();
                    mRefreshLayout.refreshComplete();
                }
            }, 2000);
        }
    }, mRecyclerView);
    mRefreshLayout.setOnHeaderEdgeDetectCallBack(new SmoothRefreshLayout.OnHeaderEdgeDetectCallBack() {

        @Override
        public boolean isNotYetInEdgeCannotMoveHeader(SmoothRefreshLayout parent, @Nullable View child, @Nullable IRefreshView header) {
            return ScrollCompat.canChildScrollUp(mRecyclerView);
        }
    });
    mRefreshLayout.setOnFooterEdgeDetectCallBack(new SmoothRefreshLayout.OnFooterEdgeDetectCallBack() {

        @Override
        public boolean isNotYetInEdgeCannotMoveFooter(SmoothRefreshLayout parent, @Nullable View child, @Nullable IRefreshView footer) {
            return ScrollCompat.canChildScrollDown(mRecyclerView);
        }
    });
    mRefreshLayout.autoRefresh(true);
    mRecyclerView = findViewById(R.id.recyclerView_test_base_recyclerView_adapter);
    mRecyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setAdapter(mAdapter);
    mRefreshLayout.setLoadMoreScrollTargetView(mRecyclerView);
}
Also used : ClassicHeader(me.dkzwm.widget.srl.extra.header.ClassicHeader) RefreshingListenerAdapter(me.dkzwm.widget.srl.RefreshingListenerAdapter) LoadMoreRecyclerViewAdapter(me.dkzwm.widget.srl.sample.adapter.LoadMoreRecyclerViewAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) IRefreshView(me.dkzwm.widget.srl.extra.IRefreshView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) SmoothRefreshLayout(me.dkzwm.widget.srl.SmoothRefreshLayout) IRefreshView(me.dkzwm.widget.srl.extra.IRefreshView) BaseQuickAdapter(com.chad.library.adapter.base.BaseQuickAdapter)

Aggregations

ClassicHeader (me.dkzwm.widget.srl.extra.header.ClassicHeader)5 RefreshingListenerAdapter (me.dkzwm.widget.srl.RefreshingListenerAdapter)4 SmoothRefreshLayout (me.dkzwm.widget.srl.SmoothRefreshLayout)3 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)2 ArrayList (java.util.ArrayList)2 ClassicFooter (me.dkzwm.widget.srl.extra.footer.ClassicFooter)2 ViewPagerAdapter (me.dkzwm.widget.srl.sample.adapter.ViewPagerAdapter)2 PageFragment (me.dkzwm.widget.srl.sample.ui.fragment.PageFragment)2 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 DrawerTransformer (com.ToxicBakery.viewpager.transforms.DrawerTransformer)1 BaseQuickAdapter (com.chad.library.adapter.base.BaseQuickAdapter)1 IRefreshViewCreator (me.dkzwm.widget.srl.IRefreshViewCreator)1 IRefreshView (me.dkzwm.widget.srl.extra.IRefreshView)1 IIndicator (me.dkzwm.widget.srl.indicator.IIndicator)1 LoadMoreRecyclerViewAdapter (me.dkzwm.widget.srl.sample.adapter.LoadMoreRecyclerViewAdapter)1 RecyclerViewAdapter (me.dkzwm.widget.srl.sample.adapter.RecyclerViewAdapter)1 CustomLoadDetailFooter (me.dkzwm.widget.srl.sample.footer.CustomLoadDetailFooter)1