|
@@ -39,6 +39,7 @@ import com.fusi24.entryPermitScanner.data.entity.DataSite;
|
39
|
39
|
import com.fusi24.entryPermitScanner.databinding.ActivityHomeBinding;
|
40
|
40
|
import com.fusi24.entryPermitScanner.ui.ScanActivity;
|
41
|
41
|
import com.fusi24.entryPermitScanner.ui.setting.SettingActivity;
|
|
42
|
+import com.google.gson.Gson;
|
42
|
43
|
|
43
|
44
|
import java.util.ArrayList;
|
44
|
45
|
import java.util.List;
|
|
@@ -82,6 +83,7 @@ public class HomeActivity extends BaseActivity implements HomeView, StatusScanAd
|
82
|
83
|
initView();
|
83
|
84
|
getDataDeviceId();
|
84
|
85
|
loadingData();
|
|
86
|
+ getDataFromService();
|
85
|
87
|
}
|
86
|
88
|
|
87
|
89
|
@Override
|
|
@@ -118,6 +120,7 @@ public class HomeActivity extends BaseActivity implements HomeView, StatusScanAd
|
118
|
120
|
@Override
|
119
|
121
|
protected void onResume() {
|
120
|
122
|
super.onResume();
|
|
123
|
+ loadingData();
|
121
|
124
|
initEvent();
|
122
|
125
|
}
|
123
|
126
|
|
|
@@ -146,7 +149,26 @@ public class HomeActivity extends BaseActivity implements HomeView, StatusScanAd
|
146
|
149
|
binding.tvRfidGunId.setText(idDevice);
|
147
|
150
|
binding.tvRfidCardNumber.setText(getSessionManager().getUserRfidNumber());
|
148
|
151
|
binding.tvEmployeeName.setText(getSessionManager().getEmployeeName());
|
|
152
|
+ binding.tvGateName.setText(getSessionManager().getGate());
|
|
153
|
+
|
|
154
|
+ if (getSessionManager().getSiteList() != null) {
|
|
155
|
+ siteAdapter.updateSiteList(getSessionManager().getSiteList());
|
|
156
|
+ siteAdapter.notifyDataSetChanged();
|
|
157
|
+ }
|
|
158
|
+
|
|
159
|
+ if (getSessionManager().getPermitList() != null) {
|
|
160
|
+ entryPermitList.clear();
|
|
161
|
+ entryPermitList.addAll(getSessionManager().getPermitList());
|
|
162
|
+ }
|
|
163
|
+ setDataPermit();
|
|
164
|
+
|
|
165
|
+ Gson gson = new Gson();
|
|
166
|
+ System.out.println("Developer Gate : " + gson.toJson(getSessionManager().getGate()));
|
|
167
|
+ System.out.println("Developer Site : " + gson.toJson(getSessionManager().getSiteList()));
|
|
168
|
+ System.out.println("Developer Permit : " + gson.toJson(getSessionManager().getPermitList()));
|
|
169
|
+ }
|
149
|
170
|
|
|
171
|
+ private void getDataFromService(){
|
150
|
172
|
presenter.getEntryPermit();
|
151
|
173
|
presenter.getStatusScan();
|
152
|
174
|
presenter.getDataDevice(idDevice);
|
|
@@ -186,7 +208,7 @@ public class HomeActivity extends BaseActivity implements HomeView, StatusScanAd
|
186
|
208
|
startActivity(intent);
|
187
|
209
|
});
|
188
|
210
|
|
189
|
|
- binding.refresh.setOnRefreshListener(this::loadingData);
|
|
211
|
+ binding.refresh.setOnRefreshListener(this::getDataFromService);
|
190
|
212
|
|
191
|
213
|
}
|
192
|
214
|
|
|
@@ -198,10 +220,8 @@ public class HomeActivity extends BaseActivity implements HomeView, StatusScanAd
|
198
|
220
|
|
199
|
221
|
@Override
|
200
|
222
|
public void showDataPermit(List<DataEntryPermit> dataEntryPermitList) {
|
|
223
|
+ binding.refresh.setRefreshing(false);
|
201
|
224
|
getSessionManager().setPermitList(dataEntryPermitList);
|
202
|
|
- entryPermitList.clear();
|
203
|
|
- entryPermitList.addAll(getSessionManager().getPermitList());
|
204
|
|
- setDataPermit();
|
205
|
225
|
}
|
206
|
226
|
|
207
|
227
|
@Override
|
|
@@ -216,11 +236,19 @@ public class HomeActivity extends BaseActivity implements HomeView, StatusScanAd
|
216
|
236
|
|
217
|
237
|
@Override
|
218
|
238
|
public void showDataDevice(List<DataDevice> dataDevices) {
|
219
|
|
- getSessionManager().setGate(dataDevices.get(0).getGate().getName());
|
220
|
|
- getSessionManager().setSiteList(Stream.of(dataDevices.get(0).getGate().getSites()).filter(DataSite::getActive).sortBy(DataSite::getId).toList());
|
221
|
|
- binding.tvGateName.setText(getSessionManager().getGate());
|
222
|
|
- siteAdapter.updateSiteList(getSessionManager().getSiteList());
|
223
|
|
- siteAdapter.notifyDataSetChanged();
|
|
239
|
+ // If data empty clear session
|
|
240
|
+ if (dataDevices.isEmpty()){
|
|
241
|
+ List<DataSite> siteList = new ArrayList<>();
|
|
242
|
+ getSessionManager().setSiteList(siteList);
|
|
243
|
+ getSessionManager().setGate("");
|
|
244
|
+ } else {
|
|
245
|
+ getSessionManager().setGate(dataDevices.get(0).getGate().getName()); // Data Gate
|
|
246
|
+ getSessionManager().setSiteList(Stream.of(dataDevices.get(0).getGate().getSites()) // Data Site
|
|
247
|
+ .filter(DataSite::getActive)
|
|
248
|
+ .sortBy(DataSite::getId).toList());
|
|
249
|
+ }
|
|
250
|
+ binding.refresh.setRefreshing(false);
|
|
251
|
+ loadingData();
|
224
|
252
|
}
|
225
|
253
|
|
226
|
254
|
private void setDataPermit(){
|
|
@@ -239,7 +267,6 @@ public class HomeActivity extends BaseActivity implements HomeView, StatusScanAd
|
239
|
267
|
}
|
240
|
268
|
|
241
|
269
|
// Inisiasi pertama saat muncul halaman default true
|
242
|
|
- binding.swStatusScan.setOn(true);
|
243
|
270
|
idCheckType = statusScanList.get(0).getId(); // <-- Check In Code (649)
|
244
|
271
|
checkTypeName = statusScanList.get(0).getName(); // <-- Check In Name
|
245
|
272
|
|