Fix android orientation exception. (#2278)

Fix android activity destroy/resume.
Fix tslint - skipped all from node_modules & platforms
This commit is contained in:
Hristo Hristov
2016-06-09 14:02:15 +03:00
parent 55398d6320
commit 192171232e
3 changed files with 24 additions and 21 deletions

View File

@ -166,7 +166,8 @@ module.exports = function(grunt) {
"!tns-core-modules/ios.d.ts",
"!tns-core-modules/android17.d.ts",
"!tns-core-modules/libjs.d.ts",
"!tests/node_modules/"
"!tests/node_modules/**",
"!tests/platforms/**"
]);
localCfg.srcTsdFiles = [
"**/*.d.ts",

View File

@ -3,6 +3,8 @@ import definition = require("application");
import frame = require("ui/frame");
import observable = require("data/observable");
import * as typesModule from "utils/types";
import * as enumsModule from "ui/enums";
let enums: typeof enumsModule;
global.moduleMerge(appModule, exports);
var typedExports: typeof definition = exports;
@ -121,28 +123,30 @@ function initLifecycleCallbacks() {
let currentOrientation: number;
function initComponentCallbacks() {
let componentCallbacks = new android.content.ComponentCallbacks2({
onLowMemory: function() {
onLowMemory: function () {
gc();
java.lang.System.gc();
typedExports.notify(<definition.ApplicationEventData>{ eventName: typedExports.lowMemoryEvent, object: this, android: this });
},
onTrimMemory: function(level: number) {
onTrimMemory: function (level: number) {
// TODO: This is skipped for now, test carefully for OutOfMemory exceptions
},
onConfigurationChanged: function(newConfig: android.content.res.Configuration) {
onConfigurationChanged: function (newConfig: android.content.res.Configuration) {
let newOrientation = newConfig.orientation;
if(newOrientation === currentOrientation) {
if (newOrientation === currentOrientation) {
return;
}
currentOrientation = newOrientation;
if (!enums) {
enums = require("ui/enums");
}
let enums = require("ui/enums");
currentOrientation = newOrientation;
let newValue;
switch (orientation) {
switch (newOrientation) {
case android.content.res.Configuration.ORIENTATION_LANDSCAPE:
newValue = enums.DeviceOrientation.landscape;
break;
@ -204,7 +208,7 @@ export class AndroidApplication extends observable.Observable implements definit
public onActivityResult: (requestCode: number, resultCode: number, data: android.content.Intent) => void;
public init(nativeApp: any) {
if(this.nativeApp) {
if (this.nativeApp) {
throw new Error("application.android already initialized.")
}
@ -296,7 +300,7 @@ export function start(entry?: frame.NavigationEntry) {
throw new Error("Application is already started.");
}
if(!androidApp.nativeApp) {
if (!androidApp.nativeApp) {
// we are still not initialized, this is possible if no 'androidApp.init' call has been made
let utils = require("utils/utils");
let nativeApp = utils.ad.getApplication();

View File

@ -717,8 +717,6 @@ class FragmentClass extends android.app.Fragment {
trace.write(`${this}.onDestroy()`, trace.categories.NativeLifecycle);
}
super.onDestroy();
this.entry.fragmentTag = undefined;
}
public toString(): string {