Skip to content

Commit

Permalink
Making onPageChanged be called continuously
Browse files Browse the repository at this point in the history
  • Loading branch information
lsjwzh committed Nov 4, 2015
1 parent f20f30c commit 60c36a9
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class RecyclerViewPager extends RecyclerView {
int mMinTopWhenDragging = Integer.MAX_VALUE;
private int mPositionOnTouchDown = -1;
private boolean mLoopEnabled;
private boolean mHasCalledOnPageChanged = true;

public RecyclerViewPager(Context context) {
this(context, null);
Expand Down Expand Up @@ -366,7 +367,11 @@ public void onScrollStateChanged(int state) {
mCurView = getLayoutManager().canScrollHorizontally() ? ViewUtils.getCenterXChild(this) :
ViewUtils.getCenterYChild(this);
if (mCurView != null) {
mPositionBeforeScroll = getChildLayoutPosition(mCurView);
if (mHasCalledOnPageChanged) {
// While rvp is scrolling, mPositionBeforeScroll will be previous value.
mPositionBeforeScroll = getChildLayoutPosition(mCurView);
mHasCalledOnPageChanged = false;
}
if (DEBUG) {
Log.d("@", "mPositionBeforeScroll:" + mPositionBeforeScroll);
}
Expand Down Expand Up @@ -424,6 +429,7 @@ public void onScrollStateChanged(int state) {
}
}
}
mHasCalledOnPageChanged = true;
mPositionBeforeScroll = mSmoothScrollTargetPosition;
}
// reset
Expand Down

0 comments on commit 60c36a9

Please sign in to comment.