-
-
Notifications
You must be signed in to change notification settings - Fork 464
Description
Hi,
if (isCustomIndicator) {
mIndicatorLayout.removeAllViews();
} else if (mIndicatorView == null) {
mIndicatorView = new IndicatorView(getContext());
}
There is a case where the isCustomIndicator is true and the mIndicatorView is null.
In BottomNavigationView, the fragment does not destroy when switching tab but goes through onViewDestory and onCreateView.
Given the following condition:
- BannerViewPager is marked with a id in xml layout
- BannerViewPager is created between the onCreateView and onViewDestory
- create configuration is different between the 2 create, in my case, one uses setIndicatorView and the other dont (Init data have >= 2 item and the second time it have 1 where no indicator will be shown)
The combination of 1 and 2 cause the onRestoreInstanceState onSaveInstanceState passing state between different instance of view thus leading to a isCustomIndicator set to true but mIndicatorView is null.
I know this might be considered as a incorrect way of using the library given the existence of refreshData and setIndicatorVisibility, but i still think it would be a better idea to
if (mIndicatorView != null) {
mIndicatorLayout.removeAllViews();
} else {
mIndicatorView = new IndicatorView(getContext());
}
in setIndicatorValues which covers all the logical cases.
Please let me know you thought on this and what else do i needed to provide. For example to reproduce, if needed, i should be able to provide it on Saturday.