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

Method _navigateCore

packages/core/ui/frame/index.android.ts:368–432  ·  view source on GitHub ↗
(newEntry: BackstackEntry)

Source from the content-addressed store, hash-verified

366 // HACK: because the function parameter type is evaluated with 'typeof'
367 @profile
368 public _navigateCore(newEntry: BackstackEntry) {
369 // should be (newEntry: BackstackEntry)
370 super._navigateCore(newEntry);
371
372 // set frameId here so that we could use it in fragment.transitions
373 newEntry.frameId = this._android.frameId;
374
375 const activity = this._android.activity;
376 if (!activity) {
377 // Activity not associated. In this case we have two execution paths:
378 // 1. This is the main frame for the application
379 // 2. This is an inner frame which requires a new Activity
380 const currentActivity = this._android.currentActivity;
381 if (currentActivity) {
382 startActivity(currentActivity, this._android.frameId);
383 }
384
385 return;
386 }
387
388 const manager: androidx.fragment.app.FragmentManager = this._getFragmentManager();
389 const clearHistory = newEntry.entry.clearHistory;
390 const currentEntry = this._currentEntry;
391
392 // New Fragment
393 if (clearHistory) {
394 navDepth = -1;
395 }
396
397 const isReplace = this._executingContext && this._executingContext.navigationType === NavigationType.replace;
398 if (!isReplace) {
399 navDepth++;
400 }
401
402 fragmentId++;
403 const newFragmentTag = `fragment${fragmentId}[${navDepth}]`;
404 const newFragment = this.createFragment(newEntry, newFragmentTag);
405 const transaction = manager.beginTransaction();
406 const animated = currentEntry ? this._getIsAnimatedNavigation(newEntry.entry) : false;
407 // NOTE: Don't use transition for the initial navigation (same as on iOS)
408 // On API 21+ transition won't be triggered unless there was at least one
409 // layout pass so we will wait forever for transitionCompleted handler...
410 // https://github.com/NativeScript/NativeScript/issues/4895
411 let navigationTransition: NavigationTransition;
412 if (currentEntry) {
413 navigationTransition = this._getNavigationTransition(newEntry.entry);
414 } else {
415 navigationTransition = null;
416 }
417
418 const isNestedDefaultTransition = !currentEntry;
419
420 _setAndroidFragmentTransitions(animated, navigationTransition, currentEntry, newEntry, this._android.frameId, transaction, this.direction, isNestedDefaultTransition);
421
422 if (currentEntry && animated && !navigationTransition) {
423 //TODO: Check whether or not this is still necessary. For Modal views?
424 // transaction.setTransition(androidx.fragment.app.FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
425 }

Callers 1

Calls 8

createFragmentMethod · 0.95
startActivityFunction · 0.85
_getFragmentManagerMethod · 0.80
replaceMethod · 0.80

Tested by

no test coverage detected