mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 20:11:24 +08:00
refactor: guard ng and vue entry points (#7071)
This commit is contained in:
@ -1171,46 +1171,50 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks {
|
|||||||
|
|
||||||
if (!rootView) {
|
if (!rootView) {
|
||||||
const mainEntry = application.getMainEntry();
|
const mainEntry = application.getMainEntry();
|
||||||
if (!mainEntry) {
|
|
||||||
throw new Error("Main entry is missing. App cannot be started. Verify app bootstrap.");
|
|
||||||
}
|
|
||||||
|
|
||||||
const intent = activity.getIntent();
|
const intent = activity.getIntent();
|
||||||
|
|
||||||
if (fireLaunchEvent) {
|
if (fireLaunchEvent) {
|
||||||
|
// entry point for Angular and Vue frameworks
|
||||||
rootView = notifyLaunch(intent, savedInstanceState);
|
rootView = notifyLaunch(intent, savedInstanceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldCreateRootFrame) {
|
if (!rootView) {
|
||||||
const extras = intent.getExtras();
|
// entry point for NS Core
|
||||||
let frameId = -1;
|
if (!mainEntry) {
|
||||||
|
// Also handles scenarios with Angular and Vue where the notifyLaunch didn't return a root view.
|
||||||
// We have extras when we call - new Frame().navigate();
|
throw new Error("Main entry is missing. App cannot be started. Verify app bootstrap.");
|
||||||
// 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) {
|
if (shouldCreateRootFrame) {
|
||||||
frameId = savedInstanceState.getInt(INTENT_EXTRA, -1);
|
const extras = intent.getExtras();
|
||||||
}
|
let frameId = -1;
|
||||||
|
|
||||||
if (!rootView) {
|
// We have extras when we call - new Frame().navigate();
|
||||||
// If we have frameId from extras - we are starting a new activity from navigation (e.g. new Frame().navigate()))
|
// savedInstanceState is used when activity is recreated.
|
||||||
// Then we check if we have frameId from savedInstanceState - this happens when Activity is destroyed but app was not (e.g. suspend)
|
// NOTE: On API 23+ we get extras on first run.
|
||||||
rootView = getFrameByNumberId(frameId) || new Frame();
|
// Check changed - first try to get frameId from Extras if not from saveInstanceState.
|
||||||
}
|
if (extras) {
|
||||||
|
frameId = extras.getInt(INTENT_EXTRA, -1);
|
||||||
if (rootView instanceof Frame) {
|
}
|
||||||
rootView.navigate(mainEntry);
|
|
||||||
|
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 {
|
} 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;
|
this._rootView = rootView;
|
||||||
|
Reference in New Issue
Block a user