Fix android crash TabViewItem canBeLoaded was true even when TabView was destroyed

Fix android crash modal view was not destroyed even though his dialog was
This commit is contained in:
Hristo Hristov
2017-12-14 13:37:56 +02:00
parent 365d48550f
commit 4e74c37313
4 changed files with 18 additions and 17 deletions

View File

@@ -187,14 +187,18 @@ function initializeDialogFragment() {
super.onDismiss(dialog); super.onDismiss(dialog);
const manager = this.getFragmentManager(); const manager = this.getFragmentManager();
if (manager) { if (manager) {
const owner = this.owner; removeModal(this.owner._domId);
removeModal(owner._domId);
this._dismissCallback(); this._dismissCallback();
}
}
public onDestroy(): void {
super.onDestroy();
const owner = this.owner;
owner._isAddedToNativeVisualTree = false; owner._isAddedToNativeVisualTree = false;
owner._tearDownUI(true); owner._tearDownUI(true);
} }
} }
}
DialogFragment = DialogFragmentImpl; DialogFragment = DialogFragmentImpl;
} }

View File

@@ -208,10 +208,6 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition {
return this._currentEntry === entry; return this._currentEntry === entry;
} }
public changeEntry(entry: BackstackEntry): void {
// android specific.
}
public setCurrent(entry: BackstackEntry, isBack: boolean): void { public setCurrent(entry: BackstackEntry, isBack: boolean): void {
const newPage = entry.resolvedPage; const newPage = entry.resolvedPage;
// In case we navigated forward to a page that was in the backstack // In case we navigated forward to a page that was in the backstack

View File

@@ -170,12 +170,6 @@ export class Frame extends FrameBase {
return newFragment; return newFragment;
} }
public changeEntry(entry: BackstackEntry): void {
const isBack = this._isBack;
this.setCurrent(entry, isBack);
this._isBack = true;
}
public setCurrent(entry: BackstackEntry, isBack: boolean): void { public setCurrent(entry: BackstackEntry, isBack: boolean): void {
const current = this._currentEntry; const current = this._currentEntry;
const currentEntryChanged = current !== entry; const currentEntryChanged = current !== entry;
@@ -189,12 +183,10 @@ export class Frame extends FrameBase {
if (this._tearDownPending) { if (this._tearDownPending) {
this._tearDownPending = false; this._tearDownPending = false;
if (!entry.recreated) { if (!entry.recreated) {
entry.recreated = false;
clearEntry(entry); clearEntry(entry);
} }
if (current && !current.recreated) { if (current && !current.recreated) {
current.recreated = false;
clearEntry(current); clearEntry(current);
} }
@@ -205,6 +197,9 @@ export class Frame extends FrameBase {
entry.fragment = this.createFragment(entry, entry.fragmentTag); entry.fragment = this.createFragment(entry, entry.fragmentTag);
entry.resolvedPage._setupUI(context); entry.resolvedPage._setupUI(context);
} }
entry.recreated = false;
current.recreated = false;
} }
super.setCurrent(entry, isBack); super.setCurrent(entry, isBack);
@@ -402,6 +397,7 @@ function clearEntry(entry: BackstackEntry): void {
_clearFragment(entry); _clearFragment(entry);
} }
entry.recreated = false;
entry.fragment = null; entry.fragment = null;
const page = entry.resolvedPage; const page = entry.resolvedPage;
if (page._context) { if (page._context) {

View File

@@ -261,6 +261,11 @@ export class TabViewItem extends TabViewItemBase {
} }
} }
public disposeNativeView(): void {
super.disposeNativeView();
(<TabViewItemDefinition>this).canBeLoaded = false;
}
public createNativeView() { public createNativeView() {
return this.nativeViewProtected; return this.nativeViewProtected;
} }