Search in sources :

Example 1 with ClassicFooter

use of me.dkzwm.widget.srl.extra.footer.ClassicFooter 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 onRefreshing() {
            mHandler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    List<String> list = DataUtil.createList(mCount, 20);
                    mCount = list.size();
                    mAdapter.updateData(list);
                    mRefreshLayout.refreshComplete();
                }
            }, 2000);
        }

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

                @Override
                public void run() {
                    List<String> list = DataUtil.createList(mCount, 20);
                    mCount += list.size();
                    mAdapter.appendData(list);
                    mRefreshLayout.refreshComplete();
                }
            }, 2000);
        }
    });
    mRefreshLayout.addOnUIPositionChangedListener(new SmoothRefreshLayout.OnUIPositionChangedListener() {

        @Override
        public void onChanged(byte status, IIndicator indicator) {
            if (mRefreshLayout.getIndicator().isAlreadyHere(IIndicator.START_POS)) {
                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(androidx.recyclerview.widget.LinearLayoutManager) SmoothRefreshLayout(me.dkzwm.widget.srl.SmoothRefreshLayout) IIndicator(me.dkzwm.widget.srl.indicator.IIndicator)

Example 2 with ClassicFooter

use of me.dkzwm.widget.srl.extra.footer.ClassicFooter in project SmoothRefreshLayout by dkzwm.

the class DemoApplication method onCreate.

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

        @Override
        public IRefreshView<IIndicator> createHeader(SmoothRefreshLayout layout) {
            ClassicHeader<IIndicator> header = new ClassicHeader<>(layout.getContext());
            header.setLastUpdateTimeKey("header_last_update_time");
            return header;
        }

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

Example 3 with ClassicFooter

use of me.dkzwm.widget.srl.extra.footer.ClassicFooter in project SmoothRefreshLayout by dkzwm.

the class ClassicSmoothRefreshLayout method init.

@Override
protected void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super.init(context, attrs, defStyleAttr, defStyleRes);
    mClassicHeader = new ClassicHeader(context);
    setHeaderView(mClassicHeader);
    mClassicFooter = new ClassicFooter(context);
    setFooterView(mClassicFooter);
}
Also used : ClassicHeader(me.dkzwm.widget.srl.extra.header.ClassicHeader) ClassicFooter(me.dkzwm.widget.srl.extra.footer.ClassicFooter)

Aggregations

ClassicFooter (me.dkzwm.widget.srl.extra.footer.ClassicFooter)3 ClassicHeader (me.dkzwm.widget.srl.extra.header.ClassicHeader)3 SmoothRefreshLayout (me.dkzwm.widget.srl.SmoothRefreshLayout)2 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)1 IRefreshViewCreator (me.dkzwm.widget.srl.IRefreshViewCreator)1 RefreshingListenerAdapter (me.dkzwm.widget.srl.RefreshingListenerAdapter)1 IRefreshView (me.dkzwm.widget.srl.extra.IRefreshView)1 IIndicator (me.dkzwm.widget.srl.indicator.IIndicator)1 RecyclerViewAdapter (me.dkzwm.widget.srl.sample.adapter.RecyclerViewAdapter)1