use of itor.topnetwork.com.dxditor.bean.BridgeWarning in project Dxditor by kimi2009.
the class BridgeModel method getWarningData.
@Override
public void getWarningData(final ValueCallBack<ArrayList<BridgeWarning>> callBack) {
if (Constants.testData) {
ArrayList<BridgeWarning> temp = new ArrayList<BridgeWarning>();
temp.add(new BridgeWarning("京津线39号桥梁(中间)梁体应力", null, "3.5N", "2.3N", null, "1", null, null));
temp.add(new BridgeWarning("京张铁路18号桥梁(中间)梁体裂缝宽度", null, "1.2cm", "1.1cm", null, "2", null, null));
temp.add(new BridgeWarning("京沪线75号桥梁梁体横向位移", null, "0.6cm", "0.9cm", null, "3", null, null));
bridgeWarnings = temp;
callBack.onSuccess(bridgeWarnings);
} else {
FormBody formBody = new FormBody.Builder().add("bridgeCode", // 设置参数名称和参数值
Constants.BRIDGECODE).build();
Request request = new Request.Builder().post(formBody).url(Constants.getAppBridgeNewOneAlarm).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();
try {
JSONObject js = new JSONObject(res);
if (js.getBoolean("success")) {
bridgeWarnings = gson.fromJson(js.getString("data"), new TypeToken<ArrayList<BridgeWarning>>() {
}.getType());
callBack.onSuccess(bridgeWarnings);
} else {
callBack.onFail("01");
}
} catch (Exception e) {
callBack.onFail("01");
e.printStackTrace();
}
}
});
}
}
Aggregations