Skip to content

Commit

Permalink
工具Jackson改为google.gson,版本更新为v1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
pedant committed Nov 6, 2014
1 parent d8a7012 commit 427206b
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 99 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ Safe Java-JS WebView Bridge
使用Safe Java-JS WebView Bridge最简单的办法就是像下面这样添加项目依赖。

**Maven**

<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>cn.pedant.safewebviewbridge</groupId>
<artifactId>library</artifactId>
<version>1.1</version>
<version>1.2</version>
<type>aar</type>
</dependency>

Expand All @@ -21,7 +25,7 @@ Safe Java-JS WebView Bridge
}

dependencies {
compile 'cn.pedant.safewebviewbridge:library:1.1'
compile 'cn.pedant.safewebviewbridge:library:1.2'
}

## Sample
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ allprojects {
repositories {
mavenCentral()
}
}
}
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
VERSION_NAME=1.1
VERSION_CODE=2
VERSION_NAME=1.2
VERSION_CODE=3
GROUP=cn.pedant.safewebviewbridge

POM_DESCRIPTION=Provide a safe and reliable scheme for Java and JavaScript in Android WebView.
Expand Down
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ android {
}

dependencies {
compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.11'
compile 'com.google.code.gson:gson:2.3'
}

apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle'
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@
import android.text.TextUtils;
import android.webkit.WebView;
import android.util.Log;

import com.google.gson.Gson;

import org.json.JSONArray;
import org.json.JSONObject;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.HashMap;

import cn.pedant.SafeWebViewBridge.util.JacksonKit;

public class JsCallJava {
private final static String TAG = "JsCallJava";
private final static String RETURN_RESULT_FORMAT = "{\"code\": %d, \"result\": %s}";
private HashMap<String, Method> mMethodsMap;
private String mPreloadInterfaceJS;
private Gson mGson;

public JsCallJava (String injectedName, Class injectedCls) {
try {
Expand Down Expand Up @@ -166,12 +168,10 @@ private String getReturn (String reqJson, int stateCode, Object result) {
&& !(result instanceof Float)
&& !(result instanceof Double)
&& !(result instanceof JSONObject)) { // 非数字或者非字符串的构造对象类型都要序列化后再拼接
try {
insertRes = JacksonKit.encode(result, true);
} catch (Exception e) {
stateCode = 500;
insertRes = "json encode result error:" + e.getMessage();
if (mGson == null) {
mGson = new Gson();
}
insertRes = mGson.toJson(result);
} else { //数字直接转化
insertRes = String.valueOf(result);
}
Expand Down

This file was deleted.

8 changes: 1 addition & 7 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,9 @@ android {
lintOptions {
abortOnError false
}

packagingOptions {
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
}

dependencies {
//compile 'cn.pedant.safewebviewbridge:library:1.1'
//compile 'cn.pedant.safewebviewbridge:library:1.2'
compile project(':library')
}

0 comments on commit 427206b

Please sign in to comment.