Skip to content

Commit 6d07542

Browse files
author
lemon
committed
bugfix:call javascript in java with object value return
1 parent f48114c commit 6d07542

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package tech.easily.webviewperformancedemo
2+
3+
data class PerformanceTiming(val connectEnd: Long, val connectStart: Long, val domComplete: Long, val domContentLoadedEventEnd: Long,
4+
val domContentLoadedEventStart: Long, val domInteractive: Long, val domLoading: Long, val domainLookupEnd: Long,
5+
val domainLookupStart: Long, val fetchStart: Long, val loadEventEnd: Long, val loadEventStart: Long, val navigationStart: Long,
6+
val redirectEnd: Long, val redirectStart: Long, val requestStart: Long, val responseEnd: Long, val responseStart: Long,
7+
val secureConnectionStart: Long, val unloadEventEnd: Long, val unloadEventStart: Long)
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="wrap_content"
4+
android:layout_height="wrap_content"
5+
android:background="#50000000"
6+
android:orientation="vertical">
7+
8+
<LinearLayout
9+
android:layout_width="wrap_content"
10+
android:layout_height="wrap_content"
11+
android:orientation="horizontal"
12+
android:padding="10dp">
13+
14+
<TextView
15+
android:layout_width="wrap_content"
16+
android:layout_height="wrap_content"
17+
android:text="网络耗时:" />
18+
19+
<TextView
20+
android:id="@+id/tv_net"
21+
android:layout_width="wrap_content"
22+
android:layout_height="wrap_content" />
23+
</LinearLayout>
24+
25+
<LinearLayout
26+
android:layout_width="wrap_content"
27+
android:layout_height="wrap_content"
28+
android:orientation="horizontal"
29+
android:padding="10dp">
30+
31+
<TextView
32+
android:layout_width="wrap_content"
33+
android:layout_height="wrap_content"
34+
android:text="渲染耗时:" />
35+
36+
<TextView
37+
android:id="@+id/tv_render"
38+
android:layout_width="wrap_content"
39+
android:layout_height="wrap_content" />
40+
</LinearLayout>
41+
42+
<LinearLayout
43+
android:layout_width="wrap_content"
44+
android:layout_height="wrap_content"
45+
android:orientation="horizontal"
46+
android:padding="10dp">
47+
48+
<TextView
49+
android:layout_width="wrap_content"
50+
android:layout_height="wrap_content"
51+
android:text="总耗时长:" />
52+
53+
<TextView
54+
android:id="@+id/tv_total"
55+
android:layout_width="wrap_content"
56+
android:layout_height="wrap_content" />
57+
</LinearLayout>
58+
59+
</LinearLayout>

easybridge/src/main/assets/easybridge.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@
5858
callbackFunc = function (result) {
5959
if (window._easybridge) {
6060
//the method onExecuteJSCallback is a Java Code,using to dispatch result after execute the JavaScript function from Java
61+
if (typeof result == 'object') {
62+
result = JSON.stringify(result);
63+
}
6164
_easybridge.onExecuteJSCallback(callbackId, result);
6265
} else {
6366
console.error(bridgeName + ':' + "the mapping object '_easybridge' had not been added any more");

0 commit comments

Comments
 (0)