updated Android example to 0.2.0
This commit is contained in:
@@ -8,7 +8,7 @@ android {
|
|||||||
minSdkVersion 19
|
minSdkVersion 19
|
||||||
targetSdkVersion 27
|
targetSdkVersion 27
|
||||||
versionCode 4
|
versionCode 4
|
||||||
versionName '0.1.5'
|
versionName '0.2.0'
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
|
|||||||
Binary file not shown.
@@ -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":{}}]
|
[{"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":{}}]
|
||||||
@@ -39,6 +39,11 @@ public class WebAPIs {
|
|||||||
private static final String DEFAULT_APP = "/irext-server";
|
private static final String DEFAULT_APP = "/irext-server";
|
||||||
private static String URL_PREFIX = DEFAULT_ADDRESS + DEFAULT_APP;
|
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_SIGN_IN = "/app/app_login";
|
||||||
private static final String SERVICE_LIST_CATEGORIES = "/indexing/list_categories";
|
private static final String SERVICE_LIST_CATEGORIES = "/indexing/list_categories";
|
||||||
private static final String SERVICE_LIST_BRANDS = "/indexing/list_brands";
|
private static final String SERVICE_LIST_BRANDS = "/indexing/list_brands";
|
||||||
@@ -73,6 +78,16 @@ public class WebAPIs {
|
|||||||
return mInstance;
|
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 {
|
private String postToServer(String url, String json) throws IOException {
|
||||||
MediaType JSON
|
MediaType JSON
|
||||||
= MediaType.parse("application/json; charset=utf-8");
|
= MediaType.parse("application/json; charset=utf-8");
|
||||||
@@ -308,7 +323,8 @@ public class WebAPIs {
|
|||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public void downloadBin(String remoteMap, int indexId,
|
public void downloadBin(String remoteMap, int indexId,
|
||||||
DownloadBinCallback downloadBinCallback) {
|
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 downloadBinaryRequest = new DownloadBinaryRequest();
|
||||||
downloadBinaryRequest.setId(id);
|
downloadBinaryRequest.setId(id);
|
||||||
downloadBinaryRequest.setToken(token);
|
downloadBinaryRequest.setToken(token);
|
||||||
@@ -318,7 +334,7 @@ public class WebAPIs {
|
|||||||
|
|
||||||
if (null != bodyJson) {
|
if (null != bodyJson) {
|
||||||
try {
|
try {
|
||||||
InputStream binStream = postToServerForOctets(downloadURL, bodyJson);
|
InputStream binStream = getFileByteStreamByURL(downloadURL);
|
||||||
|
|
||||||
if (null != binStream) {
|
if (null != binStream) {
|
||||||
downloadBinCallback.onDownloadBinSuccess(binStream);
|
downloadBinCallback.onDownloadBinSuccess(binStream);
|
||||||
|
|||||||
Reference in New Issue
Block a user