use of itor.topnetwork.com.dxditor.bean.GjxxBean in project Dxditor by kimi2009.
the class MainpageModel method getGjxxData.
@Override
public void getGjxxData(final ValueCallBack<List<GjxxBean>> callBack) {
gjxxList = new ArrayList<GjxxBean>();
if (Constants.testData) {
gjxxList.add(new GjxxBean(1, "已恢复", 11, 0.27f));
gjxxList.add(new GjxxBean(2, "已处理", 19, 0.46f));
gjxxList.add(new GjxxBean(0, "告警中", 11, 0.27f));
callBack.onSuccess(gjxxList);
} else {
Request request = new Request.Builder().url(Constants.getAppDeviceAlarmProportion).build();
okHttpClient.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
String res = response.body().string();
System.out.println("getAppDeviceAlarmProportion:" + res);
try {
JSONObject js = new JSONObject(res);
if (js.getBoolean("success")) {
gjxxList = gson.fromJson(js.getString("data"), new TypeToken<ArrayList<GjxxBean>>() {
}.getType());
callBack.onSuccess(gjxxList);
} else {
callBack.onFail("01");
}
} catch (Exception e) {
callBack.onFail("01");
e.printStackTrace();
}
}
});
}
}
Aggregations