Skip to content

Commit 627d7df

Browse files
committed
bugfix: scroll
1 parent 3a9d937 commit 627d7df

4 files changed

Lines changed: 12 additions & 12 deletions

File tree

qmui/src/main/java/com/qmuiteam/qmui/nestedScroll/QMUIContinuousNestedScrollLayout.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ private void dispatchScroll(int topCurrent, int topRange,
350350

351351
}
352352
for (OnScrollListener onScrollListener : mOnScrollListeners) {
353-
onScrollListener.onScroll(topCurrent, topRange, offsetCurrent, offsetRange,
353+
onScrollListener.onScroll(this, topCurrent, topRange, offsetCurrent, offsetRange,
354354
bottomCurrent, bottomRange);
355355
}
356356
}
@@ -366,13 +366,13 @@ public void onNestedScroll(View target, int dxConsumed, int dyConsumed, int dxUn
366366

367367
private void dispatchScrollStateChange(int newScrollState, boolean fromTopBehavior) {
368368
for (OnScrollListener onScrollListener : mOnScrollListeners) {
369-
onScrollListener.onScrollStateChange(newScrollState, fromTopBehavior);
369+
onScrollListener.onScrollStateChange(this, newScrollState, fromTopBehavior);
370370
}
371371
mCurrentScrollState = newScrollState;
372372
}
373373

374374
public void scrollBy(int dy) {
375-
if (dy > 0 && mTopAreaBehavior != null) {
375+
if ((dy > 0 || mBottomView == null) && mTopAreaBehavior != null) {
376376
mTopAreaBehavior.scroll(this, ((View) mTopView), dy);
377377
} else if (dy != 0 && mBottomView != null) {
378378
mBottomView.consumeScroll(dy);
@@ -383,7 +383,7 @@ public void smoothScrollBy(int dy, int duration) {
383383
if (dy == 0) {
384384
return;
385385
}
386-
if (dy > 0 && mTopAreaBehavior != null) {
386+
if ((dy > 0 || mBottomView == null) && mTopAreaBehavior != null) {
387387
mTopAreaBehavior.smoothScrollBy(this, ((View) mTopView), dy, duration);
388388
} else if (mBottomView != null) {
389389
mBottomView.smoothScrollYBy(dy, duration);
@@ -553,10 +553,10 @@ public void restoreScrollInfo(@Nullable Bundle bundle) {
553553

554554
public interface OnScrollListener {
555555

556-
void onScroll(int topCurrent, int topRange,
556+
void onScroll(QMUIContinuousNestedScrollLayout scrollLayout, int topCurrent, int topRange,
557557
int offsetCurrent, int offsetRange,
558558
int bottomCurrent, int bottomRange);
559559

560-
void onScrollStateChange(int newScrollState, boolean fromTopBehavior);
560+
void onScrollStateChange(QMUIContinuousNestedScrollLayout scrollLayout, int newScrollState, boolean fromTopBehavior);
561561
}
562562
}

qmuidemo/src/main/java/com/qmuiteam/qmuidemo/fragment/lab/QDContinuousNestedScroll2Fragment.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ protected void initCoordinatorLayout() {
5656
mCoordinatorLayout.addOnScrollListener(new QMUIContinuousNestedScrollLayout.OnScrollListener() {
5757

5858
@Override
59-
public void onScroll(int topCurrent, int topRange, int offsetCurrent,
59+
public void onScroll(QMUIContinuousNestedScrollLayout scrollLayout, int topCurrent, int topRange, int offsetCurrent,
6060
int offsetRange, int bottomCurrent, int bottomRange) {
6161
Log.i(TAG, String.format("topCurrent = %d; topRange = %d; " +
6262
"offsetCurrent = %d; offsetRange = %d; " +
@@ -65,7 +65,7 @@ public void onScroll(int topCurrent, int topRange, int offsetCurrent,
6565
}
6666

6767
@Override
68-
public void onScrollStateChange(int newScrollState, boolean fromTopBehavior) {
68+
public void onScrollStateChange(QMUIContinuousNestedScrollLayout scrollLayout, int newScrollState, boolean fromTopBehavior) {
6969

7070
}
7171
});

qmuidemo/src/main/java/com/qmuiteam/qmuidemo/fragment/lab/QDContinuousNestedScroll7Fragment.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
9595

9696
mCoordinatorLayout.addOnScrollListener(new QMUIContinuousNestedScrollLayout.OnScrollListener() {
9797
@Override
98-
public void onScroll(int topCurrent, int topRange, int offsetCurrent,
98+
public void onScroll(QMUIContinuousNestedScrollLayout scrollLayout, int topCurrent, int topRange, int offsetCurrent,
9999
int offsetRange, int bottomCurrent, int bottomRange) {
100100
Log.i(TAG, String.format("topCurrent = %d; topRange = %d; " +
101101
"offsetCurrent = %d; offsetRange = %d; " +
@@ -104,7 +104,7 @@ public void onScroll(int topCurrent, int topRange, int offsetCurrent,
104104
}
105105

106106
@Override
107-
public void onScrollStateChange(int newScrollState, boolean fromTopBehavior) {
107+
public void onScrollStateChange(QMUIContinuousNestedScrollLayout scrollLayout, int newScrollState, boolean fromTopBehavior) {
108108
Log.i(TAG, String.format("newScrollState = %d; fromTopBehavior = %b",
109109
newScrollState, fromTopBehavior));
110110
}

qmuidemo/src/main/java/com/qmuiteam/qmuidemo/fragment/lab/QDContinuousNestedScroll8Fragment.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public RecyclerView.LayoutParams generateDefaultLayoutParams() {
113113

114114
mCoordinatorLayout.addOnScrollListener(new QMUIContinuousNestedScrollLayout.OnScrollListener() {
115115
@Override
116-
public void onScroll(int topCurrent, int topRange, int offsetCurrent,
116+
public void onScroll(QMUIContinuousNestedScrollLayout scrollLayout, int topCurrent, int topRange, int offsetCurrent,
117117
int offsetRange, int bottomCurrent, int bottomRange) {
118118
Log.i(TAG, String.format("topCurrent = %d; topRange = %d; " +
119119
"offsetCurrent = %d; offsetRange = %d; " +
@@ -122,7 +122,7 @@ public void onScroll(int topCurrent, int topRange, int offsetCurrent,
122122
}
123123

124124
@Override
125-
public void onScrollStateChange(int newScrollState, boolean fromTopBehavior) {
125+
public void onScrollStateChange(QMUIContinuousNestedScrollLayout scrollLayout, int newScrollState, boolean fromTopBehavior) {
126126

127127
}
128128
});

0 commit comments

Comments
 (0)