Coder Social home page Coder Social logo

Comments (11)

tommybuonomo avatar tommybuonomo commented on June 27, 2024 7

Hi @akankshapaul048 ,
If you call setCurrentItem() on your ViewPager, the dots will automatically refresh

from dotsindicator.

akankshapaul048 avatar akankshapaul048 commented on June 27, 2024 6

Well i did that but no changes

from dotsindicator.

edChori avatar edChori commented on June 27, 2024 1

Try this
Handler().postDelayed({viewPager.setCurrentItem(1, true)}, 100)

from dotsindicator.

wachidsusilo avatar wachidsusilo commented on June 27, 2024 1

@SamadiPour This worked for me:

    private void buildViewPager(){
        ....
        viewPager.setCurrentItem(0); //this goes to onCreate() method
    }

    private boolean onStart = true;
    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        if(onStart){
            onStart = false;
            viewPager.setCurrentItem(initialPosition, false); //set initial position you want
        }
    }

from dotsindicator.

oliverspryn avatar oliverspryn commented on June 27, 2024

Correct, this is still a problem, unless you setCurrentItem with an animation.

viewPager.setCurrentItem(1, true)

from dotsindicator.

vkotovv avatar vkotovv commented on June 27, 2024

@tommybuonomo any updates on this?

from dotsindicator.

SamadiPour avatar SamadiPour commented on June 27, 2024

Handler().postDelayed({viewPager.setCurrentItem(1, true)}, 75) worked but i want it without this!
is there any other way?

from dotsindicator.

krodyrobi avatar krodyrobi commented on June 27, 2024

Hello, we've hit this as well.

Both the Spring and Worm implementations have the same buggy behavior, on a dark mode switch it selects the 1'st dot but the adapter reports position 3 as the currently active item.
It does not happen on the Dots one, and that is a shame as Worm is so cool.

Debugging the override fun onPageScrolled(selectedPosition: Int, nextPosition: Int, positionOffset: Float) callback of worm we see the correct nextPosition but since the dots are not present (only 1 is rendered) it cannot compute the offset to scroll to.

vp.setCurrentItem(pos, smooth) only works correctly for Dots not for the other 2.
In our case we use flow and no matter the delay we use we cannot get it to work.

Dot state recovers on next / prev page navigations or on adapter changes.
Can you guys have a look at it?

from dotsindicator.

AntonShynkaretskyi avatar AntonShynkaretskyi commented on June 27, 2024

It's still the problem. Indicator doesn't update it's state correctly, and I don't see a way to set currentItem manually

from dotsindicator.

tommybuonomo avatar tommybuonomo commented on June 27, 2024

Duplicate of #126

from dotsindicator.

tommybuonomo avatar tommybuonomo commented on June 27, 2024

Hello there, thanks everyone for your contribution
This will be fixed in the 4.3 release

from dotsindicator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.