Disable recycling of native views

createNativeView will set iOS nativeView if it is null/undefined
This commit is contained in:
Hristo Hristov
2017-03-28 18:08:39 +03:00
parent 84e726e6b9
commit e6250e718a
59 changed files with 112 additions and 97 deletions

View File

@@ -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;

View File

@@ -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 {

View File

@@ -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).

View File

@@ -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();
}
}