Skip to content

Commit a52c860

Browse files
committed
兼容 GsonFactory 10.8 代码用法
1 parent 1bd81e3 commit a52c860

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

app/src/main/java/com/hjq/easy/demo/AppApplication.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
import android.app.Application;
44
import androidx.annotation.NonNull;
5+
import androidx.annotation.Nullable;
56
import com.google.gson.reflect.TypeToken;
67
import com.google.gson.stream.JsonToken;
78
import com.hjq.easy.demo.http.model.HttpCacheStrategy;
89
import com.hjq.easy.demo.http.model.RequestHandler;
910
import com.hjq.easy.demo.http.server.ReleaseServer;
1011
import com.hjq.easy.demo.http.server.TestServer;
1112
import com.hjq.gson.factory.GsonFactory;
12-
import com.hjq.gson.factory.ParseExceptionCallback;
13+
import com.hjq.gson.factory.OnParseExceptionCallback;
1314
import com.hjq.http.EasyConfig;
1415
import com.hjq.http.config.IRequestInterceptor;
1516
import com.hjq.http.config.IRequestServer;
@@ -44,20 +45,20 @@ public void onCreate() {
4445
Bugly.init(this, builder);
4546

4647
// 设置 Json 解析容错监听
47-
GsonFactory.setParseExceptionCallback(new ParseExceptionCallback() {
48+
GsonFactory.setOnParseExceptionCallback(new OnParseExceptionCallback() {
4849

4950
@Override
50-
public void onParseObjectException(TypeToken<?> typeToken, String fieldName, JsonToken jsonToken) {
51+
public void onParseObjectException(@NonNull TypeToken<?> typeToken, @Nullable String fieldName, @Nullable JsonToken jsonToken) {
5152
handlerGsonParseException("Object parsing exception: " + typeToken + "#" + fieldName + ", backend return type: " + jsonToken);
5253
}
5354

5455
@Override
55-
public void onParseListItemException(TypeToken<?> typeToken, String fieldName, JsonToken listItemJsonToken) {
56+
public void onParseListItemException(@NonNull TypeToken<?> typeToken, @Nullable String fieldName, @Nullable JsonToken listItemJsonToken) {
5657
handlerGsonParseException("List parsing exception: " + typeToken + "#" + fieldName + ", backend return item type: " + listItemJsonToken);
5758
}
5859

5960
@Override
60-
public void onParseMapItemException(TypeToken<?> typeToken, String fieldName, String mapItemKey, JsonToken mapItemJsonToken) {
61+
public void onParseMapItemException(@NonNull TypeToken<?> typeToken, @Nullable String fieldName, @Nullable String mapItemKey, @Nullable JsonToken mapItemJsonToken) {
6162
handlerGsonParseException("Map parsing exception: " + typeToken + "#" + fieldName + ", mapItemKey = " + mapItemKey + ", backend return item type: " + mapItemJsonToken);
6263
}
6364

0 commit comments

Comments
 (0)