mirror of
https://github.com/Tencent/Hippy.git
synced 2026-10-28 13:38:10 +08:00
fix(android): pull header/footer collapse animation
This commit is contained in:
-20
@@ -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
|
||||
*/
|
||||
|
||||
+4
-5
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user