Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid indicator position #49

Open
rt1shnik opened this issue Aug 11, 2019 · 0 comments · May be fixed by #51
Open

Invalid indicator position #49

rt1shnik opened this issue Aug 11, 2019 · 0 comments · May be fixed by #51

Comments

@rt1shnik
Copy link

Sometimes when I change position of ViewPager I see that current tab at RecyclerTabLayout stay the same. I've figure out after some debugging where is problem.
See at method updateCurrentIndicatorPosition. This method don't change adapter's indicatorPosition if dx is 0. So RecyclerTabLayout's position and ViewPager's position do not match.

protected void updateCurrentIndicatorPosition(int position, float dx, float positionOffset) {
if (mAdapter == null) {
return;
}
int indicatorPosition = -1;
if (dx > 0 && positionOffset >= mPositionThreshold - POSITION_THRESHOLD_ALLOWABLE) {
indicatorPosition = position + 1;
} else if (dx < 0 && positionOffset <= 1 - mPositionThreshold + POSITION_THRESHOLD_ALLOWABLE) {
indicatorPosition = position;
}
if (indicatorPosition >= 0 && indicatorPosition != mAdapter.getCurrentIndicatorPosition()) {
mAdapter.setCurrentIndicatorPosition(indicatorPosition);
mAdapter.notifyDataSetChanged();
}
}

rt1shnik added a commit to rt1shnik/RecyclerTabLayout that referenced this issue Aug 29, 2019
rt1shnik added a commit to rt1shnik/RecyclerTabLayout that referenced this issue Aug 29, 2019
@rt1shnik rt1shnik linked a pull request Aug 29, 2019 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant