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

Method setCurrent

packages/core/ui/frame/index.android.ts:287–344  ·  view source on GitHub ↗
(entry: BackstackEntry, navigationType: NavigationType)

Source from the content-addressed store, hash-verified

285 }
286
287 public setCurrent(entry: BackstackEntry, navigationType: NavigationType): void {
288 const current = this._currentEntry;
289 const currentEntryChanged = current !== entry;
290 if (currentEntryChanged) {
291 this._updateBackstack(entry, navigationType);
292
293 // If activity was destroyed we need to destroy fragment and UI
294 // of current and new entries.
295 if (this._tearDownPending) {
296 this._tearDownPending = false;
297 if (!entry.recreated) {
298 this._disposeBackstackEntry(entry);
299 }
300
301 if (current && !current.recreated) {
302 this._disposeBackstackEntry(current);
303 }
304
305 // If we have context activity was recreated. Create new fragment
306 // and UI for the new current page.
307 const context = this._context;
308 if (context && !entry.recreated) {
309 entry.fragment = this.createFragment(entry, entry.fragmentTag);
310 entry.resolvedPage._setupUI(context);
311 }
312
313 entry.recreated = false;
314
315 if (current) {
316 current.recreated = false;
317 }
318 }
319
320 super.setCurrent(entry, navigationType);
321
322 // If we had real navigation process queue.
323 this._processNavigationQueue(entry.resolvedPage);
324 } else {
325 // Otherwise currentPage was recreated so this wasn't real navigation.
326 // Continue with next item in the queue.
327 this._processNextNavigationEntry();
328 }
329
330 // Restore cached animation settings if we just completed simulated first navigation (no animation)
331 this._restoreTransitionState();
332
333 // restore original fragment transitions if we just completed replace navigation (hmr)
334 if (navigationType === NavigationType.replace) {
335 _clearEntry(entry);
336
337 const animated = this._getIsAnimatedNavigation(entry.entry);
338 const navigationTransition = this._getNavigationTransition(entry.entry);
339 const currentEntry = null;
340 const newEntry = entry;
341 const transaction = null;
342 _setAndroidFragmentTransitions(animated, navigationTransition, currentEntry, newEntry, this._android.frameId, transaction, this.direction);
343 }
344 }

Callers

nothing calls this directly

Calls 11

createFragmentMethod · 0.95
_clearEntryFunction · 0.90
_updateBackstackMethod · 0.80
_setupUIMethod · 0.80

Tested by

no test coverage detected