-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathmain.ts
More file actions
93 lines (79 loc) · 3.64 KB
/
main.ts
File metadata and controls
93 lines (79 loc) · 3.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
console.log('####### ------ APP MODULES START ');
import { Trace, Application, UnhandledErrorEventData, LaunchEventData, ApplicationEventData, DiscardedErrorEventData } from '@nativescript/core';
Trace.addCategories(Trace.categories.NativeLifecycle);
Trace.addCategories(Trace.categories.Navigation);
Trace.addCategories(Trace.categories.Transition);
Trace.enable();
var countResume = 0;
var countSuspend = 0;
Application.on('displayed', (args) => {
const uptime = global.android ? (<any>org).nativescript.Process.getUpTime : global.__tns_uptime;
console.log('Startup time: ' + uptime() + 'ms.');
});
Application.on('uncaughtError', (args) => {
const error = args.error;
console.warn(error.message);
if (error.nativeException) {
console.warn('native error: ' + error.nativeException);
}
});
Application.on(Application.launchEvent, function (args: LaunchEventData) {
if (args.android) {
// For Android applications, args.android is an android.content.Intent class.
console.log('### Launched application with: ' + args.android + '.');
} else if (args.ios !== undefined) {
// For iOS applications, args.ios is NSDictionary (launchOptions).
console.log('### Launched application with: ' + args.ios);
}
});
Application.on(Application.suspendEvent, function (args: ApplicationEventData) {
if (args.android) {
// For Android applications, args.android is an android activity class.
console.log('#' + ++countSuspend + '# SuspendEvent Activity: ' + args.android);
} else if (args.ios) {
// For iOS applications, args.ios is UIApplication.
console.log('#' + ++countSuspend + '# SuspendEvent UIApplication: ' + args.ios);
}
});
Application.on(Application.resumeEvent, function (args: ApplicationEventData) {
if (args.android) {
// For Android applications, args.android is an android activity class.
console.log('#' + ++countResume + '# ResumeEvent Activity: ' + args.android);
} else if (args.ios) {
// For iOS applications, args.ios is UIApplication.
console.log('#' + ++countResume + '# ResumeEvent UIApplication: ' + args.ios);
}
});
Application.on(Application.exitEvent, function (args: ApplicationEventData) {
if (args.android) {
// For Android applications, args.android is an android activity class.
console.log('### ExitEvent Activity: ' + args.android);
} else if (args.ios) {
// For iOS applications, args.ios is UIApplication.
console.log('### ExitEvent UIApplication: ' + args.ios);
}
});
Application.on(Application.lowMemoryEvent, function (args: ApplicationEventData) {
if (args.android) {
// For Android applications, args.android is an android activity class.
console.log('### LowMemoryEvent Activity: ' + args.android);
} else if (args.ios) {
// For iOS applications, args.ios is UIApplication.
console.log('### LowMemoryEvent UIApplication: ' + args.ios);
}
});
Application.on(Application.uncaughtErrorEvent, function (args: UnhandledErrorEventData) {
console.log('### NativeScriptError: ' + args.error);
console.log('### nativeException: ' + (<any>args.error).nativeException);
console.log('### stackTrace: ' + (<any>args.error).stackTrace);
console.log('### stack: ' + args.error.stack);
});
Application.on(Application.discardedErrorEvent, function (args: DiscardedErrorEventData) {
console.log('### [Discarded] NativeScriptError: ' + args.error);
console.log('### [Discarded] nativeException: ' + (<any>args.error).nativeException);
console.log('### [Discarded] stackTrace: ' + (<any>args.error).stackTrace);
console.log('### [Discarded] stack: ' + args.error.stack);
});
Application.run({ moduleName: 'app-root' });
// TODO: investigate tab-view -> tabviewcss test crash
// TODO: investigate css -> layouts border overlap failure