fix(android): pull header/footer collapse animation

This commit is contained in:
iPel
2023-02-17 11:03:46 +08:00
committed by zoomchan-cxj
parent 65a93c06b0
commit 888c99a76b
2 changed files with 4 additions and 25 deletions
@@ -94,26 +94,6 @@ public class PullHeaderRefreshHelper extends PullRefreshHelper {
}
}
@Override
public void onRefreshCompleted() {
if (mRefreshStatus == PullRefreshStatus.PULL_STATUS_REFRESHING) {
// when only part of the header is visible, scroll it off the screen before hiding it
// to avoid inappropriate offsets of the list
if (HippyListUtils.isVerticalLayout(mRecyclerView)) {
int offsetY = mRecyclerView.getContentOffsetY();
if (offsetY < 0 && offsetY > -mRenderNode.getHeight()) {
mRecyclerView.scrollBy(0, -offsetY);
}
} else {
int offsetX = mRecyclerView.getContentOffsetX();
if (offsetX < 0 && offsetX > -mRenderNode.getWidth()) {
mRecyclerView.scrollBy(-offsetX, 0);
}
}
}
super.onRefreshCompleted();
}
/**
* scrollable distance from list start, value greater than or equal to 0
*/
@@ -72,13 +72,13 @@ public abstract class PullRefreshHelper {
mRefreshStatus = PullRefreshStatus.PULL_STATUS_REFRESHING;
sendReleasedEvent();
}
smoothScrollTo(getVisibleSize(), nodeSize, DURATION);
smoothResizeTo(getVisibleSize(), nodeSize, DURATION);
} else { // only partially showing
if (mRefreshStatus == PullRefreshStatus.PULL_STATUS_DRAGGING) {
mRefreshStatus = PullRefreshStatus.PULL_STATUS_FOLDED;
}
if (visibleSize > 0) {
smoothScrollTo(getVisibleSize(), 0, DURATION);
smoothResizeTo(getVisibleSize(), 0, DURATION);
}
}
}
@@ -100,8 +100,7 @@ public abstract class PullRefreshHelper {
public void onRefreshCompleted() {
if (mRefreshStatus == PullRefreshStatus.PULL_STATUS_REFRESHING) {
mRefreshStatus = PullRefreshStatus.PULL_STATUS_FOLDED;
endAnimation();
setVisibleSize(0);
smoothResizeTo(getVisibleSize(), 0, DURATION);
}
}
@@ -218,7 +217,7 @@ public abstract class PullRefreshHelper {
mRecyclerView.dispatchLayout();
}
protected void smoothScrollTo(int fromValue, int toValue, int duration) {
protected void smoothResizeTo(int fromValue, int toValue, int duration) {
endAnimation();
mAnimator = ValueAnimator.ofInt(fromValue, toValue);
mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {