mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +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) {
|
||||
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);
|
||||
|
@ -579,7 +579,7 @@ var NativeActivity = {
|
||||
|
||||
onDestroy: function () {
|
||||
let rootView: View = this.rootView
|
||||
if (rootView) {
|
||||
if (rootView && rootView._context) {
|
||||
rootView._onDetached(true);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user