xuxiuxi
2017-06-02 3cceac30dc1c5a7cf5bd4f95e327e855cdcf304d
VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/DeviceMng.java
@@ -22,7 +22,7 @@
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;
@@ -50,12 +50,19 @@
    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);
@@ -84,6 +91,22 @@
    }
    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);
    }