Droppers / AnimatedBottomBar

A customizable and easy to use BottomBar navigation view with sleek animations, with support for ViewPager, ViewPager2, NavController, and badges.
MIT License
1.38k stars 109 forks source link

[Fix] onTabReselected been called when tab first selected #10

Closed rosuH closed 3 years ago

rosuH commented 4 years ago

What the problem

The onTabReselected also been called when the tab is first selected.

What caused it

When the user selects a tab, would have followed call chain:

tab

As you can see, when you call ViewPager.setCurrentItem(), the ViewPager will invoke onPageSelected automatically. So that TabAdapter#selectTab would be call in second times. That is why onTabReselected also been called when the tab is first selected.

How to fix it?

In ViewPgaer.onPageScrollStateChanged, I adding some code to detect whether if user touch or programmatically call from code. Here is the ref.


This lib is awesome, Thanks for your work :D

rosuH commented 4 years ago

Yep, I have been tested in ViewPager and ViewPager2. Seen works fine. 😆

rosuH commented 4 years ago

Sorry for the slow response. Github did not email me :D, and I have submitted the changes as per your suggestion. Please review the code again.