Search in sources :

Example 1 with IRefreshView

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

the class SmoothRefreshLayout method setHeaderView.

/**
 * Set the Header view.
 * <p>设置Header视图</p>
 *
 * @param header Header view
 */
public void setHeaderView(@NonNull IRefreshView header) {
    if (mHeaderView != null) {
        removeView(mHeaderView.getView());
        mHeaderView = null;
    }
    if (header.getType() != IRefreshView.TYPE_HEADER)
        throw new IllegalArgumentException("Wrong type,HeaderView type must be " + "TYPE_HEADER");
    View view = header.getView();
    addFreshViewLayoutParams(view);
    mViewsZAxisNeedReset = true;
    addView(view);
}
Also used : View(android.view.View) IRefreshView(me.dkzwm.widget.srl.extra.IRefreshView)

Example 2 with IRefreshView

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

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

the class SmoothRefreshLayout method setFooterView.

/**
 * Set the Footer view.
 * <p>设置Footer视图</p>
 *
 * @param footer Footer view
 */
public void setFooterView(@NonNull IRefreshView footer) {
    if (mFooterView != null) {
        removeView(mFooterView.getView());
        mFooterView = null;
    }
    if (footer.getType() != IRefreshView.TYPE_FOOTER)
        throw new IllegalArgumentException("Wrong type,FooterView type must be " + "TYPE_FOOTER");
    View view = footer.getView();
    addFreshViewLayoutParams(view);
    mViewsZAxisNeedReset = true;
    addView(view);
}
Also used : View(android.view.View) IRefreshView(me.dkzwm.widget.srl.extra.IRefreshView)

Aggregations

View (android.view.View)3 IRefreshView (me.dkzwm.widget.srl.extra.IRefreshView)3 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 BaseQuickAdapter (com.chad.library.adapter.base.BaseQuickAdapter)1 RefreshingListenerAdapter (me.dkzwm.widget.srl.RefreshingListenerAdapter)1 SmoothRefreshLayout (me.dkzwm.widget.srl.SmoothRefreshLayout)1 ClassicHeader (me.dkzwm.widget.srl.extra.header.ClassicHeader)1 LoadMoreRecyclerViewAdapter (me.dkzwm.widget.srl.sample.adapter.LoadMoreRecyclerViewAdapter)1