Search in sources :

Example 1 with IIndicator

use of me.dkzwm.widget.srl.indicator.IIndicator 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 IIndicator

use of me.dkzwm.widget.srl.indicator.IIndicator in project SmoothRefreshLayout by dkzwm.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mRefreshLayout = findViewById(R.id.smoothRefreshLayout_main);
    // 设置刷新回调
    mRefreshLayout.setOnRefreshListener(new RefreshingListenerAdapter() {

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

                @Override
                public void run() {
                    mRefreshLayout.refreshComplete(800);
                }
            }, 4000);
        }
    });
    mRefreshLayout.addOnUIPositionChangedListener(new SmoothRefreshLayout.OnUIPositionChangedListener() {

        @Override
        public void onChanged(byte status, IIndicator indicator) {
            if (!mRefreshLayout.isOverScrolling() && mRefreshLayout.isMovingFooter()) {
                mRefreshLayout.resetScrollerInterpolator();
            }
        }
    });
    mRefreshLayout.setDisableLoadMore(false);
    mRefreshLayout.setDisablePerformLoadMore(true);
    mRefreshLayout.setEnableHideFooterView(true);
    mRefreshLayout.getDefaultHeader().setWaveColor(ContextCompat.getColor(this, R.color.colorPrimary));
    mRefreshLayout.getDefaultHeader().setBackgroundColor(ContextCompat.getColor(this, R.color.colorAccent));
    mRefreshLayout.getDefaultHeader().setStyle(IRefreshView.STYLE_PIN);
    // 自动刷新
    mRefreshLayout.autoRefresh(Constants.ACTION_AT_ONCE, true);
    findViewById(R.id.imageView_main_bottom_icon).setOnClickListener(this);
    findViewById(R.id.button_main_with_frameLayout).setOnClickListener(this);
    findViewById(R.id.button_main_with_listView).setOnClickListener(this);
    findViewById(R.id.button_main_with_gridView).setOnClickListener(this);
    findViewById(R.id.button_main_with_recyclerView).setOnClickListener(this);
    findViewById(R.id.button_main_with_recyclerView_in_coordinatorLayout).setOnClickListener(this);
    findViewById(R.id.button_main_test_enable_next_pull_to_refresh_at_once).setOnClickListener(this);
    findViewById(R.id.button_main_test_material_style).setOnClickListener(this);
    findViewById(R.id.button_main_test_nested).setOnClickListener(this);
    findViewById(R.id.button_main_test_pull_to_refresh).setOnClickListener(this);
    findViewById(R.id.button_main_test_release_to_refresh).setOnClickListener(this);
    findViewById(R.id.button_main_with_viewPager).setOnClickListener(this);
    findViewById(R.id.button_main_with_webView).setOnClickListener(this);
    findViewById(R.id.button_main_with_textView).setOnClickListener(this);
    findViewById(R.id.button_main_test_over_scroll).setOnClickListener(this);
    findViewById(R.id.button_main_test_two_level_refresh).setOnClickListener(this);
    findViewById(R.id.button_main_test_QQ_activity_style).setOnClickListener(this);
    findViewById(R.id.button_main_test_QQ_web_style).setOnClickListener(this);
    findViewById(R.id.button_main_test_nested_view_pager).setOnClickListener(this);
    findViewById(R.id.button_main_test_base_recyclerView_adapter).setOnClickListener(this);
    findViewById(R.id.button_main_test_nested_horizontal_views).setOnClickListener(this);
    findViewById(R.id.button_main_test_horizontal_refresh).setOnClickListener(this);
    findViewById(R.id.button_main_test_horizontal_recyclerView).setOnClickListener(this);
    findViewById(R.id.button_main_test_multi_direction_views).setOnClickListener(this);
    findViewById(R.id.button_main_test_scroll_to_auto_refresh).setOnClickListener(this);
    findViewById(R.id.button_main_test_scale_effect).setOnClickListener(this);
    findViewById(R.id.button_main_test_horizontal_scale_effect).setOnClickListener(this);
    mButtonDebug = findViewById(R.id.button_main_debug);
    mButtonDebug.setOnClickListener(this);
}
Also used : RefreshingListenerAdapter(me.dkzwm.widget.srl.RefreshingListenerAdapter) IIndicator(me.dkzwm.widget.srl.indicator.IIndicator) WaveSmoothRefreshLayout(me.dkzwm.widget.srl.sample.widget.WaveSmoothRefreshLayout) SmoothRefreshLayout(me.dkzwm.widget.srl.SmoothRefreshLayout)

Aggregations

RefreshingListenerAdapter (me.dkzwm.widget.srl.RefreshingListenerAdapter)2 SmoothRefreshLayout (me.dkzwm.widget.srl.SmoothRefreshLayout)2 IIndicator (me.dkzwm.widget.srl.indicator.IIndicator)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 ClassicFooter (me.dkzwm.widget.srl.extra.footer.ClassicFooter)1 ClassicHeader (me.dkzwm.widget.srl.extra.header.ClassicHeader)1 RecyclerViewAdapter (me.dkzwm.widget.srl.sample.adapter.RecyclerViewAdapter)1 WaveSmoothRefreshLayout (me.dkzwm.widget.srl.sample.widget.WaveSmoothRefreshLayout)1