|
@@ -11,7 +11,6 @@ import androidx.recyclerview.widget.DividerItemDecoration;
|
11
|
11
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
12
|
12
|
|
13
|
13
|
import com.bumptech.glide.Glide;
|
14
|
|
-import com.fusi24.rfid.MainActivity;
|
15
|
14
|
import com.fusi24.rfid.R;
|
16
|
15
|
import com.fusi24.rfid.adapter.ScanResultAdapter;
|
17
|
16
|
import com.fusi24.rfid.base.BaseActivity;
|
|
@@ -19,6 +18,7 @@ import com.fusi24.rfid.config.Constant;
|
19
|
18
|
import com.fusi24.rfid.data.entity.DataProblems;
|
20
|
19
|
import com.fusi24.rfid.data.entity.DataResultRfid;
|
21
|
20
|
import com.fusi24.rfid.databinding.ActivityScanResultBinding;
|
|
21
|
+import com.fusi24.rfid.ui.home.HomeActivity;
|
22
|
22
|
|
23
|
23
|
import java.util.ArrayList;
|
24
|
24
|
import java.util.List;
|
|
@@ -26,18 +26,16 @@ import java.util.Locale;
|
26
|
26
|
|
27
|
27
|
public class ScanResultActivity extends BaseActivity implements ScanResultView {
|
28
|
28
|
|
29
|
|
- public static final String ID_SITE = "id_site";
|
30
|
|
- public static final String ID_PERMIT = "id_permit";
|
31
|
29
|
public static final String RFID_CARD_NUMBER = "rfid_card_number";
|
|
30
|
+ public static final String ID_PERMIT = "id_permit";
|
|
31
|
+ public static final String ID_DEVICE = "id_device";
|
|
32
|
+ public static final String ID_CHECK_TYPE = "id_check_type";
|
|
33
|
+ public static final String LOCATION = "location";
|
32
|
34
|
|
33
|
35
|
private ScanResultPresenter presenter;
|
34
|
36
|
private ScanResultAdapter adapter;
|
35
|
37
|
private List<DataProblems> problemsList;
|
36
|
|
- private String dataUrl;
|
37
|
|
- private String idSite;
|
38
|
|
- private String idPermit;
|
39
|
|
- private String numberRfid;
|
40
|
|
- private String numberRfidTemp;
|
|
38
|
+ private String dataUrl, numberRfid, numberRfidTemp, idPermit, idDevice, idCheckType, longLat;
|
41
|
39
|
private ActivityScanResultBinding binding;
|
42
|
40
|
|
43
|
41
|
@Override
|
|
@@ -51,19 +49,21 @@ public class ScanResultActivity extends BaseActivity implements ScanResultView {
|
51
|
49
|
getManager(), getAndroidScheduler(), getProcessScheduler());
|
52
|
50
|
presenter.attachView(this);
|
53
|
51
|
|
54
|
|
- if (getIntent() != null){
|
55
|
|
- idSite = getIntent().getStringExtra(ID_SITE);
|
56
|
|
- idPermit = getIntent().getStringExtra(ID_PERMIT);
|
|
52
|
+ if (getIntent() != null) {
|
57
|
53
|
numberRfidTemp = getIntent().getStringExtra(RFID_CARD_NUMBER);
|
|
54
|
+ idPermit = getIntent().getStringExtra(ID_PERMIT);
|
|
55
|
+ idDevice = getIntent().getStringExtra(ID_DEVICE);
|
|
56
|
+ idCheckType = getIntent().getStringExtra(ID_CHECK_TYPE);
|
|
57
|
+ longLat = getIntent().getStringExtra(LOCATION);
|
58
|
58
|
}
|
59
|
59
|
|
60
|
60
|
// Setting digit rfid card using MAX_NUMBER = 10
|
61
|
61
|
/* FORMAT "%010d"
|
62
|
|
- * % ==> used as formatter, 0 ==> used to pad with zeroes instead of spaces
|
63
|
|
- * 10 ==> maximum of 10 characters wide
|
64
|
|
- * d ==> as a decimal integer */
|
65
|
|
- if (numberRfidTemp != null){
|
66
|
|
- if (numberRfidTemp.length() < 10){
|
|
62
|
+ * % ==> used as formatter, 0 ==> used to pad with zeroes instead of spaces
|
|
63
|
+ * 10 ==> maximum of 10 characters wide
|
|
64
|
+ * d ==> as a decimal integer */
|
|
65
|
+ if (numberRfidTemp != null) {
|
|
66
|
+ if (numberRfidTemp.length() < 10) {
|
67
|
67
|
numberRfid = String.format(Locale.getDefault(), "%010d", Integer.valueOf(numberRfidTemp));
|
68
|
68
|
} else {
|
69
|
69
|
numberRfid = numberRfidTemp;
|
|
@@ -76,7 +76,7 @@ public class ScanResultActivity extends BaseActivity implements ScanResultView {
|
76
|
76
|
}
|
77
|
77
|
|
78
|
78
|
@SuppressLint("SetTextI18n")
|
79
|
|
- private void initView(){
|
|
79
|
+ private void initView() {
|
80
|
80
|
binding.tvRfidNumber.setText("Nomor RFID : " + numberRfid);
|
81
|
81
|
|
82
|
82
|
problemsList = new ArrayList<>();
|
|
@@ -89,15 +89,15 @@ public class ScanResultActivity extends BaseActivity implements ScanResultView {
|
89
|
89
|
binding.rvDocumentProblem.setAdapter(adapter);
|
90
|
90
|
}
|
91
|
91
|
|
92
|
|
- private void loadingdata(){
|
|
92
|
+ private void loadingdata() {
|
93
|
93
|
problemsList.clear();
|
94
|
94
|
String[] expand = {"employee.company, employee.structuralPosition, employee.functionalPosition"};
|
95
|
|
- presenter.checkRfidCard(numberRfid, Integer.valueOf(idPermit), Integer.valueOf(idSite), expand);
|
|
95
|
+ presenter.checkRfidCard(numberRfid, Integer.valueOf(idPermit), idDevice, Integer.valueOf(idCheckType), longLat, expand);
|
96
|
96
|
}
|
97
|
97
|
|
98
|
|
- private void initEvent(){
|
|
98
|
+ private void initEvent() {
|
99
|
99
|
binding.btnHome.setOnClickListener(v -> {
|
100
|
|
- final Intent intent = new Intent(this, MainActivity.class);
|
|
100
|
+ final Intent intent = new Intent(this, HomeActivity.class);
|
101
|
101
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
102
|
102
|
startActivity(intent);
|
103
|
103
|
});
|
|
@@ -108,7 +108,7 @@ public class ScanResultActivity extends BaseActivity implements ScanResultView {
|
108
|
108
|
@Override
|
109
|
109
|
public void showDataRfid(DataResultRfid dataResultRfid) {
|
110
|
110
|
|
111
|
|
- if (dataResultRfid.getEmployee() != null){
|
|
111
|
+ if (dataResultRfid.getEmployee() != null) {
|
112
|
112
|
dataUrl = Constant.URL_PHOTO + dataResultRfid.getEmployee().getUrlPhoto().substring(14);
|
113
|
113
|
|
114
|
114
|
binding.tvProfileName.setText(dataResultRfid.getEmployee().getName());
|
|
@@ -128,17 +128,17 @@ public class ScanResultActivity extends BaseActivity implements ScanResultView {
|
128
|
128
|
.error(R.drawable.ic_profile_default)
|
129
|
129
|
.into(binding.ivProfileImage);
|
130
|
130
|
|
131
|
|
- if (dataResultRfid.getPassed()){
|
|
131
|
+ if (dataResultRfid.getPassed()) {
|
132
|
132
|
binding.tvProfileStatus.setText(R.string.label_status_passed);
|
133
|
133
|
binding.llProfileStatus.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
|
134
|
134
|
} else {
|
135
|
|
- if (dataResultRfid.getAlertType() != null){
|
136
|
|
- if (dataResultRfid.getAlertType().equalsIgnoreCase("ERROR")){
|
|
135
|
+ if (dataResultRfid.getAlertType() != null) {
|
|
136
|
+ if (dataResultRfid.getAlertType().equalsIgnoreCase("ERROR")) {
|
137
|
137
|
binding.tvProfileStatus.setText(R.string.label_status_not_passed);
|
138
|
138
|
binding.llProfileStatus.setBackgroundColor(getResources().getColor(R.color.colorRedDark));
|
139
|
139
|
}
|
140
|
140
|
|
141
|
|
- if (dataResultRfid.getAlertType().equalsIgnoreCase("WARNING")){
|
|
141
|
+ if (dataResultRfid.getAlertType().equalsIgnoreCase("WARNING")) {
|
142
|
142
|
binding.tvProfileStatus.setText(R.string.label_status_not_valid);
|
143
|
143
|
binding.llProfileStatus.setBackgroundColor(getResources().getColor(R.color.colorRedDark));
|
144
|
144
|
}
|
|
@@ -149,7 +149,7 @@ public class ScanResultActivity extends BaseActivity implements ScanResultView {
|
149
|
149
|
}
|
150
|
150
|
}
|
151
|
151
|
|
152
|
|
- if (dataResultRfid.getMessage() != null){
|
|
152
|
+ if (dataResultRfid.getMessage() != null) {
|
153
|
153
|
Toast.makeText(this, dataResultRfid.getMessage(), Toast.LENGTH_SHORT).show();
|
154
|
154
|
}
|
155
|
155
|
|