Skip to content

Invalid indicator position #49

@rt1shnik

Description

@rt1shnik

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();
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions