andremion / CounterFab

A FloatingActionButton subclass that shows a counter badge on right top corner

Home Page:https://play.google.com/store/apps/details?id=com.andremion.counterfab.sample

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to update counter value

saintjab opened this issue · comments

Great library. I am trying to update the value of the counter but can only work on the initial setCount(), subsequent ones are not updating the value. I am currently setting the value at the onCreateView of a fragment where I can increase/decrease the value. However when I come back to the same fragment the new setCount() isn't working because the fragment never got destroyed though onCreateView is called and getCount() shows the value I set but doesn't update the value with the set value. Any advice why this is happening?

Hey, thank you for using it.
Could you please add some code snippets of how you are using it so I can try to reproduce and understand better the scenario.

Hey, sorry for the delay. I have attached a screenshot on the issue. I am using increase() and decrease() methods which work successfully to increase/ decrease the value of the count. However as shown in the highlighted screenshot, though the fab.setCount() method seems to work, the fab view isn't updating the count from 3 to new value 2
screenshot
.

I don't know if I got your question.
But you said that the "issue" occurs when you come back to that fragment where you are setting the count value in onCreateView method.
That means that your fragment is just resuming and you need to chose another lifecycle method to set the count, like onResume for example.
This could occurs with any view that you manipulate outside your fragment's view. Be careful with that.

@andremion. I moved the update to the onResume() and that solved the issue. Thanks for the pointer. You can close this now.

You're welcome!