updated index api to 0.2.5

This commit is contained in:
strawmanbobi
2020-04-15 20:50:40 +08:00
parent 0469ffd41f
commit 41075b12ee
16 changed files with 494 additions and 28 deletions

View File

@@ -6,7 +6,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.android.tools.build:gradle:3.6.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}

View File

@@ -1,6 +1,6 @@
#Sun Dec 29 09:58:52 CST 2019
#Wed Apr 15 19:56:17 CST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

View File

@@ -6,6 +6,7 @@ import android.content.pm.PackageManager;
import android.util.Log;
import com.google.gson.Gson;
import net.irext.webapi.bean.ACStatus;
import net.irext.webapi.model.*;
import net.irext.webapi.utils.Constants;
import net.irext.webapi.request.*;
@@ -35,7 +36,7 @@ public class WebAPIs {
private static WebAPIs mInstance = null;
private static final String DEFAULT_ADDRESS = "http://irext.net";
private static final String DEFAULT_ADDRESS = "http://localhost:8081";
private static final String DEFAULT_APP = "/irext-server";
private static String URL_PREFIX = DEFAULT_ADDRESS + DEFAULT_APP;
@@ -53,11 +54,12 @@ public class WebAPIs {
private static final String SERVICE_LIST_INDEXES = "/indexing/list_indexes";
private static final String SERVICE_DOWNLOAD_BIN = "/operation/download_bin";
private static final String SERVICE_ONLINE_DECODE = "/operation/decode";
private static final String SERVICE_GET_AC_PARAMETERS = "/operation/get_ac_parameters";
private int id;
private String token;
private OkHttpClient mHttpClient;
private final OkHttpClient mHttpClient;
private WebAPIs(String address, String appName) {
if (null != address && null != appName) {
@@ -187,7 +189,7 @@ public class WebAPIs {
@SuppressWarnings("unused")
public void listBrands(int categoryId, int from, int count,
ListBrandsCallback listBrandsCallback) {
ListBrandsCallback listBrandsCallback) {
String listBrandsURL = URL_PREFIX + SERVICE_LIST_BRANDS;
ListBrandsRequest listBrandsRequest = new ListBrandsRequest();
listBrandsRequest.setId(id);
@@ -261,7 +263,7 @@ public class WebAPIs {
@SuppressWarnings("unused")
public void listOperators(String cityCode,
ListOperatersCallback listOperatersCallback) {
ListOperatersCallback listOperatersCallback) {
String listOperatorsURL = URL_PREFIX + SERVICE_LIST_OPERATORS;
ListOperatorsRequest listOperatorsRequest = new ListOperatorsRequest();
listOperatorsRequest.setId(id);
@@ -288,10 +290,11 @@ public class WebAPIs {
@SuppressWarnings("unused")
public void listRemoteIndexes(int categoryId,
int brandId,
String cityCode,
String operatorId,
ListIndexesCallback onListIndexCallback) {
int brandId,
String cityCode,
String operatorId,
int withParaData,
ListIndexesCallback onListIndexCallback) {
String listIndexesURL = URL_PREFIX + SERVICE_LIST_INDEXES;
ListIndexesRequest listIndexesRequest = new ListIndexesRequest();
listIndexesRequest.setId(id);
@@ -300,6 +303,7 @@ public class WebAPIs {
listIndexesRequest.setBrandId(brandId);
listIndexesRequest.setCityCode(cityCode);
listIndexesRequest.setOperatorId(operatorId);
listIndexesRequest.setWithParaData(withParaData);
listIndexesRequest.setFrom(0);
listIndexesRequest.setCount(20);
String bodyJson = listIndexesRequest.toJson();
@@ -323,8 +327,7 @@ public class WebAPIs {
@SuppressWarnings("unused")
public void downloadBin(String remoteMap, int indexId,
DownloadBinCallback downloadBinCallback) {
String fileName = IR_BIN_FILE_PREFIX + remoteMap + IR_BIN_FILE_SUFFIX;
String downloadURL = IR_BIN_DOWNLOAD_PREFIX + fileName;
String downloadURL = URL_PREFIX + SERVICE_DOWNLOAD_BIN;
DownloadBinaryRequest downloadBinaryRequest = new DownloadBinaryRequest();
downloadBinaryRequest.setId(id);
downloadBinaryRequest.setToken(token);
@@ -334,7 +337,7 @@ public class WebAPIs {
if (null != bodyJson) {
try {
InputStream binStream = getFileByteStreamByURL(downloadURL);
InputStream binStream = postToServerForOctets(downloadURL, bodyJson);
if (null != binStream) {
downloadBinCallback.onDownloadBinSuccess(binStream);
@@ -349,13 +352,18 @@ public class WebAPIs {
}
@SuppressWarnings("unused")
@Deprecated
public int[] decodeIR(int indexId) {
public int[] decodeIR(int indexId, ACStatus acStatus, int keyCode, int changeWindDir,
Integer directDecode, Integer paraData) {
String decodeURL = URL_PREFIX + SERVICE_ONLINE_DECODE;
DecodeRequest decodeRequest = new DecodeRequest();
decodeRequest.setId(id);
decodeRequest.setToken(token);
decodeRequest.setIndexId(indexId);
decodeRequest.setAcStatus(acStatus);
decodeRequest.setKeyCode(keyCode);
decodeRequest.setChangeWindDir(changeWindDir);
decodeRequest.setDirectDecode(directDecode);
decodeRequest.setParaData(paraData);
String bodyJson = decodeRequest.toJson();
@@ -374,4 +382,30 @@ public class WebAPIs {
}
return null;
}
@SuppressWarnings("unused")
public ACParameters getACParameters(int indexId, int mode) {
String decodeURL = URL_PREFIX + SERVICE_GET_AC_PARAMETERS;
GetACParametersRequest getACParametersRequest = new GetACParametersRequest();
getACParametersRequest.setId(id);
getACParametersRequest.setToken(token);
getACParametersRequest.setIndexId(indexId);
getACParametersRequest.setMode(mode);
String bodyJson = getACParametersRequest.toJson();
if (null != bodyJson) {
try {
String response = postToServer(decodeURL, bodyJson);
ACParametersResponse acParametersResponse = new Gson().fromJson(response, ACParametersResponse.class);
if (acParametersResponse.getStatus().getCode() == Constants.ERROR_CODE_SUCCESS) {
return acParametersResponse.getEntity();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
}
}

View File

@@ -0,0 +1,83 @@
package net.irext.webapi.model;
/**
* Filename: ACParameters.java
* Revised: Date: 2019-02-14
* Revision: Revision: 1.0
* <p>
* Description: AC parameters entity
* <p>
* Revision log:
* 2018-12-29: created by strawmanbobi
*/
public class ACParameters {
private int tempMin;
private int tempMax;
private int [] supportedModes;
private int []supportedWindSpeed;
private int []supportedSwing;
private int []supportedWindDirections;
public ACParameters(int tempMin, int tempMax, int[] supportedModes,
int[] supportedWindSpeed,
int[] supportedSwing, int[] supportedWindDirections) {
this.tempMin = tempMin;
this.tempMax = tempMax;
this.supportedModes = supportedModes;
this.supportedWindSpeed = supportedWindSpeed;
this.supportedSwing = supportedSwing;
this.supportedWindDirections = supportedWindDirections;
}
public ACParameters() {
}
public int getTempMin() {
return tempMin;
}
public void setTempMin(int tempMin) {
this.tempMin = tempMin;
}
public int getTempMax() {
return tempMax;
}
public void setTempMax(int tempMax) {
this.tempMax = tempMax;
}
public int[] getSupportedModes() {
return supportedModes;
}
public void setSupportedModes(int[] supportedModes) {
this.supportedModes = supportedModes;
}
public int[] getSupportedWindSpeed() {
return supportedWindSpeed;
}
public void setSupportedWindSpeed(int[] supportedWindSpeed) {
this.supportedWindSpeed = supportedWindSpeed;
}
public int[] getSupportedSwing() {
return supportedSwing;
}
public void setSupportedSwing(int[] supportedSwing) {
this.supportedSwing = supportedSwing;
}
public int[] getSupportedWindDirections() {
return supportedWindDirections;
}
public void setSupportedWindDirections(int[] supportedWindDirections) {
this.supportedWindDirections = supportedWindDirections;
}
}

View File

@@ -18,12 +18,17 @@ public class DecodeRequest extends BaseRequest {
private ACStatus acStatus;
private int keyCode;
private int changeWindDir;
private Integer directDecode;
private Integer paraData;
public DecodeRequest(int indexId, ACStatus acStatus, int keyCode, int changeWindDir) {
public DecodeRequest(int indexId, ACStatus acStatus, int keyCode, int changeWindDir,
Integer directDecode, Integer paraData) {
this.indexId = indexId;
this.acStatus = acStatus;
this.keyCode = keyCode;
this.changeWindDir = changeWindDir;
this.directDecode = directDecode;
this.paraData = paraData;
}
public DecodeRequest() {
@@ -61,4 +66,20 @@ public class DecodeRequest extends BaseRequest {
public void setChangeWindDir(int changeWindDir) {
this.changeWindDir = changeWindDir;
}
public Integer getDirectDecode() {
return directDecode;
}
public void setDirectDecode(Integer directDecode) {
this.directDecode = directDecode;
}
public Integer getParaData() {
return paraData;
}
public void setParaData(Integer paraData) {
this.paraData = paraData;
}
}

View File

@@ -0,0 +1,41 @@
package net.irext.webapi.request;
/**
* Filename: GetACParametersRequest.java
* Revised: Date: 2017-05-16
* Revision: Revision: 1.0
* <p>
* Description: HTTP server online
* <p>
* Revision log:
* 2019-02-14: created by strawmanbobi
*/
public class GetACParametersRequest extends BaseRequest {
private int indexId;
private int mode;
public GetACParametersRequest(int indexId, int mode) {
this.indexId = indexId;
this.mode = mode;
}
public GetACParametersRequest() {
}
public int getIndexId() {
return indexId;
}
public void setIndexId(int indexId) {
this.indexId = indexId;
}
public int getMode() {
return mode;
}
public void setMode(int mode) {
this.mode = mode;
}
}

View File

@@ -19,14 +19,18 @@ public class ListIndexesRequest extends BaseRequest {
private String cityCode;
private String operatorId;
// try index in IRIS with this flag set to 1
private int withParaData;
public ListIndexesRequest(int from, int count, int categoryId, int brandId,
String cityCode, String operatorId) {
String cityCode, String operatorId, int withParaData) {
this.from = from;
this.count = count;
this.categoryId = categoryId;
this.brandId = brandId;
this.cityCode = cityCode;
this.operatorId = operatorId;
this.withParaData = withParaData;
}
public ListIndexesRequest() {
@@ -80,4 +84,12 @@ public class ListIndexesRequest extends BaseRequest {
public void setOperatorId(String operatorId) {
this.operatorId = operatorId;
}
public int getWithParaData() {
return withParaData;
}
public void setWithParaData(int withParaData) {
this.withParaData = withParaData;
}
}

View File

@@ -0,0 +1,36 @@
package net.irext.webapi.response;
import net.irext.webapi.model.ACParameters;
/**
* Filename: ACParametersResponse.java
* Revised: Date: 2017-05-16
* Revision: Revision: 1.0
* <p>
* Description: Air conditioner support parameters response
* <p>
* Revision log:
* 2019-02-14: created by strawmanbobi
*/
public class ACParametersResponse extends ServiceResponse {
private ACParameters entity;
public ACParametersResponse(Status status, ACParameters entity) {
super(status);
this.entity = entity;
}
public ACParametersResponse() {
super(new Status());
this.entity = null;
}
public ACParameters getEntity() {
return entity;
}
public void setEntity(ACParameters entity) {
this.entity = entity;
}
}

View File

@@ -34,7 +34,7 @@ public class Constants {
CLEANING_ROBOT(12),
AIR_CLEANER(13),
DYSON(14);
private final int id;
CategoryID(int id) {

View File

@@ -1,6 +1,7 @@
package net.irext.webapi;
import com.google.gson.Gson;
import net.irext.webapi.bean.ACStatus;
import net.irext.webapi.model.*;
import net.irext.webapi.utils.Constants;
import net.irext.webapi.request.*;
@@ -28,7 +29,7 @@ public class WebAPIs {
private static WebAPIs mInstance = null;
private static final String DEFAULT_ADDRESS = "http://irext.net";
private static final String DEFAULT_ADDRESS = "http://localhost:8081";
private static final String DEFAULT_APP = "/irext-server";
private static String URL_PREFIX = DEFAULT_ADDRESS + DEFAULT_APP;
@@ -46,11 +47,12 @@ public class WebAPIs {
private static final String SERVICE_LIST_INDEXES = "/indexing/list_indexes";
private static final String SERVICE_DOWNLOAD_BIN = "/operation/download_bin";
private static final String SERVICE_ONLINE_DECODE = "/operation/decode";
private static final String SERVICE_GET_AC_PARAMETERS = "/operation/get_ac_parameters";
private int id;
private String token;
private OkHttpClient mHttpClient;
private final OkHttpClient mHttpClient;
private WebAPIs(String address, String appName) {
if (null != address && null != appName) {
@@ -267,6 +269,7 @@ public class WebAPIs {
int brandId,
String cityCode,
String operatorId,
int withParaData,
ListIndexesCallback onListIndexCallback) {
String listIndexesURL = URL_PREFIX + SERVICE_LIST_INDEXES;
ListIndexesRequest listIndexesRequest = new ListIndexesRequest();
@@ -276,6 +279,7 @@ public class WebAPIs {
listIndexesRequest.setBrandId(brandId);
listIndexesRequest.setCityCode(cityCode);
listIndexesRequest.setOperatorId(operatorId);
listIndexesRequest.setWithParaData(withParaData);
listIndexesRequest.setFrom(0);
listIndexesRequest.setCount(20);
String bodyJson = listIndexesRequest.toJson();
@@ -299,8 +303,7 @@ public class WebAPIs {
@SuppressWarnings("unused")
public void downloadBin(String remoteMap, int indexId,
DownloadBinCallback downloadBinCallback) {
String fileName = IR_BIN_FILE_PREFIX + remoteMap + IR_BIN_FILE_SUFFIX;
String downloadURL = IR_BIN_DOWNLOAD_PREFIX + fileName;
String downloadURL = URL_PREFIX + SERVICE_DOWNLOAD_BIN;
DownloadBinaryRequest downloadBinaryRequest = new DownloadBinaryRequest();
downloadBinaryRequest.setId(id);
downloadBinaryRequest.setToken(token);
@@ -310,7 +313,7 @@ public class WebAPIs {
if (null != bodyJson) {
try {
InputStream binStream = getFileByteStreamByURL(downloadURL);
InputStream binStream = postToServerForOctets(downloadURL, bodyJson);
if (null != binStream) {
downloadBinCallback.onDownloadBinSuccess(binStream);
@@ -325,13 +328,18 @@ public class WebAPIs {
}
@SuppressWarnings("unused")
@Deprecated
public int[] decodeIR(int indexId) {
public int[] decodeIR(int indexId, ACStatus acStatus, int keyCode, int changeWindDir,
Integer directDecode, Integer paraData) {
String decodeURL = URL_PREFIX + SERVICE_ONLINE_DECODE;
DecodeRequest decodeRequest = new DecodeRequest();
decodeRequest.setId(id);
decodeRequest.setToken(token);
decodeRequest.setIndexId(indexId);
decodeRequest.setAcStatus(acStatus);
decodeRequest.setKeyCode(keyCode);
decodeRequest.setChangeWindDir(changeWindDir);
decodeRequest.setDirectDecode(directDecode);
decodeRequest.setParaData(paraData);
String bodyJson = decodeRequest.toJson();
@@ -350,4 +358,30 @@ public class WebAPIs {
}
return null;
}
@SuppressWarnings("unused")
public ACParameters getACParameters(int indexId, int mode) {
String decodeURL = URL_PREFIX + SERVICE_GET_AC_PARAMETERS;
GetACParametersRequest getACParametersRequest = new GetACParametersRequest();
getACParametersRequest.setId(id);
getACParametersRequest.setToken(token);
getACParametersRequest.setIndexId(indexId);
getACParametersRequest.setMode(mode);
String bodyJson = getACParametersRequest.toJson();
if (null != bodyJson) {
try {
String response = postToServer(decodeURL, bodyJson);
ACParametersResponse acParametersResponse = new Gson().fromJson(response, ACParametersResponse.class);
if (acParametersResponse.getStatus().getCode() == Constants.ERROR_CODE_SUCCESS) {
return acParametersResponse.getEntity();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
}
}

View File

@@ -0,0 +1,83 @@
package net.irext.webapi.model;
/**
* Filename: ACParameters.java
* Revised: Date: 2019-02-14
* Revision: Revision: 1.0
* <p>
* Description: AC parameters entity
* <p>
* Revision log:
* 2018-12-29: created by strawmanbobi
*/
public class ACParameters {
private int tempMin;
private int tempMax;
private int [] supportedModes;
private int []supportedWindSpeed;
private int []supportedSwing;
private int []supportedWindDirections;
public ACParameters(int tempMin, int tempMax, int[] supportedModes,
int[] supportedWindSpeed,
int[] supportedSwing, int[] supportedWindDirections) {
this.tempMin = tempMin;
this.tempMax = tempMax;
this.supportedModes = supportedModes;
this.supportedWindSpeed = supportedWindSpeed;
this.supportedSwing = supportedSwing;
this.supportedWindDirections = supportedWindDirections;
}
public ACParameters() {
}
public int getTempMin() {
return tempMin;
}
public void setTempMin(int tempMin) {
this.tempMin = tempMin;
}
public int getTempMax() {
return tempMax;
}
public void setTempMax(int tempMax) {
this.tempMax = tempMax;
}
public int[] getSupportedModes() {
return supportedModes;
}
public void setSupportedModes(int[] supportedModes) {
this.supportedModes = supportedModes;
}
public int[] getSupportedWindSpeed() {
return supportedWindSpeed;
}
public void setSupportedWindSpeed(int[] supportedWindSpeed) {
this.supportedWindSpeed = supportedWindSpeed;
}
public int[] getSupportedSwing() {
return supportedSwing;
}
public void setSupportedSwing(int[] supportedSwing) {
this.supportedSwing = supportedSwing;
}
public int[] getSupportedWindDirections() {
return supportedWindDirections;
}
public void setSupportedWindDirections(int[] supportedWindDirections) {
this.supportedWindDirections = supportedWindDirections;
}
}

View File

@@ -18,12 +18,17 @@ public class DecodeRequest extends BaseRequest {
private ACStatus acStatus;
private int keyCode;
private int changeWindDir;
private Integer directDecode;
private Integer paraData;
public DecodeRequest(int indexId, ACStatus acStatus, int keyCode, int changeWindDir) {
public DecodeRequest(int indexId, ACStatus acStatus, int keyCode, int changeWindDir,
Integer directDecode, Integer paraData) {
this.indexId = indexId;
this.acStatus = acStatus;
this.keyCode = keyCode;
this.changeWindDir = changeWindDir;
this.directDecode = directDecode;
this.paraData = paraData;
}
public DecodeRequest() {
@@ -61,4 +66,20 @@ public class DecodeRequest extends BaseRequest {
public void setChangeWindDir(int changeWindDir) {
this.changeWindDir = changeWindDir;
}
public Integer getDirectDecode() {
return directDecode;
}
public void setDirectDecode(Integer directDecode) {
this.directDecode = directDecode;
}
public Integer getParaData() {
return paraData;
}
public void setParaData(Integer paraData) {
this.paraData = paraData;
}
}

View File

@@ -0,0 +1,41 @@
package net.irext.webapi.request;
/**
* Filename: GetACParametersRequest.java
* Revised: Date: 2017-05-16
* Revision: Revision: 1.0
* <p>
* Description: HTTP server online
* <p>
* Revision log:
* 2019-02-14: created by strawmanbobi
*/
public class GetACParametersRequest extends BaseRequest {
private int indexId;
private int mode;
public GetACParametersRequest(int indexId, int mode) {
this.indexId = indexId;
this.mode = mode;
}
public GetACParametersRequest() {
}
public int getIndexId() {
return indexId;
}
public void setIndexId(int indexId) {
this.indexId = indexId;
}
public int getMode() {
return mode;
}
public void setMode(int mode) {
this.mode = mode;
}
}

View File

@@ -19,14 +19,18 @@ public class ListIndexesRequest extends BaseRequest {
private String cityCode;
private String operatorId;
// try index in IRIS with this flag set to 1
private int withParaData;
public ListIndexesRequest(int from, int count, int categoryId, int brandId,
String cityCode, String operatorId) {
String cityCode, String operatorId, int withParaData) {
this.from = from;
this.count = count;
this.categoryId = categoryId;
this.brandId = brandId;
this.cityCode = cityCode;
this.operatorId = operatorId;
this.withParaData = withParaData;
}
public ListIndexesRequest() {
@@ -80,4 +84,12 @@ public class ListIndexesRequest extends BaseRequest {
public void setOperatorId(String operatorId) {
this.operatorId = operatorId;
}
public int getWithParaData() {
return withParaData;
}
public void setWithParaData(int withParaData) {
this.withParaData = withParaData;
}
}

View File

@@ -0,0 +1,36 @@
package net.irext.webapi.response;
import net.irext.webapi.model.ACParameters;
/**
* Filename: ACParametersResponse.java
* Revised: Date: 2017-05-16
* Revision: Revision: 1.0
* <p>
* Description: Air conditioner support parameters response
* <p>
* Revision log:
* 2019-02-14: created by strawmanbobi
*/
public class ACParametersResponse extends ServiceResponse {
private ACParameters entity;
public ACParametersResponse(Status status, ACParameters entity) {
super(status);
this.entity = entity;
}
public ACParametersResponse() {
super(new Status());
this.entity = null;
}
public ACParameters getEntity() {
return entity;
}
public void setEntity(ACParameters entity) {
this.entity = entity;
}
}

12
web-sdk/web-sdk.iml Normal file
View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="lib" level="project" />
</component>
</module>