fix(bottom-navigation-android): crash when changing tab and suspending app (#8030)

This commit is contained in:
Martin Yankov
2019-10-29 17:01:05 +02:00
committed by Manol Donev
parent 85b92b0136
commit a61de80a35

View File

@ -380,10 +380,8 @@ export class BottomNavigation extends TabNavigationBase {
this._bottomNavigationBar.setVisibility(android.view.View.GONE); this._bottomNavigationBar.setVisibility(android.view.View.GONE);
} }
if (this._attachedToWindow) {
this.changeTab(this.selectedIndex); this.changeTab(this.selectedIndex);
} }
}
_onAttachedToWindow(): void { _onAttachedToWindow(): void {
super._onAttachedToWindow(); super._onAttachedToWindow();
@ -467,8 +465,9 @@ export class BottomNavigation extends TabNavigationBase {
// TODO: Should we extract adapter-like class? // TODO: Should we extract adapter-like class?
// TODO: Rename this? // TODO: Rename this?
public changeTab(index: number) { public changeTab(index: number) {
// this is the case when there are no items // index is -1 when there are no items
if (index === -1) { // bot nav is not attached if you change the tab too early
if (index === -1 || !this._attachedToWindow) {
return; return;
} }