瀏覽代碼

-fixing null when get data alert type
-fixing null when get data employee

ilhamitubagoes 4 年之前
父節點
當前提交
125301eaa9
共有 1 個文件被更改,包括 27 次插入16 次删除
  1. 27 16
      app/src/main/java/com/fusi24/rfid/ui/scanresult/ScanResultActivity.java

+ 27 - 16
app/src/main/java/com/fusi24/rfid/ui/scanresult/ScanResultActivity.java

@@ -65,6 +65,7 @@ public class ScanResultActivity extends BaseActivity implements ScanResultView {
65 65
     private ScanResultPresenter presenter;
66 66
     private ScanResultAdapter adapter;
67 67
     private List<DataProblems> problemsList;
68
+    private String dataUrl;
68 69
     private String idSite;
69 70
     private String idPermit;
70 71
     private String numberRfid;
@@ -148,7 +149,19 @@ public class ScanResultActivity extends BaseActivity implements ScanResultView {
148 149
     @Override
149 150
     public void showDataRfid(DataResultRfid dataResultRfid) {
150 151
 
151
-        String dataUrl = Constant.URL_PHOTO + dataResultRfid.getEmployee().getUrlPhoto().substring(14);
152
+        if (dataResultRfid.getEmployee() != null){
153
+            dataUrl = Constant.URL_PHOTO + dataResultRfid.getEmployee().getUrlPhoto().substring(14);
154
+
155
+            tvProfileName.setText(dataResultRfid.getEmployee().getName());
156
+            tvStructuralPosition.setText(dataResultRfid.getEmployee().getStructuralPosition().getName());
157
+            tvFunctionalPosition.setText(dataResultRfid.getEmployee().getFunctionalPosition().getName());
158
+            tvCompanyName.setText(dataResultRfid.getEmployee().getCompany().getName());
159
+        } else {
160
+            tvProfileName.setText("-");
161
+            tvStructuralPosition.setText("-");
162
+            tvFunctionalPosition.setText("-");
163
+            tvCompanyName.setText("-");
164
+        }
152 165
 
153 166
         Glide.with(this)
154 167
                 .load(dataUrl)
@@ -156,27 +169,25 @@ public class ScanResultActivity extends BaseActivity implements ScanResultView {
156 169
                 .error(R.drawable.ic_profile_default)
157 170
                 .into(ivProfileImage);
158 171
 
159
-        tvProfileName.setText(dataResultRfid.getEmployee().getName());
160
-        tvStructuralPosition.setText(dataResultRfid.getEmployee().getStructuralPosition().getName());
161
-        tvFunctionalPosition.setText(dataResultRfid.getEmployee().getFunctionalPosition().getName());
162
-        tvCompanyName.setText(dataResultRfid.getEmployee().getCompany().getName());
163
-
164 172
         if (dataResultRfid.getPassed()){
165 173
             tvProfileStatus.setText(R.string.label_status_passed);
166 174
             llProfileStatus.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
167 175
         } else {
168
-            if (dataResultRfid.getAlertType() == null){
169
-                tvProfileStatus.setText(R.string.label_status_not_passed);
170
-                llProfileStatus.setBackgroundColor(getResources().getColor(R.color.colorRedDark));
171
-            }
172 176
 
173
-            if (dataResultRfid.getAlertType().equalsIgnoreCase("ERROR")){
174
-                tvProfileStatus.setText(R.string.label_status_not_passed);
175
-                llProfileStatus.setBackgroundColor(getResources().getColor(R.color.colorRedDark));
176
-            }
177
+            if (dataResultRfid.getAlertType() != null){
177 178
 
178
-            if (dataResultRfid.getAlertType().equalsIgnoreCase("WARNING")){
179
-                tvProfileStatus.setText(R.string.label_status_not_valid);
179
+                if (dataResultRfid.getAlertType().equalsIgnoreCase("ERROR")){
180
+                    tvProfileStatus.setText(R.string.label_status_not_passed);
181
+                    llProfileStatus.setBackgroundColor(getResources().getColor(R.color.colorRedDark));
182
+                }
183
+
184
+                if (dataResultRfid.getAlertType().equalsIgnoreCase("WARNING")){
185
+                    tvProfileStatus.setText(R.string.label_status_not_valid);
186
+                    llProfileStatus.setBackgroundColor(getResources().getColor(R.color.colorRedDark));
187
+                }
188
+
189
+            } else {
190
+                tvProfileStatus.setText(R.string.label_status_not_passed);
180 191
                 llProfileStatus.setBackgroundColor(getResources().getColor(R.color.colorRedDark));
181 192
             }
182 193
         }