mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
FragmentClass instance is cached so that JS part does not die before …
* FragmentClass instance is cached so that JS part does not die before native counter part. * Fix tslint error.
This commit is contained in:
@ -7,7 +7,6 @@ import {View} from "ui/core/view";
|
|||||||
import {Observable} from "data/observable";
|
import {Observable} from "data/observable";
|
||||||
import * as application from "application";
|
import * as application from "application";
|
||||||
import * as types from "utils/types";
|
import * as types from "utils/types";
|
||||||
import * as utils from "utils/utils";
|
|
||||||
|
|
||||||
global.moduleMerge(frameCommon, exports);
|
global.moduleMerge(frameCommon, exports);
|
||||||
|
|
||||||
@ -19,6 +18,7 @@ var IS_BACK = "_isBack";
|
|||||||
var NAV_DEPTH = "_navDepth";
|
var NAV_DEPTH = "_navDepth";
|
||||||
var CLEARING_HISTORY = "_clearingHistory";
|
var CLEARING_HISTORY = "_clearingHistory";
|
||||||
var FRAMEID = "_frameId";
|
var FRAMEID = "_frameId";
|
||||||
|
var FRAGMENT = "_FRAGMENT";
|
||||||
|
|
||||||
var navDepth = -1;
|
var navDepth = -1;
|
||||||
|
|
||||||
@ -197,6 +197,9 @@ export class Frame extends frameCommon.Frame {
|
|||||||
newFragment.frame = this;
|
newFragment.frame = this;
|
||||||
newFragment.entry = backstackEntry;
|
newFragment.entry = backstackEntry;
|
||||||
|
|
||||||
|
// Cahce newFragment at backstackEntry instance so that it cannot die while backstackEntry is alive.
|
||||||
|
backstackEntry[FRAGMENT] = newFragment;
|
||||||
|
|
||||||
backstackEntry[BACKSTACK_TAG] = newFragmentTag;
|
backstackEntry[BACKSTACK_TAG] = newFragmentTag;
|
||||||
backstackEntry[NAV_DEPTH] = navDepth;
|
backstackEntry[NAV_DEPTH] = navDepth;
|
||||||
|
|
||||||
@ -664,7 +667,7 @@ class FragmentClass extends android.app.Fragment {
|
|||||||
public onDestroy(): void {
|
public onDestroy(): void {
|
||||||
trace.write(`${this.getTag()}.onDestroy()`, trace.categories.NativeLifecycle);
|
trace.write(`${this.getTag()}.onDestroy()`, trace.categories.NativeLifecycle);
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
utils.GC();
|
this.entry[FRAGMENT] = undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user