Skip to content

Commit

Permalink
fix(android): send scroll event when pulling header/footer
Browse files Browse the repository at this point in the history
  • Loading branch information
iPel authored and zoomchan-cxj committed Mar 16, 2023
1 parent 628367e commit 1c0d713
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,18 @@ protected int getOffsetFromEnd() {
- v.computeHorizontalScrollOffset();
}

@Override
public void enableRefresh() {
mRefreshStatus = PullRefreshStatus.PULL_STATUS_REFRESHING;
int nodeSize = isVertical() ? mRenderNode.getHeight() : mRenderNode.getWidth();
endAnimation();
int visibleSize = getVisibleSize();
if (visibleSize < nodeSize) {
setVisibleSize(nodeSize);
}
HippyRecyclerListAdapter<?> adapter = mRecyclerView.getAdapter();
if (adapter != null) {
mRecyclerView.smoothScrollToPosition(adapter.getItemCount());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,17 @@ protected void sendPullingEvent(int offset) {

@Override
public void enableRefresh() {
super.enableRefresh();
if (mRefreshStatus == PullRefreshStatus.PULL_STATUS_REFRESHING) {
mRefreshStatus = PullRefreshStatus.PULL_STATUS_REFRESHING;
int nodeSize = isVertical() ? mRenderNode.getHeight() : mRenderNode.getWidth();
if (mRecyclerView.getFirstChildPosition() > 0) {
endAnimation();
setVisibleSize(nodeSize);
mRecyclerView.smoothScrollToPosition(0);
} else {
int visibleSize = getVisibleSize();
if (visibleSize < nodeSize) {
smoothResizeTo(visibleSize, nodeSize, DURATION);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ protected int getNodeSize() {

protected abstract void sendPullingEvent(int offset);

protected void sendCompatScrollEvent() {
mRecyclerView.getRecyclerViewEventHelper().checkSendOnScrollEvent();
}

public void onDestroy() {
mItemView = null;
mContainer.removeAllViews();
Expand All @@ -104,21 +108,7 @@ public void onRefreshCompleted() {
}
}

public void enableRefresh() {
switch (mRefreshStatus) {
case PULL_STATUS_FOLDED:
int nodeSize = isVertical() ? mRenderNode.getHeight() : mRenderNode.getWidth();
setVisibleSize(nodeSize);
mRefreshStatus = PullRefreshStatus.PULL_STATUS_REFRESHING;
break;
case PULL_STATUS_DRAGGING:
mRefreshStatus = PullRefreshStatus.PULL_STATUS_REFRESHING;
break;
case PULL_STATUS_REFRESHING:
default:
break;
}
}
public abstract void enableRefresh();

public View getView() {
return mContainer;
Expand Down Expand Up @@ -215,6 +205,7 @@ protected void setVisibleSize(int size) {
}
mContainer.setLayoutParams(layoutParams);
mRecyclerView.dispatchLayout();
sendCompatScrollEvent();
}

protected void smoothResizeTo(int fromValue, int toValue, int duration) {
Expand Down

0 comments on commit 1c0d713

Please sign in to comment.