瀏覽代碼

<配置默认值>

weizhengliang 5 年之前
父節點
當前提交
c71b8f9f78
共有 1 個文件被更改,包括 19 次插入2 次删除
  1. 19 2
      app/src/main/java/com/wdkl/infoboardclassic/manager/PatientInfoManager.java

+ 19 - 2
app/src/main/java/com/wdkl/infoboardclassic/manager/PatientInfoManager.java

@@ -34,6 +34,9 @@ public class PatientInfoManager {
     private List<String> nurseConfigTitleList = new ArrayList<>();
     private List<NurseConfigItem> nurseConfigItemList = new ArrayList<>();
 
+    private int[] titleId = new int[] {R.string.patient_count_title, R.string.discharged_today_title, R.string.discharged_tomorrow_title, R.string.admission_today};
+    private int[] contents = new int[]{0, 0, 0, 0};
+
     private PatientInfoManager(){
     }
 
@@ -49,6 +52,7 @@ public class PatientInfoManager {
     }
 
     public void getPatientInfo() {
+        clearLists();
         OkHttpClient.Builder builder = new OkHttpClient.Builder()
                 .connectTimeout(30, TimeUnit.SECONDS)
                 .writeTimeout(60, TimeUnit.SECONDS)
@@ -89,8 +93,6 @@ public class PatientInfoManager {
     private void parsePatientInfo(List<PatientInfoBean> patients) {
         allPatientInfoItemList.clear();
         if (patients != null) {
-            int[] titleId = new int[] {R.string.patient_count_title, R.string.discharged_today_title, R.string.discharged_tomorrow_title, R.string.admission_today};
-            int[] contents = new int[]{0, 0, 0, 0};
             contents[0] = patients.size();
             for (int i = 0; i < titleId.length; i++) {
                 //住院信息
@@ -103,6 +105,15 @@ public class PatientInfoManager {
     }
 
     public List<AllPatientInfoItem> getAllPatientInfoItemList() {
+        if (allPatientInfoItemList.size() == 0) {
+            //默认值
+            for (int i = 0; i < titleId.length; i++) {
+                AllPatientInfoItem allPatientInfoItem = new AllPatientInfoItem();
+                allPatientInfoItem.setInfoTitle(getString(titleId[i]));
+                allPatientInfoItem.setInfoContent(Integer.toString(contents[i]));
+                allPatientInfoItemList.add(allPatientInfoItem);
+            }
+        }
         return allPatientInfoItemList;
     }
 
@@ -126,4 +137,10 @@ public class PatientInfoManager {
     private String getString(int resId) {
         return BaseApp.getContext().getString(resId);
     }
+
+    private void clearLists() {
+        allPatientInfoItemList.clear();
+        nurseConfigTitleList.clear();
+        nurseConfigItemList.clear();
+    }
 }