From 390261037c530be2a59e99a93ed44f6817d0d006 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期一, 12 六月 2023 21:18:58 +0800
Subject: [PATCH] 2023年06月12日21:18:47

---
 app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java |   82 +++++++++++++++++++++++++---------------
 1 files changed, 51 insertions(+), 31 deletions(-)

diff --git a/app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java b/app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java
index ec5a1cf..0a4314e 100644
--- a/app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java
+++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java
@@ -14,10 +14,18 @@
 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) {
@@ -79,22 +87,20 @@
         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().toString());
+                    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);
 
                 }
             }
@@ -102,7 +108,9 @@
 
             @Override
             public void onFailure(Exception exception) {
-                cloudCallBeak.onFailure(exception);
+                if (cloudCallBeak != null) {
+                    cloudCallBeak.onFailure(exception);
+                }
             }
         });
     }
@@ -115,29 +123,28 @@
      * @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().toString());
+                    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);
+                }
             }
         });
 
@@ -152,7 +159,7 @@
      * @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());
@@ -179,13 +186,17 @@
         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);
+                }
             }
         });
     }
@@ -204,13 +215,17 @@
         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);
+                }
             }
         });
 
@@ -250,19 +265,24 @@
         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 {
 
         //鎬绘潯鏁�

--
Gitblit v1.8.0