MCPcopy Create free account
hub / github.com/NativeScript/NativeScript / disposeNativeView

Method disposeNativeView

packages/core/ui/frame/index.android.ts:507–546  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

505 }
506
507 public disposeNativeView() {
508 const nativeView = this.nativeViewProtected as android.view.ViewGroup;
509 const listener = getAttachListener();
510
511 nativeView.removeOnAttachStateChangeListener(listener);
512 nativeView[ownerSymbol] = null;
513
514 // There are cases like root view when detach listener is not called before the native view gets disposed
515 // so call detach method directly for these views
516 if (this._attachedToWindow) {
517 this._onDetachedFromWindow();
518 }
519
520 this._tearDownPending = !!this._executingContext;
521
522 const current = this._currentEntry;
523 const executingEntry = this._executingContext ? this._executingContext.entry : null;
524
525 this.backStack.forEach((entry) => {
526 // Don't destroy current and executing entries or UI will look blank.
527 // We will do it in setCurrent.
528 if (entry !== executingEntry) {
529 this._disposeBackstackEntry(entry);
530 }
531 });
532
533 if (current && !executingEntry) {
534 this._disposeBackstackEntry(current);
535 }
536
537 // Dispose cached transition and store it again if view ever gets re-used
538 this._cachedTransitionState = null;
539
540 // Mark as reset in order to properly re-initialize fragments if view ever gets re-used
541 this._isReset = true;
542
543 this._android.rootViewGroup = null;
544 this._removeFromFrameStack();
545 super.disposeNativeView();
546 }
547
548 public _popFromFrameStack() {
549 if (!this._isInFrameStack) {

Callers

nothing calls this directly

Calls 5

_onDetachedFromWindowMethod · 0.95
getAttachListenerFunction · 0.85
forEachMethod · 0.80
_removeFromFrameStackMethod · 0.80

Tested by

no test coverage detected