Skip to content

Commit 5f443be

Browse files
committed
Fixed Issue #1543: View._onDetached called twice when app is suspended.
1 parent 2a8b2ae commit 5f443be

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

‎ui/core/view.android.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,9 @@ export class View extends viewCommon.View {
180180

181181
public _removeViewCore(view: viewCommon.View) {
182182
super._removeViewCore(view);
183-
// TODO: Detach from the context?
184-
view._onDetached();
183+
if (view._context) {
184+
view._onDetached();
185+
}
185186
}
186187

187188
public _onAttached(context: android.content.Context) {
@@ -227,7 +228,9 @@ export class View extends viewCommon.View {
227228
if (child._isAddedToNativeVisualTree) {
228229
that._removeViewFromNativeVisualTree(child);
229230
}
230-
child._onDetached(force);
231+
if (child._context) {
232+
child._onDetached(force);
233+
}
231234
return true;
232235
}
233236
this._eachChildView(eachChild);

‎ui/frame/frame.android.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ var NativeActivity = {
579579

580580
onDestroy: function () {
581581
let rootView: View = this.rootView
582-
if (rootView) {
582+
if (rootView && rootView._context) {
583583
rootView._onDetached(true);
584584
}
585585

0 commit comments

Comments
 (0)