Merge pull request #1605 from NativeScript/on-detached

Fixed Issue #1543: View._onDetached called twice when app is suspended.
This commit is contained in:
Rossen Hristov
2016-02-22 16:52:32 +02:00
2 changed files with 7 additions and 4 deletions

View File

@ -180,8 +180,9 @@ export class View extends viewCommon.View {
public _removeViewCore(view: viewCommon.View) {
super._removeViewCore(view);
// TODO: Detach from the context?
view._onDetached();
if (view._context) {
view._onDetached();
}
}
public _onAttached(context: android.content.Context) {
@ -227,7 +228,9 @@ export class View extends viewCommon.View {
if (child._isAddedToNativeVisualTree) {
that._removeViewFromNativeVisualTree(child);
}
child._onDetached(force);
if (child._context) {
child._onDetached(force);
}
return true;
}
this._eachChildView(eachChild);

View File

@ -579,7 +579,7 @@ var NativeActivity = {
onDestroy: function () {
let rootView: View = this.rootView
if (rootView) {
if (rootView && rootView._context) {
rootView._onDetached(true);
}