Skip to content

Commit

Permalink
update 可以不设置监听启动下拉刷新
Browse files Browse the repository at this point in the history
  • Loading branch information
youlookwhat committed Dec 13, 2019
1 parent 90d3309 commit 1f10053
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
23 changes: 13 additions & 10 deletions ByRecyclerview/src/main/java/me/jingbin/library/ByRecyclerView.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,14 @@ public void setRefreshing(boolean refreshing) {
layoutManager.scrollToPosition(0);
}
mRefreshHeader.setState(BaseRefreshHeader.STATE_REFRESHING);
postDelayed(new Runnable() {
@Override
public void run() {
mRefreshListener.onRefresh();
}
}, 300);
if (mRefreshListener != null) {
postDelayed(new Runnable() {
@Override
public void run() {
mRefreshListener.onRefresh();
}
}, 300);
}
} else {
if (getPullHeaderSize() > 0) {
mRefreshHeader.refreshComplete();
Expand Down Expand Up @@ -394,11 +396,12 @@ public boolean onTouchEvent(MotionEvent ev) {
mPullStartY = 0;
mLastY = -1;
if (mRefreshEnabled
&& mRefreshListener != null
&& isOnTop()
&& appbarState == AppBarStateChangeListener.State.EXPANDED) {
if (mRefreshHeader.releaseAction()) {
mRefreshListener.onRefresh();
if (mRefreshListener != null) {
mRefreshListener.onRefresh();
}
}
}
break;
Expand Down Expand Up @@ -512,7 +515,7 @@ boolean isLoadMore(int position) {
* Is it a RefreshHeaderView layout
*/
boolean isRefreshHeader(int position) {
if (mRefreshEnabled && mRefreshListener != null) {
if (mRefreshEnabled) {
return position == 0;
} else {
return false;
Expand Down Expand Up @@ -826,7 +829,7 @@ public void onStateChanged(AppBarLayout appBarLayout, State state) {
* If you use the drop-down refresh that comes with the control, you need to count position
*/
public int getPullHeaderSize() {
if (mRefreshEnabled && mRefreshListener != null) {
if (mRefreshEnabled) {
return 1;
} else {
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ private class ViewHolder extends BaseBindingHolder<T, B> {

@Override
protected void onBindingView(BaseBindingHolder holder, T bean, int position) {
bindView(holder, binding, bean, position);
bindView(holder, bean, binding, position);
}
}

protected abstract void bindView(BaseBindingHolder holder, B binding, T bean, int position);
protected abstract void bindView(BaseBindingHolder holder, T bean, B binding, int position);
}

0 comments on commit 1f10053

Please sign in to comment.