mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 20:11:24 +08:00
Merge pull request #7075 from NativeScript/myankov/merge
chore: merge release to master
This commit is contained in:
@ -131,9 +131,8 @@ let mainEntry: NavigationEntry;
|
||||
let started = false;
|
||||
// NOTE: for backwards compatibility. Remove for 4.0.0.
|
||||
const createRootFrame = { value: true };
|
||||
export function start(entry?: NavigationEntry | string) {
|
||||
console.log("application.start() is deprecated; use application.run() instead");
|
||||
|
||||
function _start(entry?: NavigationEntry | string) {
|
||||
if (started) {
|
||||
throw new Error("Application is already started.");
|
||||
}
|
||||
@ -146,13 +145,18 @@ export function start(entry?: NavigationEntry | string) {
|
||||
}
|
||||
}
|
||||
|
||||
export function start(entry?: NavigationEntry | string) {
|
||||
console.log("application.start() is deprecated; use application.run() instead");
|
||||
_start(entry);
|
||||
}
|
||||
|
||||
export function shouldCreateRootFrame(): boolean {
|
||||
return createRootFrame.value;
|
||||
}
|
||||
|
||||
export function run(entry?: NavigationEntry | string) {
|
||||
createRootFrame.value = false;
|
||||
start(entry);
|
||||
_start(entry);
|
||||
}
|
||||
|
||||
const CALLBACKS = "_callbacks";
|
||||
|
@ -275,16 +275,15 @@ function createRootView(v?: View) {
|
||||
let rootView = v;
|
||||
if (!rootView) {
|
||||
// try to navigate to the mainEntry (if specified)
|
||||
if (mainEntry) {
|
||||
if (!mainEntry) {
|
||||
throw new Error("Main entry is missing. App cannot be started. Verify app bootstrap.");
|
||||
} else {
|
||||
if (createRootFrame.value) {
|
||||
const frame = rootView = new Frame();
|
||||
frame.navigate(mainEntry);
|
||||
} else {
|
||||
rootView = createViewFromEntry(mainEntry);
|
||||
}
|
||||
} else {
|
||||
// TODO: Throw an exception?
|
||||
throw new Error("A Frame must be used to navigate to a Page.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -302,9 +301,7 @@ export function getRootView() {
|
||||
// NOTE: for backwards compatibility. Remove for 4.0.0.
|
||||
const createRootFrame = { value: true };
|
||||
let started: boolean = false;
|
||||
export function start(entry?: string | NavigationEntry) {
|
||||
console.log("application.start() is deprecated; use application.run() instead");
|
||||
|
||||
function _start(entry?: string | NavigationEntry) {
|
||||
mainEntry = typeof entry === "string" ? { moduleName: entry } : entry;
|
||||
started = true;
|
||||
|
||||
@ -336,9 +333,14 @@ export function start(entry?: string | NavigationEntry) {
|
||||
}
|
||||
}
|
||||
|
||||
export function start(entry?: string | NavigationEntry) {
|
||||
console.log("application.start() is deprecated; use application.run() instead");
|
||||
_start(entry);
|
||||
}
|
||||
|
||||
export function run(entry?: string | NavigationEntry) {
|
||||
createRootFrame.value = false;
|
||||
start(entry);
|
||||
_start(entry);
|
||||
}
|
||||
|
||||
export function _resetRootView(entry?: NavigationEntry | string) {
|
||||
|
@ -1174,39 +1174,47 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks {
|
||||
const intent = activity.getIntent();
|
||||
|
||||
if (fireLaunchEvent) {
|
||||
// entry point for Angular and Vue frameworks
|
||||
rootView = notifyLaunch(intent, savedInstanceState);
|
||||
}
|
||||
|
||||
if (shouldCreateRootFrame) {
|
||||
const extras = intent.getExtras();
|
||||
let frameId = -1;
|
||||
|
||||
// We have extras when we call - new Frame().navigate();
|
||||
// savedInstanceState is used when activity is recreated.
|
||||
// NOTE: On API 23+ we get extras on first run.
|
||||
// Check changed - first try to get frameId from Extras if not from saveInstanceState.
|
||||
if (extras) {
|
||||
frameId = extras.getInt(INTENT_EXTRA, -1);
|
||||
if (!rootView) {
|
||||
// entry point for NS Core
|
||||
if (!mainEntry) {
|
||||
// Also handles scenarios with Angular and Vue where the notifyLaunch didn't return a root view.
|
||||
throw new Error("Main entry is missing. App cannot be started. Verify app bootstrap.");
|
||||
}
|
||||
|
||||
if (savedInstanceState && frameId < 0) {
|
||||
frameId = savedInstanceState.getInt(INTENT_EXTRA, -1);
|
||||
}
|
||||
|
||||
if (!rootView) {
|
||||
// If we have frameId from extras - we are starting a new activity from navigation (e.g. new Frame().navigate()))
|
||||
// Then we check if we have frameId from savedInstanceState - this happens when Activity is destroyed but app was not (e.g. suspend)
|
||||
rootView = getFrameByNumberId(frameId) || new Frame();
|
||||
}
|
||||
|
||||
if (rootView instanceof Frame) {
|
||||
rootView.navigate(mainEntry);
|
||||
if (shouldCreateRootFrame) {
|
||||
const extras = intent.getExtras();
|
||||
let frameId = -1;
|
||||
|
||||
// We have extras when we call - new Frame().navigate();
|
||||
// savedInstanceState is used when activity is recreated.
|
||||
// NOTE: On API 23+ we get extras on first run.
|
||||
// Check changed - first try to get frameId from Extras if not from saveInstanceState.
|
||||
if (extras) {
|
||||
frameId = extras.getInt(INTENT_EXTRA, -1);
|
||||
}
|
||||
|
||||
if (savedInstanceState && frameId < 0) {
|
||||
frameId = savedInstanceState.getInt(INTENT_EXTRA, -1);
|
||||
}
|
||||
|
||||
if (!rootView) {
|
||||
// If we have frameId from extras - we are starting a new activity from navigation (e.g. new Frame().navigate()))
|
||||
// Then we check if we have frameId from savedInstanceState - this happens when Activity is destroyed but app was not (e.g. suspend)
|
||||
rootView = getFrameByNumberId(frameId) || new Frame();
|
||||
}
|
||||
|
||||
if (rootView instanceof Frame) {
|
||||
rootView.navigate(mainEntry);
|
||||
} else {
|
||||
throw new Error("A Frame must be used to navigate to a Page.");
|
||||
}
|
||||
} else {
|
||||
throw new Error("A Frame must be used to navigate to a Page.");
|
||||
rootView = createViewFromEntry(mainEntry);
|
||||
}
|
||||
} else {
|
||||
// Create the root view if the notifyLaunch didn't return it
|
||||
rootView = rootView || createViewFromEntry(mainEntry);
|
||||
}
|
||||
|
||||
this._rootView = rootView;
|
||||
|
Reference in New Issue
Block a user