siralam / LoopingViewPager

A ViewPager and PagerAdapter combination that support auto scroll, infinite loop and page indicators.
532 stars 64 forks source link

first page is skipped, last page doesn't have a timer #6

Closed abiemann closed 6 years ago

abiemann commented 6 years ago

my viewpager has 4 pages: indexes 0,1,2,3

It seems that LoopingViewPager starts at page[1] (I expected page[0]), then page[2], then it skips the timer on page[3] and goes directly back to page[1]

usage in XML:

                <com.asksira.loopingviewpager.LoopingViewPager
                    android:id="@+id/viewPager_info_screens"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="@drawable/shape_rect_round_corners_white"
                    android:layout_margin="5dp"
                    android:elevation="5dp"
                    app:isInfinite="true"
                    app:autoScroll="true"
                    app:scrollInterval="3000"/>

in Java:

    LoopingViewPager mPager = findViewById(R.id.viewPager_info_screens);
    mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
    mPager.setAdapter(mPagerAdapter);
siralam commented 6 years ago

Yes, indeed, as long as you have set isInfinite to true. If it is infinite, page[0] and page[3] are just dummies of page[2] and page[1] correspondingly (That means there are only 2 pages from the point of view of user)

I skip the timer of page[3] because we don't want user to know that page[0] and page[3] exists. When ViewPager selected page[3], it will directly, immediately jumps to page[1] (Which is the same as page[3]).

So... what is your question / problem?