Commit 60c36a9 1 parent f20f30c commit 60c36a9 Copy full SHA for 60c36a9
File tree 1 file changed +7
-1
lines changed
lib/src/main/java/com/lsjwzh/widget/recyclerviewpager
1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ public class RecyclerViewPager extends RecyclerView {
44
44
int mMinTopWhenDragging = Integer .MAX_VALUE ;
45
45
private int mPositionOnTouchDown = -1 ;
46
46
private boolean mLoopEnabled ;
47
+ private boolean mHasCalledOnPageChanged = true ;
47
48
48
49
public RecyclerViewPager (Context context ) {
49
50
this (context , null );
@@ -366,7 +367,11 @@ public void onScrollStateChanged(int state) {
366
367
mCurView = getLayoutManager ().canScrollHorizontally () ? ViewUtils .getCenterXChild (this ) :
367
368
ViewUtils .getCenterYChild (this );
368
369
if (mCurView != null ) {
369
- mPositionBeforeScroll = getChildLayoutPosition (mCurView );
370
+ if (mHasCalledOnPageChanged ) {
371
+ // While rvp is scrolling, mPositionBeforeScroll will be previous value.
372
+ mPositionBeforeScroll = getChildLayoutPosition (mCurView );
373
+ mHasCalledOnPageChanged = false ;
374
+ }
370
375
if (DEBUG ) {
371
376
Log .d ("@" , "mPositionBeforeScroll:" + mPositionBeforeScroll );
372
377
}
@@ -424,6 +429,7 @@ public void onScrollStateChanged(int state) {
424
429
}
425
430
}
426
431
}
432
+ mHasCalledOnPageChanged = true ;
427
433
mPositionBeforeScroll = mSmoothScrollTargetPosition ;
428
434
}
429
435
// reset
You can’t perform that action at this time.
0 commit comments