diff --git a/android-example/app/build.gradle b/android-example/app/build.gradle index 5493a87..28b5fe2 100755 --- a/android-example/app/build.gradle +++ b/android-example/app/build.gradle @@ -8,7 +8,7 @@ android { minSdkVersion 19 targetSdkVersion 27 versionCode 4 - versionName '0.1.5' + versionName '0.2.0' } buildTypes { release { diff --git a/android-example/app/release/app-release.apk b/android-example/app/release/app-release.apk index eac00ea..fd8d479 100644 Binary files a/android-example/app/release/app-release.apk and b/android-example/app/release/app-release.apk differ diff --git a/android-example/app/release/output.json b/android-example/app/release/output.json index d15b5a7..d7050db 100644 --- a/android-example/app/release/output.json +++ b/android-example/app/release/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":4,"versionName":"0.1.5","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}] \ No newline at end of file +[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":4,"versionName":"0.2.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}] \ No newline at end of file diff --git a/android-example/web-api/src/main/java/net/irext/webapi/WebAPIs.java b/android-example/web-api/src/main/java/net/irext/webapi/WebAPIs.java index 735ed25..11db8e0 100755 --- a/android-example/web-api/src/main/java/net/irext/webapi/WebAPIs.java +++ b/android-example/web-api/src/main/java/net/irext/webapi/WebAPIs.java @@ -39,6 +39,11 @@ public class WebAPIs { private static final String DEFAULT_APP = "/irext-server"; private static String URL_PREFIX = DEFAULT_ADDRESS + DEFAULT_APP; + // download bin from OSS + private static final String IR_BIN_FILE_PREFIX = "irda_"; + private static final String IR_BIN_FILE_SUFFIX = ".bin"; + private static final String IR_BIN_DOWNLOAD_PREFIX = "http://irext-debug.oss-cn-hangzhou.aliyuncs.com/"; + private static final String SERVICE_SIGN_IN = "/app/app_login"; private static final String SERVICE_LIST_CATEGORIES = "/indexing/list_categories"; private static final String SERVICE_LIST_BRANDS = "/indexing/list_brands"; @@ -73,6 +78,16 @@ public class WebAPIs { return mInstance; } + private InputStream getFileByteStreamByURL(String url) throws IOException { + Request request = new Request.Builder() + .url(url) + .get() + .build(); + + Response response = new OkHttpClient().newCall(request).execute(); + return response.body().byteStream(); + } + private String postToServer(String url, String json) throws IOException { MediaType JSON = MediaType.parse("application/json; charset=utf-8"); @@ -308,7 +323,8 @@ public class WebAPIs { @SuppressWarnings("unused") public void downloadBin(String remoteMap, int indexId, DownloadBinCallback downloadBinCallback) { - String downloadURL = URL_PREFIX + SERVICE_DOWNLOAD_BIN; + String fileName = IR_BIN_FILE_PREFIX + remoteMap + IR_BIN_FILE_SUFFIX; + String downloadURL = IR_BIN_DOWNLOAD_PREFIX + fileName; DownloadBinaryRequest downloadBinaryRequest = new DownloadBinaryRequest(); downloadBinaryRequest.setId(id); downloadBinaryRequest.setToken(token); @@ -318,7 +334,7 @@ public class WebAPIs { if (null != bodyJson) { try { - InputStream binStream = postToServerForOctets(downloadURL, bodyJson); + InputStream binStream = getFileByteStreamByURL(downloadURL); if (null != binStream) { downloadBinCallback.onDownloadBinSuccess(binStream);