Skip to content

Commit 32fb766

Browse files
committed
sync test-app sources with project template sources
1 parent 57d088c commit 32fb766

File tree

4 files changed

+27
-46
lines changed

4 files changed

+27
-46
lines changed

build-artifacts/project-template-gradle/src/main/java/com/tns/AndroidJsDebugger.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,11 +437,12 @@ public void start()
437437
Handler handler = new Handler(handlerThread.getLooper());
438438

439439
this.registerEnableDisableDebuggerReceiver(handler);
440-
440+
441+
AndroidJsDebugger.this.debugContext.enableAgent();
442+
441443
boolean shouldDebugBreak = getDebugBreakFlagAndClearIt();
442444
if (shouldDebugBreak)
443445
{
444-
AndroidJsDebugger.this.debugContext.enableAgent();
445446
AndroidJsDebugger.this.debugContext.debugBreak();
446447
}
447448
}

test-app/app/src/main/java/com/tns/AndroidJsDebugger.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,14 +437,12 @@ public void start()
437437
Handler handler = new Handler(handlerThread.getLooper());
438438

439439
this.registerEnableDisableDebuggerReceiver(handler);
440-
441-
boolean shouldDebugBreak = getDebugBreakFlagAndClearIt();
442440

443441
AndroidJsDebugger.this.debugContext.enableAgent();
444442

443+
boolean shouldDebugBreak = getDebugBreakFlagAndClearIt();
445444
if (shouldDebugBreak)
446445
{
447-
448446
AndroidJsDebugger.this.debugContext.debugBreak();
449447
}
450448
}

test-app/app/src/main/java/com/tns/NativeScriptApplication.java

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,52 +2,17 @@
22

33
import android.app.Application;
44

5-
@JavaScriptImplementation(javaScriptFile = "./MyApp.js")
6-
public class NativeScriptApplication extends android.app.Application implements com.tns.NativeScriptHashCodeProvider {
5+
public class NativeScriptApplication extends android.app.Application {
76

87
private static NativeScriptApplication thiz;
98

10-
public NativeScriptApplication()
11-
{
12-
//android.os.Debug.waitForDebugger();
9+
public NativeScriptApplication() {
1310
thiz = this;
1411
}
1512

1613
public void onCreate() {
14+
super.onCreate();
1715
new RuntimeHelper(this).initRuntime();
18-
if (Runtime.isInitialized()) {
19-
java.lang.Object[] params = null;
20-
com.tns.Runtime.callJSMethod(this, "onCreate", void.class, params);
21-
} else {
22-
super.onCreate();
23-
}
24-
}
25-
26-
public void onLowMemory() {
27-
if (Runtime.isInitialized()) {
28-
java.lang.Object[] params = null;
29-
com.tns.Runtime.callJSMethod(this, "onLowMemory", void.class, params);
30-
} else {
31-
super.onLowMemory();
32-
}
33-
}
34-
35-
public void onTrimMemory(int level) {
36-
if (Runtime.isInitialized()) {
37-
java.lang.Object[] params = new Object[1];
38-
params[0] = level;
39-
com.tns.Runtime.callJSMethod(this, "onTrimMemory", void.class, params);
40-
} else {
41-
super.onTrimMemory(level);
42-
}
43-
}
44-
45-
public boolean equals__super(java.lang.Object other) {
46-
return super.equals(other);
47-
}
48-
49-
public int hashCode__super() {
50-
return super.hashCode();
5116
}
5217

5318
public static Application getInstance() {

test-app/app/src/main/java/com/tns/RuntimeHelper.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,13 @@ public boolean hasErrorIntent() {
3737

3838
return hasErrorIntent;
3939
}
40-
41-
public void initRuntime() {
40+
41+
public void initRuntime()
42+
{
43+
if (Runtime.isInitialized()) {
44+
return;
45+
}
46+
4247
System.loadLibrary("NativeScript");
4348

4449
Logger logger = new LogcatLogger(app);
@@ -128,7 +133,19 @@ public void initRuntime() {
128133

129134
runtime.init();
130135
runtime.runScript(new File(appDir, "internal/ts_helpers.js"));
131-
Runtime.initInstance(this.app);
136+
137+
File javaClassesModule = new File(appDir, "app/tns-java-classes.js");
138+
if (javaClassesModule.exists()) {
139+
runtime.runModule(javaClassesModule);
140+
}
141+
142+
try {
143+
// put this call in a try/catch block because with the latest changes in the modules it is not granted that NativeScriptApplication is extended through JavaScript.
144+
Runtime.initInstance(this.app);
145+
}
146+
catch (Exception e) {
147+
148+
}
132149
runtime.run();
133150
}
134151
}

0 commit comments

Comments
 (0)