Browse Source

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

ilhamitubagoes 4 years ago
parent
commit
125301eaa9

+ 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
     private ScanResultPresenter presenter;
65
     private ScanResultPresenter presenter;
66
     private ScanResultAdapter adapter;
66
     private ScanResultAdapter adapter;
67
     private List<DataProblems> problemsList;
67
     private List<DataProblems> problemsList;
68
+    private String dataUrl;
68
     private String idSite;
69
     private String idSite;
69
     private String idPermit;
70
     private String idPermit;
70
     private String numberRfid;
71
     private String numberRfid;
@@ -148,7 +149,19 @@ public class ScanResultActivity extends BaseActivity implements ScanResultView {
148
     @Override
149
     @Override
149
     public void showDataRfid(DataResultRfid dataResultRfid) {
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
         Glide.with(this)
166
         Glide.with(this)
154
                 .load(dataUrl)
167
                 .load(dataUrl)
@@ -156,27 +169,25 @@ public class ScanResultActivity extends BaseActivity implements ScanResultView {
156
                 .error(R.drawable.ic_profile_default)
169
                 .error(R.drawable.ic_profile_default)
157
                 .into(ivProfileImage);
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
         if (dataResultRfid.getPassed()){
172
         if (dataResultRfid.getPassed()){
165
             tvProfileStatus.setText(R.string.label_status_passed);
173
             tvProfileStatus.setText(R.string.label_status_passed);
166
             llProfileStatus.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
174
             llProfileStatus.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
167
         } else {
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
                 llProfileStatus.setBackgroundColor(getResources().getColor(R.color.colorRedDark));
191
                 llProfileStatus.setBackgroundColor(getResources().getColor(R.color.colorRedDark));
181
             }
192
             }
182
         }
193
         }