Skip to content

Commit e6250e7

Browse files
Hristo HristovHristo Hristov
authored andcommitted
Disable recycling of native views
createNativeView will set iOS nativeView if it is null/undefined
1 parent 84e726e commit e6250e7

File tree

59 files changed

+112
-97
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+112
-97
lines changed

tests/app/testRunner.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,10 @@ function printRunTestStats() {
346346
messageContainer.focus();
347347
page.style.fontSize = 11;
348348
if (page.android) {
349-
setTimeout(() => messageContainer.dismissSoftInput());
349+
setTimeout(() => {
350+
messageContainer.dismissSoftInput();
351+
(<android.view.View>messageContainer.nativeView).scrollTo(0, 0);
352+
});
350353
}
351354
}
352355

tests/app/ui/core/bindable/bindable-tests.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ export function test_BindingToDictionaryAtAppLevel() {
604604
pageViewModel.set("testProperty", testPropertyName);
605605
const dict = {};
606606
dict[testPropertyName] = expectedValue;
607-
appModule.resources["dict"] = dict;
607+
appModule.getResources()["dict"] = dict;
608608

609609
const testFunc = function (views: Array<View>) {
610610
const testLabel = <Label>(views[0]);
@@ -629,7 +629,7 @@ export function test_BindingConverterCalledEvenWithNullValue() {
629629
const testPropertyValue = null;
630630
const expectedValue = "collapsed";
631631
pageViewModel.set("testProperty", testPropertyValue);
632-
appModule.resources["converter"] = function (value) {
632+
appModule.getResources()["converter"] = function (value) {
633633
if (value) {
634634
return "visible";
635635
} else {

tests/app/ui/list-view/list-view-tests.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ export class ListViewTest extends testModule.UITest<listViewModule.ListView> {
421421
return result;
422422
};
423423

424-
app.resources["dateConverter"] = dateConverter;
424+
app.getResources()["dateConverter"] = dateConverter;
425425

426426
var data = new observableArray.ObservableArray();
427427
data.push({ date: new Date(2020, 2, 7) });
@@ -542,7 +542,7 @@ export class ListViewTest extends testModule.UITest<listViewModule.ListView> {
542542
return value;
543543
}
544544

545-
app.resources["testConverter"] = testConverter;
545+
app.getResources()["testConverter"] = testConverter;
546546

547547
var listViewModel = new observable.Observable();
548548
listViewModel.set("items", [1, 2, 3]);
@@ -570,7 +570,7 @@ export class ListViewTest extends testModule.UITest<listViewModule.ListView> {
570570
return value;
571571
}
572572

573-
app.resources["testConverter"] = testConverter;
573+
app.getResources()["testConverter"] = testConverter;
574574

575575
var listViewModel = new observable.Observable();
576576
listViewModel.set("items", [1, 2, 3]);

tests/app/ui/repeater/repeater-tests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ export function test_usingAppLevelConvertersInRepeaterItems() {
264264
return result;
265265
};
266266

267-
app.resources["dateConverter"] = dateConverter;
267+
app.getResources()["dateConverter"] = dateConverter;
268268

269269
var data = new observableArray.ObservableArray();
270270

tns-core-modules/application/application-common.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export function hasLaunched(): boolean {
1818
export { Observable };
1919

2020
import { UnhandledErrorEventData, iOSApplication, AndroidApplication, CssChangedEventData } from ".";
21-
import { NavigationEntry } from "../ui/frame";
2221

2322
export const launchEvent = "launch";
2423
export const suspendEvent = "suspend";
@@ -30,10 +29,11 @@ export const orientationChangedEvent = "orientationChanged";
3029

3130
let cssFile: string = "app.css";
3231

33-
export let mainModule: string;
34-
export let mainEntry: NavigationEntry;
32+
let resources: any = {};
3533

36-
export let resources: any = {};
34+
export function getResources() {
35+
return resources;
36+
}
3737

3838
export function setResources(res: any) {
3939
resources = res;

tns-core-modules/application/application.android.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,21 +107,23 @@ const androidApp = new AndroidApplication();
107107
exports.android = androidApp;
108108
setApplication(androidApp);
109109

110+
let mainEntry: NavigationEntry;
110111
let started = false;
111-
export function start(entry?: NavigationEntry) {
112+
export function start(entry?: NavigationEntry | string) {
112113
if (started) {
113114
throw new Error("Application is already started.");
114115
}
115116

117+
started = true;
118+
mainEntry = typeof entry === "string" ? { moduleName: entry } : entry;
116119
if (!androidApp.nativeApp) {
117120
const nativeApp = getNativeApplication();
118121
androidApp.init(nativeApp);
119122
}
123+
}
120124

121-
started = true;
122-
if (entry) {
123-
exports.mainEntry = entry;
124-
}
125+
export function getMainEntry() {
126+
return mainEntry;
125127
}
126128

127129
export function getNativeApplication(): android.app.Application {

tns-core-modules/application/application.d.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,23 +103,19 @@ export interface CssChangedEventData extends EventData {
103103
}
104104

105105
/**
106-
* The main page path (without the file extension) for the application starting from the application root.
107-
* 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:
108-
* var application = require("application");
109-
* application.mainModule = "app/subFolder/main";
110-
* application.start();
106+
* Get main entry specified when calling start function.
111107
*/
112-
export var mainModule: string;
108+
export function getMainEntry(): NavigationEntry;
113109

114110
/**
115-
* The main navigation entry to be used when loading the main Page.
111+
* Get application level static resources.
116112
*/
117-
export var mainEntry: NavigationEntry;
113+
export function getResources(): any;
118114

119115
/**
120-
* An application level static resources.
116+
* Set application level static resources.
121117
*/
122-
export var resources: any;
118+
export function setResources(res: any): void;
123119

124120
/**
125121
* Sets application level static resources.
@@ -156,7 +152,7 @@ export function off(eventNames: string, callback?: any, thisArg?: any);
156152
/**
157153
* Call this method to start the application. Important: All code after this method call will not be executed!
158154
*/
159-
export function start(entry?: NavigationEntry);
155+
export function start(entry?: NavigationEntry | string);
160156

161157
/**
162158
* A basic method signature to hook an event listener (shortcut alias to the addEventListener method).

tns-core-modules/application/application.ios.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,14 @@ const iosApp = new IOSApplication();
188188
exports.ios = iosApp;
189189
setApplication(iosApp);
190190

191+
let mainEntry: NavigationEntry;
191192
function createRootView(v?: View) {
192193
let rootView = v;
193194
let frame: Frame;
194195
let main: string | NavigationEntry;
195196
if (!rootView) {
196-
// try to navigate to the mainEntry/Module (if specified)
197-
main = exports.mainEntry || exports.mainModule;
197+
// try to navigate to the mainEntry (if specified)
198+
main = mainEntry;
198199
if (main) {
199200
frame = new Frame();
200201
frame.navigate(main);
@@ -209,12 +210,13 @@ function createRootView(v?: View) {
209210
return rootView;
210211
}
211212

213+
export function getMainEntry() {
214+
return mainEntry;
215+
}
216+
212217
let started: boolean = false;
213-
exports.start = function (entry?: NavigationEntry) {
214-
if (entry) {
215-
exports.mainEntry = entry;
216-
}
217-
218+
export function start(entry?: string | NavigationEntry) {
219+
mainEntry = typeof entry === "string" ? { moduleName: entry } : entry;
218220
started = true;
219221

220222
if (!iosApp.nativeApp) {
@@ -246,4 +248,4 @@ global.__onLiveSync = function () {
246248
}
247249

248250
livesync();
249-
}
251+
}

tns-core-modules/ui/action-bar/action-bar.android.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,13 @@ export class ActionBar extends ActionBarBase {
137137
}
138138

139139
public initNativeView(): void {
140+
super.initNativeView();
140141
(<any>this.nativeView).menuItemClickListener.owner = this;
141142
}
142143

143144
public disposeNativeView() {
144145
(<any>this.nativeView).menuItemClickListener.owner = null;
146+
super.disposeNativeView();
145147
}
146148

147149
public onLoaded() {
@@ -365,7 +367,7 @@ export class ActionBar extends ActionBarBase {
365367
}
366368
}
367369

368-
ActionBar.prototype.recycleNativeView = true;
370+
// ActionBar.prototype.recycleNativeView = true;
369371

370372
let defaultTitleTextColor: number;
371373

tns-core-modules/ui/activity-indicator/activity-indicator-common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export class ActivityIndicatorBase extends View implements ActivityIndicatorDefi
77
public busy: boolean;
88
}
99

10-
ActivityIndicatorBase.prototype.recycleNativeView = true;
10+
// ActivityIndicatorBase.prototype.recycleNativeView = true;
1111

1212
export const busyProperty = new Property<ActivityIndicatorBase, boolean>({ name: "busy", defaultValue: false, valueConverter: booleanConverter });
1313
busyProperty.register(ActivityIndicatorBase);

0 commit comments

Comments
 (0)