updated Android example according to 0.2.1
This commit is contained in:
Binary file not shown.
@@ -1 +1 @@
|
||||
[{"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":{}}]
|
||||
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":4,"versionName":"0.2.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
|
||||
@@ -6,8 +6,9 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.irext.decode.sdk.utils.Constants;
|
||||
import net.irext.ircontrol.R;
|
||||
import net.irext.sdk.utils.Constants;
|
||||
import net.irext.webapi.model.RemoteIndex;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -6,10 +6,10 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.irext.decode.sdk.utils.Constants;
|
||||
import net.irext.ircontrol.R;
|
||||
import net.irext.ircontrol.bean.RemoteControl;
|
||||
import net.irext.sdk.utils.Constants;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,13 +9,13 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
|
||||
import net.irext.decode.sdk.utils.Constants;
|
||||
import net.irext.ircontrol.IRApplication;
|
||||
import net.irext.ircontrol.R;
|
||||
import net.irext.ircontrol.ui.activity.CreateActivity;
|
||||
import net.irext.ircontrol.ui.adapter.CategoryAdapter;
|
||||
import net.irext.ircontrol.ui.widget.PullToRefreshListView;
|
||||
import net.irext.ircontrol.utils.MessageUtil;
|
||||
import net.irext.sdk.utils.Constants;
|
||||
import net.irext.webapi.model.Category;
|
||||
import net.irext.webapi.WebAPICallbacks.ListCategoriesCallback;
|
||||
|
||||
|
||||
@@ -14,9 +14,9 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.*;
|
||||
|
||||
import net.irext.decode.sdk.bean.ACStatus;
|
||||
import net.irext.decode.sdk.IRDecode;
|
||||
import net.irext.sdk.utils.Constants;
|
||||
import net.irext.decode.sdk.bean.ACStatus;
|
||||
import net.irext.decode.sdk.utils.Constants;
|
||||
import net.irext.ircontrol.R;
|
||||
import net.irext.ircontrol.bean.RemoteControl;
|
||||
import net.irext.ircontrol.ui.activity.ControlActivity;
|
||||
@@ -162,14 +162,14 @@ public class ControlFragment extends Fragment implements View.OnClickListener {
|
||||
/* decode SDK - decode according to key code */
|
||||
if (Constants.CategoryID.AIR_CONDITIONER.getValue() ==
|
||||
mCurrentRemoteControl.getCategoryId()) {
|
||||
acStatus.setACPower(Constants.ACPower.POWER_OFF.getValue());
|
||||
acStatus.setACMode(Constants.ACMode.MODE_COOL.getValue());
|
||||
acStatus.setACTemp(Constants.ACTemperature.TEMP_24.getValue());
|
||||
acStatus.setACWindSpeed(Constants.ACWindSpeed.SPEED_AUTO.getValue());
|
||||
acStatus.setACWindDir(Constants.ACSwing.SWING_ON.getValue());
|
||||
acStatus.setACDisplay(0);
|
||||
acStatus.setACTimer(0);
|
||||
acStatus.setACSleep(0);
|
||||
acStatus.setAcPower(Constants.ACPower.POWER_OFF.getValue());
|
||||
acStatus.setAcMode(Constants.ACMode.MODE_COOL.getValue());
|
||||
acStatus.setAcTemp(Constants.ACTemperature.TEMP_24.getValue());
|
||||
acStatus.setAcWindSpeed(Constants.ACWindSpeed.SPEED_AUTO.getValue());
|
||||
acStatus.setAcWindDir(Constants.ACSwing.SWING_ON.getValue());
|
||||
acStatus.setAcDisplay(0);
|
||||
acStatus.setAcTimer(0);
|
||||
acStatus.setAcSleep(0);
|
||||
|
||||
switch(keyCode) {
|
||||
case KEY_POWER:
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -2,7 +2,7 @@ package net.irext.decode.sdk;
|
||||
|
||||
import net.irext.decode.sdk.bean.ACStatus;
|
||||
import net.irext.decode.sdk.bean.TemperatureRange;
|
||||
import net.irext.sdk.utils.Constants;
|
||||
import net.irext.decode.sdk.utils.Constants;
|
||||
|
||||
/**
|
||||
* Filename: IRDecode.java
|
||||
@@ -18,9 +18,7 @@ public class IRDecode {
|
||||
|
||||
private static final String TAG = IRDecode.class.getSimpleName();
|
||||
|
||||
static {
|
||||
System.loadLibrary("irdecode");
|
||||
}
|
||||
private static Object mSync = new Object();
|
||||
|
||||
private native int irOpen(int category, int subCate, String fileName);
|
||||
|
||||
@@ -38,6 +36,8 @@ public class IRDecode {
|
||||
|
||||
private native int irACGetSupportedSwing(int acMode);
|
||||
|
||||
private native int irACGetSupportedWindDirection(int acMode);
|
||||
|
||||
private static IRDecode mInstance;
|
||||
|
||||
public static IRDecode getInstance() {
|
||||
@@ -48,7 +48,9 @@ public class IRDecode {
|
||||
}
|
||||
|
||||
private IRDecode() {
|
||||
|
||||
String libPath = "/data/irext/libirda_decoder.so";
|
||||
System.out.println("loading decode library " + libPath);
|
||||
System.load(libPath);
|
||||
}
|
||||
|
||||
public int openFile(int category, int subCate, String fileName) {
|
||||
@@ -60,10 +62,14 @@ public class IRDecode {
|
||||
}
|
||||
|
||||
public int[] decodeBinary(int keyCode, ACStatus acStatus, int changeWindDir) {
|
||||
int[] decoded;
|
||||
synchronized (mSync) {
|
||||
if (null == acStatus) {
|
||||
acStatus = new ACStatus();
|
||||
}
|
||||
return irDecode(keyCode, acStatus, changeWindDir);
|
||||
decoded = irDecode(keyCode, acStatus, changeWindDir);
|
||||
}
|
||||
return decoded;
|
||||
}
|
||||
|
||||
public void closeBinary() {
|
||||
@@ -76,7 +82,7 @@ public class IRDecode {
|
||||
|
||||
public int[] getACSupportedMode() {
|
||||
// cool, heat, auto, fan, de-humidification
|
||||
int []retSupportedMode = {0, 0, 0, 0, 0};
|
||||
int[] retSupportedMode = {0, 0, 0, 0, 0};
|
||||
int supportedMode = irACGetSupportedMode();
|
||||
for (int i = Constants.ACMode.MODE_COOL.getValue(); i <=
|
||||
Constants.ACMode.MODE_DEHUMIDITY.getValue(); i++) {
|
||||
@@ -87,7 +93,7 @@ public class IRDecode {
|
||||
|
||||
public int[] getACSupportedWindSpeed(int acMode) {
|
||||
// auto, low, medium, high
|
||||
int []retSupportedWindSpeed = {0, 0, 0, 0};
|
||||
int[] retSupportedWindSpeed = {0, 0, 0, 0};
|
||||
int supportedWindSpeed = irACGetSupportedWindSpeed(acMode);
|
||||
for (int i = Constants.ACWindSpeed.SPEED_AUTO.getValue();
|
||||
i <= Constants.ACWindSpeed.SPEED_HIGH.getValue();
|
||||
@@ -99,7 +105,7 @@ public class IRDecode {
|
||||
|
||||
public int[] getACSupportedSwing(int acMode) {
|
||||
// swing-on, swing-off
|
||||
int []retSupportedSwing= {0, 0};
|
||||
int[] retSupportedSwing = {0, 0};
|
||||
int supportedSwing = irACGetSupportedSwing(acMode);
|
||||
for (int i = Constants.ACSwing.SWING_ON.getValue();
|
||||
i <= Constants.ACSwing.SWING_OFF.getValue();
|
||||
@@ -108,4 +114,9 @@ public class IRDecode {
|
||||
}
|
||||
return retSupportedSwing;
|
||||
}
|
||||
|
||||
public int getACSupportedWindDirection(int acMode) {
|
||||
// how many directions supported by specific AC
|
||||
return irACGetSupportedWindDirection(acMode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.irext.decode.sdk.bean;
|
||||
|
||||
import net.irext.sdk.utils.Constants;
|
||||
import net.irext.decode.sdk.utils.Constants;
|
||||
|
||||
/**
|
||||
* Filename: ACStatus.java
|
||||
@@ -48,67 +48,67 @@ public class ACStatus {
|
||||
this.acTimer = acTimer;
|
||||
}
|
||||
|
||||
public int getACPower() {
|
||||
public int getAcPower() {
|
||||
return acPower;
|
||||
}
|
||||
|
||||
public void setACPower(int acPower) {
|
||||
public void setAcPower(int acPower) {
|
||||
this.acPower = acPower;
|
||||
}
|
||||
|
||||
public int getACTemp() {
|
||||
public int getAcTemp() {
|
||||
return acTemp;
|
||||
}
|
||||
|
||||
public void setACTemp(int acTemp) {
|
||||
public void setAcTemp(int acTemp) {
|
||||
this.acTemp = acTemp;
|
||||
}
|
||||
|
||||
public int getACMode() {
|
||||
public int getAcMode() {
|
||||
return acMode;
|
||||
}
|
||||
|
||||
public void setACMode(int acMode) {
|
||||
public void setAcMode(int acMode) {
|
||||
this.acMode = acMode;
|
||||
}
|
||||
|
||||
public int getACWindDir() {
|
||||
public int getAcWindDir() {
|
||||
return acWindDir;
|
||||
}
|
||||
|
||||
public void setACWindDir(int acWindDir) {
|
||||
public void setAcWindDir(int acWindDir) {
|
||||
this.acWindDir = acWindDir;
|
||||
}
|
||||
|
||||
public int getACWindSpeed() {
|
||||
public int getAcWindSpeed() {
|
||||
return acWindSpeed;
|
||||
}
|
||||
|
||||
public void setACWindSpeed(int acWindSpeed) {
|
||||
public void setAcWindSpeed(int acWindSpeed) {
|
||||
this.acWindSpeed = acWindSpeed;
|
||||
}
|
||||
|
||||
public int getACDisplay() {
|
||||
public int getAcDisplay() {
|
||||
return acDisplay;
|
||||
}
|
||||
|
||||
public void setACDisplay(int acDisplay) {
|
||||
public void setAcDisplay(int acDisplay) {
|
||||
this.acDisplay = acDisplay;
|
||||
}
|
||||
|
||||
public int getACSleep() {
|
||||
public int getAcSleep() {
|
||||
return acSleep;
|
||||
}
|
||||
|
||||
public void setACSleep(int acSleep) {
|
||||
public void setAcSleep(int acSleep) {
|
||||
this.acSleep = acSleep;
|
||||
}
|
||||
|
||||
public int getACTimer() {
|
||||
public int getAcTimer() {
|
||||
return acTimer;
|
||||
}
|
||||
|
||||
public void setACTimer(int acTimer) {
|
||||
public void setAcTimer(int acTimer) {
|
||||
this.acTimer = acTimer;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.irext.sdk.utils;
|
||||
package net.irext.decode.sdk.utils;
|
||||
|
||||
/**
|
||||
* Filename: Constants.java
|
||||
@@ -14,10 +14,24 @@ public class Constants {
|
||||
|
||||
public static final int ERROR_CODE_SUCCESS = 0;
|
||||
public static final int ERROR_CODE_NETWORK_ERROR = -1;
|
||||
|
||||
public static final int ERROR_CODE_AUTH_FAILURE = 1;
|
||||
public static final int ERROR_CODE_INVALID_CATEGORY = 2;
|
||||
public static final int ERROR_CODE_INVALID_BRAND = 3;
|
||||
public static final int ERROR_CODE_INVALID_PARAMETER = 4;
|
||||
public static final int ERROR_CODE_INVALID_CITY = 5;
|
||||
public static final int ERROR_CODE_INVALID_OPERATOR = 6;
|
||||
|
||||
public static final int ERROR_CODE_INVALID_SESSION = 20;
|
||||
|
||||
public static final String ERROR_CODE_SUCESS_TEXT = "success";
|
||||
public static final String ERROR_CODE_NETWORK_ERROR_TEXT = "network error";
|
||||
public static final String ERROR_CODE_AUTH_FAILUTRE_TEXT = "auth failure";
|
||||
public static final String ERROR_CODE_INVALID_CATEGORY_TEXT = "invalid category";
|
||||
public static final String ERROR_CODE_INVALID_BRAND_TEXT = "invalid brand";
|
||||
public static final String ERROR_CODE_INVALID_PARAMETER_TEXT = "invalid parameter";
|
||||
|
||||
public static final String ERROR_CODE_INVALID_SESSION_TEXT = "invalid decode session";
|
||||
|
||||
public enum CategoryID {
|
||||
AIR_CONDITIONER(1),
|
||||
|
||||
Reference in New Issue
Block a user