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);
}
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);
}
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);
}
Aggregations