mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Merge pull request #1605 from NativeScript/on-detached
Fixed Issue #1543: View._onDetached called twice when app is suspended.
This commit is contained in:
@@ -180,8 +180,9 @@ export class View extends viewCommon.View {
|
|||||||
|
|
||||||
public _removeViewCore(view: viewCommon.View) {
|
public _removeViewCore(view: viewCommon.View) {
|
||||||
super._removeViewCore(view);
|
super._removeViewCore(view);
|
||||||
// TODO: Detach from the context?
|
if (view._context) {
|
||||||
view._onDetached();
|
view._onDetached();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public _onAttached(context: android.content.Context) {
|
public _onAttached(context: android.content.Context) {
|
||||||
@@ -227,7 +228,9 @@ export class View extends viewCommon.View {
|
|||||||
if (child._isAddedToNativeVisualTree) {
|
if (child._isAddedToNativeVisualTree) {
|
||||||
that._removeViewFromNativeVisualTree(child);
|
that._removeViewFromNativeVisualTree(child);
|
||||||
}
|
}
|
||||||
child._onDetached(force);
|
if (child._context) {
|
||||||
|
child._onDetached(force);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
this._eachChildView(eachChild);
|
this._eachChildView(eachChild);
|
||||||
|
|||||||
@@ -579,7 +579,7 @@ var NativeActivity = {
|
|||||||
|
|
||||||
onDestroy: function () {
|
onDestroy: function () {
|
||||||
let rootView: View = this.rootView
|
let rootView: View = this.rootView
|
||||||
if (rootView) {
|
if (rootView && rootView._context) {
|
||||||
rootView._onDetached(true);
|
rootView._onDetached(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user