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

CirclePageIndicator is not working with InfiniteViewPager #30

Open
GaneshB-Extentia opened this issue May 12, 2015 · 12 comments
Open

CirclePageIndicator is not working with InfiniteViewPager #30

GaneshB-Extentia opened this issue May 12, 2015 · 12 comments

Comments

@GaneshB-Extentia
Copy link

CirclePageIndicator (com.viewpagerindicator.CirclePageIndicator) is not working with InfiniteViewPager.

@joshma91
Copy link

This worked quite nicely for me:
https://github.com/surfstudio/InfinitePageIndicator

@vsay01
Copy link

vsay01 commented Jan 25, 2016

@joshma91 The link provided above worked but the animation of circlepageindicator from last item to first item not good? because it go to empty spot then come to first spot.
Any idea how we can fix the animation from last to first of circlepageindicator with infiniteViewpager?

@joshma91
Copy link

@vsay01 I'm sorry, I'm a bit removed from the project where I used this and don't have the source code anymore. Did you do all of the things this page recommends doing? https://github.com/surfstudio/InfinitePageIndicator/blob/master/README.md

@vsay01
Copy link

vsay01 commented Jan 25, 2016

@joshma91 Yes, I was be able to set the circlepagindicator with the infiniteviewpager.
But in the demo, they recommended the animation should be disabled.
From the demo:

// Because animation between circles now looks ugly, we should disable it
   mPageIndicator.setSnap(true);

When I enable the animation it works fine first to second to the last but the animation from last to first and first to last the animation not good because selected circle move to the empty spot (virtual spot) before move to first or last.

Any idea how can we improve it?
Thank

@joshma91
Copy link

@vsay01 Found my code - here's my implementation. You can see there's a couple tweaks in here which I think I needed to add to get it to work. Hope this helps

    pagerView = (InfiniteViewPager) activity.findViewById(R.id.pager);
    pageIndicator = (CirclePageIndicator) activity.findViewById(R.id.line_indicator);
    pageIndicator.setSnap(true);
    currentPosition = 0;

    ArrayList<ListItem> listItem = getListItems();

    //add the first item again as the last, to create the wrap effect
    listItem.add(listItem .get(0));

    //insert a copy of the last item as the new first item, so we can scroll backwards
    listItem.add(0, listItem.get(listItem.size() - 1));

    listAdapter = new ListAdapter(activity, listItem);
    pagerAdapter = new InfinitePagerAdapter(listAdapter );
    pagerAdapter.setOneItemMode();
    pagerView.setAdapter(pagerAdapter);

    pagerView.setCurrentItem(currentPosition);
    pageIndicator.setCurrentItem(currentPosition);
    pagerView.invalidate();

   pagerView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent touchevent) {
            return false;
        }
    });

@vsay01
Copy link

vsay01 commented Jan 25, 2016

@joshma91 Thank I followed the code I got an error
ViewPager has not been bound it seems like you didnt bound the view pager to pageindicator?

Plus when you setSnap(true) it will disable the animation, but I would like to keep the animation of the circlePageindicator.

@joshma91
Copy link

@vsay01
woops. turns out I set the viewpager in another method. Put this pageIndicator.setViewPager(pagerView);
right before
pagerView.setCurrentItem(currentPosition)

I'm not sure about the setSnap. Just try true/false and see what works for you

@vsay01
Copy link

vsay01 commented Jan 26, 2016

@joshma91 I tried your code

  • when added the last item to the front of the circle increase
    for instance: 4 slides has 5 circle
  • No animation
    When enable animation using setSnap(false) the same animation issue (when circle move from the last to the first item it move to the empty spot ahead then go to first item)

@joshma91
Copy link

@vsay01 I'm sorry, I'm out of ideas on how to help you now. That was all I had for my code... Good luck with this, I hope you figure it out soon.

@vsay01
Copy link

vsay01 commented Jan 26, 2016

@joshma91 Thank 👍

@monchiez13
Copy link

doesnt work for me, it freezes then crashes later

@RahulSDeshpande
Copy link

@monchiez13 For me too - it crashes if I use TabLayout with InfiniteViewPager !!
Seems this lib is not intended to work with the TabLayouts or page indicators !!

Any fix would be appreciated !!
:)

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

No branches or pull requests

5 participants