| | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 住宅逻辑界面 |
| | | */ |
| | | public class HdlResidenceLogic { |
| | | |
| | | private static volatile HdlResidenceLogic sHdlResidenceLogic; |
| | | |
| | | /** |
| | | * 获取当前对象 |
| | | * |
| | | * @return HdlResidenceLogic |
| | | */ |
| | | public static synchronized HdlResidenceLogic getInstance() { |
| | | if (sHdlResidenceLogic == null) { |
| | | synchronized (HdlResidenceLogic.class) { |
| | |
| | | HttpClient.getInstance().requestHttp(requestUrl, json.toString(), true, true, new BaseSuccessFailureCallBeak() { |
| | | @Override |
| | | public void onSuccess(HttpResponsePack httpResponsePack) { |
| | | if (httpResponsePack != null) { |
| | | if (httpResponsePack.getData() != null) { |
| | | Gson gson = new Gson(); |
| | | String jsonStr = gson.toJson(httpResponsePack.getData().toString()); |
| | | HouseInfoBeanClass houseInfoBeanClass = gson.fromJson(jsonStr, HouseInfoBeanClass.class); |
| | | houseList.addAll(houseInfoBeanClass.getList()); |
| | | //总共有多少页 |
| | | long totalPage = houseInfoBeanClass.totalPage; |
| | | if (totalPage == houseInfoBeanClass.getPageNo()) { |
| | | if (httpResponsePack != null && httpResponsePack.getData() != null) { |
| | | Gson gson = new Gson(); |
| | | String jsonStr = gson.toJson(httpResponsePack.getData()); |
| | | HouseInfoBeanClass houseInfoBeanClass = gson.fromJson(jsonStr, HouseInfoBeanClass.class); |
| | | houseList.addAll(houseInfoBeanClass.getList()); |
| | | //总共有多少页 |
| | | long totalPage = houseInfoBeanClass.totalPage; |
| | | if (totalPage == houseInfoBeanClass.getPageNo()) { |
| | | if (cloudCallBeak != null) { |
| | | cloudCallBeak.onSuccess(true); |
| | | return; |
| | | } |
| | | getResidenceList(pageNo + 1, 100, cloudCallBeak); |
| | | } else { |
| | | cloudCallBeak.onSuccess(false); |
| | | return; |
| | | } |
| | | getResidenceList(pageNo + 1, 100, cloudCallBeak); |
| | | |
| | | } |
| | | } |
| | |
| | | |
| | | @Override |
| | | public void onFailure(Exception exception) { |
| | | cloudCallBeak.onFailure(exception); |
| | | if (cloudCallBeak != null) { |
| | | cloudCallBeak.onFailure(exception); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | |
| | | * @param cloudCallBeak 回调 |
| | | */ |
| | | public void getResidenceInfo(String homeId, CloudCallBeak<HouseInfoBean> cloudCallBeak) { |
| | | String requestUrl = HttpApi.POST_GET_MEMBER_INFO; |
| | | String requestUrl = HttpApi.POST_PowerStation_Info; |
| | | JsonObject json = new JsonObject(); |
| | | json.addProperty("homeId", homeId);//电站id |
| | | //json.addProperty("zoneType", "password");//区域 |
| | | HttpClient.getInstance().requestHttp(requestUrl, json.toString(), true, true, new BaseSuccessFailureCallBeak() { |
| | | @Override |
| | | public void onSuccess(HttpResponsePack httpResponsePack) { |
| | | if (httpResponsePack != null) { |
| | | if (httpResponsePack.getData() != null) { |
| | | Gson gson = new Gson(); |
| | | String jsonStr = gson.toJson(httpResponsePack.getData().toString()); |
| | | HouseInfoBean houseInfoBean = gson.fromJson(jsonStr, HouseInfoBean.class); |
| | | if (httpResponsePack != null && httpResponsePack.getData() != null) { |
| | | Gson gson = new Gson(); |
| | | String jsonStr = gson.toJson(httpResponsePack.getData()); |
| | | HouseInfoBean houseInfoBean = gson.fromJson(jsonStr, HouseInfoBean.class); |
| | | if (cloudCallBeak != null) { |
| | | cloudCallBeak.onSuccess(houseInfoBean); |
| | | } else { |
| | | cloudCallBeak.onSuccess(null); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(Exception exception) { |
| | | cloudCallBeak.onFailure(exception); |
| | | if (cloudCallBeak != null) { |
| | | cloudCallBeak.onFailure(exception); |
| | | } |
| | | } |
| | | }); |
| | | |
| | |
| | | * @param cloudCallBeak - |
| | | */ |
| | | public void editResidence(HouseInfoBean houseInfoBean, CloudCallBeak<Boolean> cloudCallBeak) { |
| | | String requestUrl = HttpApi.POST_PowerStation_Create; |
| | | String requestUrl = HttpApi.POST_PowerStation_Edit; |
| | | JsonObject json = new JsonObject(); |
| | | JsonObject location = new JsonObject(); |
| | | json.addProperty("homeId", houseInfoBean.getHomeId()); |
| | |
| | | HttpClient.getInstance().requestHttp(requestUrl, json.toString(), true, true, new BaseSuccessFailureCallBeak() { |
| | | @Override |
| | | public void onSuccess(HttpResponsePack httpResponsePack) { |
| | | cloudCallBeak.onSuccess(true); |
| | | if (cloudCallBeak != null) { |
| | | cloudCallBeak.onSuccess(true); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(Exception exception) { |
| | | cloudCallBeak.onFailure(exception); |
| | | if (cloudCallBeak != null) { |
| | | cloudCallBeak.onFailure(exception); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | |
| | | HttpClient.getInstance().requestHttp(requestUrl, json.toString(), true, true, new BaseSuccessFailureCallBeak() { |
| | | @Override |
| | | public void onSuccess(HttpResponsePack httpResponsePack) { |
| | | cloudCallBeak.onSuccess(true); |
| | | if (cloudCallBeak != null) { |
| | | cloudCallBeak.onSuccess(true); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(Exception exception) { |
| | | cloudCallBeak.onFailure(exception); |
| | | if (cloudCallBeak != null) { |
| | | cloudCallBeak.onFailure(exception); |
| | | } |
| | | } |
| | | }); |
| | | |
| | |
| | | HttpClient.getInstance().requestHttp(requestUrl, json.toString(), true, true, new BaseSuccessFailureCallBeak() { |
| | | @Override |
| | | public void onSuccess(HttpResponsePack httpResponsePack) { |
| | | cloudCallBeak.onSuccess(true); |
| | | if (cloudCallBeak != null) { |
| | | cloudCallBeak.onSuccess(true); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(Exception exception) { |
| | | cloudCallBeak.onFailure(exception); |
| | | if (cloudCallBeak != null) { |
| | | cloudCallBeak.onFailure(exception); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | static class HouseInfoBeanClass { |
| | | |
| | | //总条数 |