|
|
|
@ -4,6 +4,8 @@ import android.app.Activity; |
|
|
|
import android.util.Log; |
|
|
|
|
|
|
|
import com.google.gson.Gson; |
|
|
|
import com.google.gson.JsonObject; |
|
|
|
import com.google.gson.JsonParser; |
|
|
|
import com.google.gson.reflect.TypeToken; |
|
|
|
import com.loopj.android.http.AsyncHttpClient; |
|
|
|
import com.loopj.android.http.AsyncHttpResponseHandler; |
|
|
|
@ -217,6 +219,41 @@ public class DeviceData extends BaseData { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 通过接口来判断网络是否正常 |
|
|
|
* */ |
|
|
|
public static void getMachine() { |
|
|
|
RetrofitUtil.getBaseService().getMachine(DeviceData.getDeviceInfo(HINT_DEVICE_CODE)).enqueue(new Callback<Resp>() { |
|
|
|
@Override |
|
|
|
public void onResponse(Call<Resp> call, Response<Resp> response) { |
|
|
|
try { |
|
|
|
if(response.body()!=null){ |
|
|
|
if (StringUtil.respSuccess(response.body())) { |
|
|
|
String dataJson = new Gson().toJson(response.body().getData()); |
|
|
|
if(!dataJson.contains("machineCode")){ |
|
|
|
//加密数据
|
|
|
|
dataJson = AesUtil.decrypt((String.valueOf(response.body().getData()))); |
|
|
|
} |
|
|
|
JsonObject jsonObject = new JsonParser().parse(dataJson).getAsJsonObject(); |
|
|
|
String typeName = jsonObject.get("machineTypeName").getAsString(); |
|
|
|
DeviceData.saveDeviceInfo(DeviceData.HINT_DEVICE_TYPE, typeName); //设备类型
|
|
|
|
LoggerUtil.e("getMachine()", typeName); |
|
|
|
} |
|
|
|
}else { |
|
|
|
LoggerUtil.e("getMachine()", "body()=null"); |
|
|
|
} |
|
|
|
} catch (Throwable t) { |
|
|
|
LoggerUtil.e("getMachine()", StringUtil.getThrowableStr(t)); |
|
|
|
} |
|
|
|
} |
|
|
|
@Override |
|
|
|
public void onFailure(Call<Resp> call, Throwable t) { |
|
|
|
LoggerUtil.e("getMachine()", "请求超时"); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取图片视频下载地址ip |
|
|
|
*/ |
|
|
|
|