mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Disable recycling of native views
createNativeView will set iOS nativeView if it is null/undefined
This commit is contained in:
@@ -18,7 +18,6 @@ export function hasLaunched(): boolean {
|
||||
export { Observable };
|
||||
|
||||
import { UnhandledErrorEventData, iOSApplication, AndroidApplication, CssChangedEventData } from ".";
|
||||
import { NavigationEntry } from "../ui/frame";
|
||||
|
||||
export const launchEvent = "launch";
|
||||
export const suspendEvent = "suspend";
|
||||
@@ -30,10 +29,11 @@ export const orientationChangedEvent = "orientationChanged";
|
||||
|
||||
let cssFile: string = "app.css";
|
||||
|
||||
export let mainModule: string;
|
||||
export let mainEntry: NavigationEntry;
|
||||
let resources: any = {};
|
||||
|
||||
export let resources: any = {};
|
||||
export function getResources() {
|
||||
return resources;
|
||||
}
|
||||
|
||||
export function setResources(res: any) {
|
||||
resources = res;
|
||||
|
||||
@@ -107,21 +107,23 @@ const androidApp = new AndroidApplication();
|
||||
exports.android = androidApp;
|
||||
setApplication(androidApp);
|
||||
|
||||
let mainEntry: NavigationEntry;
|
||||
let started = false;
|
||||
export function start(entry?: NavigationEntry) {
|
||||
export function start(entry?: NavigationEntry | string) {
|
||||
if (started) {
|
||||
throw new Error("Application is already started.");
|
||||
}
|
||||
|
||||
started = true;
|
||||
mainEntry = typeof entry === "string" ? { moduleName: entry } : entry;
|
||||
if (!androidApp.nativeApp) {
|
||||
const nativeApp = getNativeApplication();
|
||||
androidApp.init(nativeApp);
|
||||
}
|
||||
}
|
||||
|
||||
started = true;
|
||||
if (entry) {
|
||||
exports.mainEntry = entry;
|
||||
}
|
||||
export function getMainEntry() {
|
||||
return mainEntry;
|
||||
}
|
||||
|
||||
export function getNativeApplication(): android.app.Application {
|
||||
|
||||
18
tns-core-modules/application/application.d.ts
vendored
18
tns-core-modules/application/application.d.ts
vendored
@@ -103,23 +103,19 @@ export interface CssChangedEventData extends EventData {
|
||||
}
|
||||
|
||||
/**
|
||||
* The main page path (without the file extension) for the application starting from the application root.
|
||||
* For example if you have page called "main.js" in a folder called "subFolder" and your root folder is "app" you can specify mainModule like this:
|
||||
* var application = require("application");
|
||||
* application.mainModule = "app/subFolder/main";
|
||||
* application.start();
|
||||
* Get main entry specified when calling start function.
|
||||
*/
|
||||
export var mainModule: string;
|
||||
export function getMainEntry(): NavigationEntry;
|
||||
|
||||
/**
|
||||
* The main navigation entry to be used when loading the main Page.
|
||||
* Get application level static resources.
|
||||
*/
|
||||
export var mainEntry: NavigationEntry;
|
||||
export function getResources(): any;
|
||||
|
||||
/**
|
||||
* An application level static resources.
|
||||
* Set application level static resources.
|
||||
*/
|
||||
export var resources: any;
|
||||
export function setResources(res: any): void;
|
||||
|
||||
/**
|
||||
* Sets application level static resources.
|
||||
@@ -156,7 +152,7 @@ export function off(eventNames: string, callback?: any, thisArg?: any);
|
||||
/**
|
||||
* Call this method to start the application. Important: All code after this method call will not be executed!
|
||||
*/
|
||||
export function start(entry?: NavigationEntry);
|
||||
export function start(entry?: NavigationEntry | string);
|
||||
|
||||
/**
|
||||
* A basic method signature to hook an event listener (shortcut alias to the addEventListener method).
|
||||
|
||||
@@ -188,13 +188,14 @@ const iosApp = new IOSApplication();
|
||||
exports.ios = iosApp;
|
||||
setApplication(iosApp);
|
||||
|
||||
let mainEntry: NavigationEntry;
|
||||
function createRootView(v?: View) {
|
||||
let rootView = v;
|
||||
let frame: Frame;
|
||||
let main: string | NavigationEntry;
|
||||
if (!rootView) {
|
||||
// try to navigate to the mainEntry/Module (if specified)
|
||||
main = exports.mainEntry || exports.mainModule;
|
||||
// try to navigate to the mainEntry (if specified)
|
||||
main = mainEntry;
|
||||
if (main) {
|
||||
frame = new Frame();
|
||||
frame.navigate(main);
|
||||
@@ -209,12 +210,13 @@ function createRootView(v?: View) {
|
||||
return rootView;
|
||||
}
|
||||
|
||||
export function getMainEntry() {
|
||||
return mainEntry;
|
||||
}
|
||||
|
||||
let started: boolean = false;
|
||||
exports.start = function (entry?: NavigationEntry) {
|
||||
if (entry) {
|
||||
exports.mainEntry = entry;
|
||||
}
|
||||
|
||||
export function start(entry?: string | NavigationEntry) {
|
||||
mainEntry = typeof entry === "string" ? { moduleName: entry } : entry;
|
||||
started = true;
|
||||
|
||||
if (!iosApp.nativeApp) {
|
||||
@@ -246,4 +248,4 @@ global.__onLiveSync = function () {
|
||||
}
|
||||
|
||||
livesync();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user