android: Fix the problem of shaking when pull down the refreshable view

This commit is contained in:
pengfei.zhou 2022-07-29 13:39:34 +08:00 committed by osborn
parent 81137b8fb8
commit d391cb8348

View File

@ -561,14 +561,11 @@ public class DoricSwipeLayout extends ViewGroup implements NestedScrollingParent
consumed[1] = dy - (int) mTotalUnconsumed; consumed[1] = dy - (int) mTotalUnconsumed;
mTotalUnconsumed = 0; mTotalUnconsumed = 0;
} else { } else {
if (dy > 3) {
mTotalUnconsumed -= dy; mTotalUnconsumed -= dy;
consumed[1] = dy; consumed[1] = dy;
} }
}
moveSpinner(mTotalUnconsumed); moveSpinner(mTotalUnconsumed);
} }
// If a client layout is using a custom start position for the circle // If a client layout is using a custom start position for the circle
// view, they mean to hide it again before scrolling the child view // view, they mean to hide it again before scrolling the child view
// If we get back to mTotalUnconsumed == 0 and there is more to go, hide // If we get back to mTotalUnconsumed == 0 and there is more to go, hide
@ -619,7 +616,7 @@ public class DoricSwipeLayout extends ViewGroup implements NestedScrollingParent
// This is a decent indication of whether we should take over the event stream or not. // This is a decent indication of whether we should take over the event stream or not.
final int dy = dyUnconsumed + mParentOffsetInWindow[1]; final int dy = dyUnconsumed + mParentOffsetInWindow[1];
if (dy < 0 && !canChildScrollUp()) { if (dy < 0 && !canChildScrollUp()) {
mTotalUnconsumed += Math.abs(dy); mTotalUnconsumed -= dy;
moveSpinner(mTotalUnconsumed); moveSpinner(mTotalUnconsumed);
} }
} }
@ -872,6 +869,9 @@ public class DoricSwipeLayout extends ViewGroup implements NestedScrollingParent
void setTargetOffsetTopAndBottom(int offset) { void setTargetOffsetTopAndBottom(int offset) {
mRefreshView.bringToFront(); mRefreshView.bringToFront();
ViewCompat.offsetTopAndBottom(mRefreshView, offset); ViewCompat.offsetTopAndBottom(mRefreshView, offset);
if (mTarget != null) {
ViewCompat.offsetTopAndBottom(mTarget, offset);
}
mCurrentTargetOffsetTop = mRefreshView.getTop(); mCurrentTargetOffsetTop = mRefreshView.getTop();
if (mRefreshView.getMeasuredHeight() > 0) { if (mRefreshView.getMeasuredHeight() > 0) {
mRefreshView.setPullingDistance(DoricUtils.px2dp(mRefreshView.getBottom())); mRefreshView.setPullingDistance(DoricUtils.px2dp(mRefreshView.getBottom()));