| | |
| | | public class DeviceMng {
|
| | | public static DeviceMng instance = new DeviceMng();
|
| | |
|
| | | public static String authorationId = null;
|
| | | public static String authorationId = "101";
|
| | |
|
| | | public static DeviceMng getInstance() {
|
| | | return instance;
|
| | |
| | |
|
| | | public void load () {
|
| | | try {
|
| | | if (authorationId == null || authorationId.trim().length() <= 1) {
|
| | | getAuthorationId();
|
| | | return;
|
| | | }
|
| | | // if (authorationId == null || authorationId.trim().length() <= 1) {
|
| | | // getAuthorationId();
|
| | | // MainActivity.getInstance().runOnUiThread(new Runnable() {
|
| | | // @Override
|
| | | // public void run() {
|
| | | // Toast.makeText(MainActivity.getInstance(), "请填写设备序列号", Toast.LENGTH_SHORT).show();
|
| | | // }
|
| | | // });
|
| | | // return;
|
| | | // }
|
| | | RequestParams params = new RequestParams(AppApi.BASE_URL + AppApi.Query.DEVICE_QUERY);
|
| | | params.addBodyParameter(Device.FieldNames.authorizationId, authorationId);
|
| | | params.addBodyParameter(Device.FieldNames.sn, authorationId);
|
| | | params.addBodyParameter(Device.FieldNames.type, CommonVariables.DeviceType.ANDROID_DEVICE);
|
| | | x.http().post(params, new BaseCommonCallBack() {
|
| | | public void success() {
|
| | | List<Device> places = resultBean.getListBeanOfType(Device.class);
|
| | |
| | | }
|
| | |
|
| | | public void saveLanSetting(Map<String, String> fields) {
|
| | |
|
| | | RequestParams params = new RequestParams(AppApi.BASE_URL + AppApi.Query.DEVICE_QUERY);
|
| | | params.addBodyParameter(Device.FieldNames.sn, authorationId);
|
| | | params.addBodyParameter(Device.FieldNames.type, CommonVariables.DeviceType.ANDROID_DEVICE);
|
| | | x.http().post(params, new BaseCommonCallBack() {
|
| | | public void success() {
|
| | | List<Device> places = resultBean.getListBeanOfType(Device.class);
|
| | | if (places.size() > 0) {
|
| | | BaseApplication.getInstance().setDevice(places.get(0));
|
| | | } else {
|
| | | Toast.makeText(BaseApplication.getInstance(), "数据库中找不到该设备", Toast.LENGTH_SHORT).show();
|
| | | }
|
| | | }
|
| | | });
|
| | |
|
| | |
|
| | | SharedPreferencesUtils.save(CommonVariables.DeviceSharedPreferences.LAN, fields);
|
| | | }
|
| | |
|