diff --git a/visearch-android/build.gradle b/visearch-android/build.gradle index f3ff7ea..f35255b 100644 --- a/visearch-android/build.gradle +++ b/visearch-android/build.gradle @@ -4,8 +4,8 @@ plugins { def versionMajor = 2 def versionMinor = 1 -def versionPatch = 1 -version = '2.1.1' +def versionPatch = 2 +version = '2.1.2' android { compileSdkVersion 29 diff --git a/visearch-android/src/main/java/com/visenze/visearch/android/network/ProductSearchService.java b/visearch-android/src/main/java/com/visenze/visearch/android/network/ProductSearchService.java index 8e66158..bde7524 100644 --- a/visearch-android/src/main/java/com/visenze/visearch/android/network/ProductSearchService.java +++ b/visearch-android/src/main/java/com/visenze/visearch/android/network/ProductSearchService.java @@ -1,5 +1,6 @@ package com.visenze.visearch.android.network; +import com.google.gson.Gson; import com.visenze.visearch.android.BaseProductSearchParams; import com.visenze.visearch.android.ProductSearchByImageParams; import com.visenze.visearch.android.ProductSearch; @@ -79,11 +80,18 @@ private void handleCallback(Call call, final ProductSearch.Resu call.enqueue(new Callback() { @Override public void onResponse(Call call, Response response) { - if(response.isSuccessful() && response.body() !=null) { ProductResponse data = response.body(); handleResponse(data, resultListener); } else { + if (response.errorBody() != null) { + Gson gson = new Gson(); + ProductResponse resp = gson.fromJson(response.errorBody().charStream(), ProductResponse.class); + if (resp != null && resp.getError()!= null) { + resultListener.onSearchResult(null, resp.getError()); + return; + } + } ErrorData error = new ErrorData(); error.setMessage("api failed"); error.setCode(-1);