| | |
| | | */ |
| | | public void getGatewayInfo(String mac, LinkCallBack<GatewayBean> linkCallBack) { |
| | | String requestUrl = TopicApi.GET_GATEWAY_INFO; |
| | | TcpClient.getInstance().sendDataToLinkGateway(mac, requestUrl, null, "", new HDLLinkCallBack() { |
| | | JsonObject json = new JsonObject(); |
| | | json.addProperty("device_mac", mac); |
| | | TcpClient.getInstance().sendDataToLinkGateway(mac, requestUrl, json, "", new HDLLinkCallBack() { |
| | | @Override |
| | | public void onSuccess(String json) { |
| | | if (TextUtils.isEmpty(json)) { |
| | | if (linkCallBack != null) { |
| | | linkCallBack.onSuccess(null); |
| | | } |
| | | if (linkCallBack == null) { |
| | | return; |
| | | } |
| | | Gson gson = new Gson(); |
| | | GatewayBean gatewayBean = gson.fromJson(json, GatewayBean.class); |
| | | if (linkCallBack != null) { |
| | | linkCallBack.onSuccess(gatewayBean); |
| | | if (TextUtils.isEmpty(json)) { |
| | | linkCallBack.onSuccess(null); |
| | | return; |
| | | } |
| | | |
| | | Gson gson = new Gson(); |
| | | Type typeOfT = new TypeToken<BaseLocalResponse<GatewayBean>>() { |
| | | }.getType(); |
| | | BaseLocalResponse<GatewayBean> baseLocalResponse = gson.fromJson(json, typeOfT); |
| | | if (baseLocalResponse == null || baseLocalResponse.getObjects() == null) { |
| | | linkCallBack.onSuccess(new GatewayBean()); |
| | | } else { |
| | | linkCallBack.onSuccess(baseLocalResponse.getObjects()); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |