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

Jump to any item using setCurrentItem(3,true); is not working correctly #8

Closed
vipinhelloindia opened this issue Apr 3, 2014 · 5 comments · Fixed by #15
Closed

Jump to any item using setCurrentItem(3,true); is not working correctly #8

vipinhelloindia opened this issue Apr 3, 2014 · 5 comments · Fixed by #15

Comments

@vipinhelloindia
Copy link

viewPager.setCurrentItem(viewPager.getCurrentItem() + 1);
@aeroechelon
Copy link
Contributor

Please see pull request #15 for this fix.

@DigitalDavo
Copy link

I have this fix, but still get an infinite for(); loop entry on about half of my calls to setCurrentItem();

@aeroechelon
Copy link
Contributor

Infinite for loop on some of your calls to setCurrentItem()? The fix essentially forwards the params of overloaded methodsetCurrenItem(int, boolean) to the original method setCurrenItem(int). Could you post more details of your issue?

@Override
    public void setCurrentItem(int item) {
        // offset the current item to ensure there is space to scroll
        setCurrentItem(item, false);
    }

    @Override
    public void setCurrentItem(int item, boolean smoothScroll) {
        item = getOffsetAmount() + (item % getAdapter().getCount());
        super.setCurrentItem(item, smoothScroll);
    }

@DigitalDavo
Copy link

I have 4 fragments. There are links from fragment0 to the 3 other fragments, and then a "BACK" link to fragment0 from the other fragments. It is a bit hit and miss as to whether you will get across or back to the main fragment or not. Half of the time it works and the other half of the time you hit the infinite loop and after 20 seconds you get the system isn't responding wait/ok/report dialogue.

It was reported on stackoverflow that it failed if the transition was from a lower to a higher virtual position number, but I'm not sure it was thas simple.

@aeroechelon
Copy link
Contributor

Do you see the same issue if you use setCurrentItem(int item)?

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.

3 participants