Search in sources :

Example 11 with RefreshingListenerAdapter

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

Example 12 with RefreshingListenerAdapter

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

Example 13 with RefreshingListenerAdapter

use of me.dkzwm.widget.srl.RefreshingListenerAdapter in project SmoothRefreshLayout by dkzwm.

the class TestScrollToAutoRefreshActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_test_scroll_to_auto_refresh);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setTitle(R.string.test_scroll_to_auto_refresh);
    RecyclerView recyclerView = findViewById(R.id.recyclerView_test_scroll_to_auto_refresh);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setHasFixedSize(true);
    mAdapter = new RecyclerViewAdapter(this, getLayoutInflater());
    recyclerView.setAdapter(mAdapter);
    mRefreshLayout = findViewById(R.id.smoothRefreshLayout_test_scroll_to_auto_refresh);
    mRefreshLayout.setDisableLoadMore(false);
    mRefreshLayout.materialStyle();
    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.setEnableSmoothRollbackWhenCompleted(true);
    mRefreshLayout.autoRefresh(false);
    mAutoRefreshUtil = new QuickConfigAutoRefreshUtil(recyclerView);
    mRefreshLayout.setLifecycleObserver(mAutoRefreshUtil);
    findViewById(R.id.button_test_scroll_to_auto_refresh_left).setOnClickListener(this);
    findViewById(R.id.button_test_scroll_to_auto_refresh_right).setOnClickListener(this);
}
Also used : RefreshingListenerAdapter(me.dkzwm.widget.srl.RefreshingListenerAdapter) QuickConfigAutoRefreshUtil(me.dkzwm.widget.srl.utils.QuickConfigAutoRefreshUtil) RecyclerView(android.support.v7.widget.RecyclerView) RecyclerViewAdapter(me.dkzwm.widget.srl.sample.adapter.RecyclerViewAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 14 with RefreshingListenerAdapter

use of me.dkzwm.widget.srl.RefreshingListenerAdapter in project SmoothRefreshLayout by dkzwm.

the class WithFrameLayoutActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_with_framelayout);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setTitle(R.string.with_frameLayout);
    mRefreshLayout = findViewById(R.id.smoothRefreshLayout_with_frameLayout);
    mTextView = findViewById(R.id.textView_with_frameLayout_desc);
    mTextView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Toast.makeText(WithFrameLayoutActivity.this, "Clicked", Toast.LENGTH_SHORT).show();
        }
    });
    mTextView.setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            Toast.makeText(WithFrameLayoutActivity.this, "LongClicked", Toast.LENGTH_SHORT).show();
            return true;
        }
    });
    WaveTextRefreshView refreshView = new WaveTextRefreshView(this);
    refreshView.setIncrementalY(.5f);
    mRefreshLayout.setHeaderView(refreshView);
    mRefreshLayout.setRatioToKeep(1);
    mRefreshLayout.setRatioOfHeaderToRefresh(1);
    mRefreshLayout.setEnableOverScroll(false);
    mRefreshLayout.setEnableKeepRefreshView(true);
    mRefreshLayout.setEnableInterceptEventWhileLoading(true);
    mRefreshLayout.setDisableLoadMore(false);
    mRefreshLayout.setDisablePerformLoadMore(true);
    mRefreshLayout.setEnableHideFooterView(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);
                }
            }, 8000);
        }
    });
    mRefreshLayout.autoRefresh(true);
}
Also used : WaveTextRefreshView(me.dkzwm.widget.srl.sample.header.WaveTextRefreshView) RefreshingListenerAdapter(me.dkzwm.widget.srl.RefreshingListenerAdapter) WaveTextRefreshView(me.dkzwm.widget.srl.sample.header.WaveTextRefreshView) TextView(android.widget.TextView) View(android.view.View)

Example 15 with RefreshingListenerAdapter

use of me.dkzwm.widget.srl.RefreshingListenerAdapter in project SmoothRefreshLayout by dkzwm.

the class WithRecyclerViewActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_with_recyclerview);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setTitle(R.string.with_recyclerView);
    mRecyclerView = findViewById(R.id.recyclerView_with_recyclerView);
    mRecyclerView.setLayoutManager(new GridLayoutManager(this, 3));
    mRecyclerView.setHasFixedSize(true);
    mAdapter = new RecyclerViewAdapter(this, getLayoutInflater());
    mRecyclerView.setAdapter(mAdapter);
    mRefreshLayout = findViewById(R.id.smoothRefreshLayout_with_recyclerView);
    mRefreshLayout.setDisableLoadMore(false);
    mRefreshLayout.materialStyle();
    mRefreshLayout.setEnableAutoLoadMore(true);
    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, 15);
                        mCount += 15;
                        mAdapter.updateData(list);
                    } else {
                        List<String> list = DataUtil.createList(mCount, 15);
                        mCount += 15;
                        mAdapter.appendData(list);
                    }
                    mRefreshLayout.refreshComplete();
                }
            }, 2000);
        }
    });
    mRefreshLayout.setEnableSmoothRollbackWhenCompleted(true);
    mRefreshLayout.autoRefresh(false);
}
Also used : RefreshingListenerAdapter(me.dkzwm.widget.srl.RefreshingListenerAdapter) GridLayoutManager(android.support.v7.widget.GridLayoutManager) RecyclerViewAdapter(me.dkzwm.widget.srl.sample.adapter.RecyclerViewAdapter)

Aggregations

RefreshingListenerAdapter (me.dkzwm.widget.srl.RefreshingListenerAdapter)18 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)4 ClassicHeader (me.dkzwm.widget.srl.extra.header.ClassicHeader)4 MaterialHeader (me.dkzwm.widget.srl.extra.header.MaterialHeader)4 RecyclerViewAdapter (me.dkzwm.widget.srl.sample.adapter.RecyclerViewAdapter)4 RecyclerView (android.support.v7.widget.RecyclerView)3 View (android.view.View)3 SmoothRefreshLayout (me.dkzwm.widget.srl.SmoothRefreshLayout)3 IIndicator (me.dkzwm.widget.srl.indicator.IIndicator)3 GridLayoutManager (android.support.v7.widget.GridLayoutManager)2 ArrayList (java.util.ArrayList)2 MaterialFooter (me.dkzwm.widget.srl.extra.footer.MaterialFooter)2 ListViewAdapter (me.dkzwm.widget.srl.sample.adapter.ListViewAdapter)2 ViewPagerAdapter (me.dkzwm.widget.srl.sample.adapter.ViewPagerAdapter)2 PageFragment (me.dkzwm.widget.srl.sample.ui.fragment.PageFragment)2 Nullable (android.support.annotation.Nullable)1 ViewTreeObserver (android.view.ViewTreeObserver)1 TextView (android.widget.TextView)1 DrawerTransformer (com.ToxicBakery.viewpager.transforms.DrawerTransformer)1 BaseQuickAdapter (com.chad.library.adapter.base.BaseQuickAdapter)1