|
@@ -3,15 +3,12 @@ package com.fusi24.rfid.ui.scanresult;
|
3
|
3
|
import android.annotation.SuppressLint;
|
4
|
4
|
import android.content.Intent;
|
5
|
5
|
import android.os.Bundle;
|
6
|
|
-import android.widget.Button;
|
7
|
|
-import android.widget.LinearLayout;
|
8
|
|
-import android.widget.TextView;
|
|
6
|
+import android.view.View;
|
9
|
7
|
import android.widget.Toast;
|
10
|
8
|
|
11
|
9
|
import androidx.recyclerview.widget.DefaultItemAnimator;
|
12
|
10
|
import androidx.recyclerview.widget.DividerItemDecoration;
|
13
|
11
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
14
|
|
-import androidx.recyclerview.widget.RecyclerView;
|
15
|
12
|
|
16
|
13
|
import com.bumptech.glide.Glide;
|
17
|
14
|
import com.fusi24.rfid.MainActivity;
|
|
@@ -21,47 +18,17 @@ import com.fusi24.rfid.base.BaseActivity;
|
21
|
18
|
import com.fusi24.rfid.config.Constant;
|
22
|
19
|
import com.fusi24.rfid.data.entity.DataProblems;
|
23
|
20
|
import com.fusi24.rfid.data.entity.DataResultRfid;
|
|
21
|
+import com.fusi24.rfid.databinding.ActivityScanResultBinding;
|
24
|
22
|
|
25
|
23
|
import java.util.ArrayList;
|
26
|
24
|
import java.util.List;
|
27
|
25
|
|
28
|
|
-import butterknife.BindView;
|
29
|
|
-import butterknife.ButterKnife;
|
30
|
|
-import de.hdodenhof.circleimageview.CircleImageView;
|
31
|
|
-
|
32
|
26
|
public class ScanResultActivity extends BaseActivity implements ScanResultView {
|
33
|
27
|
|
34
|
28
|
public static final String ID_SITE = "id_site";
|
35
|
29
|
public static final String ID_PERMIT = "id_permit";
|
36
|
30
|
public static final String RFID_CARD_NUMBER = "rfid_card_number";
|
37
|
31
|
|
38
|
|
- @BindView(R.id.tv_rfid_number)
|
39
|
|
- TextView tvRfidNumber;
|
40
|
|
-
|
41
|
|
- @BindView(R.id.iv_profile_image)
|
42
|
|
- CircleImageView ivProfileImage;
|
43
|
|
- @BindView(R.id.tv_profile_name)
|
44
|
|
- TextView tvProfileName;
|
45
|
|
- @BindView(R.id.tv_structural_position)
|
46
|
|
- TextView tvStructuralPosition;
|
47
|
|
- @BindView(R.id.tv_functional_position)
|
48
|
|
- TextView tvFunctionalPosition;
|
49
|
|
- @BindView(R.id.tv_company_name)
|
50
|
|
- TextView tvCompanyName;
|
51
|
|
-
|
52
|
|
- @BindView(R.id.ll_profile_status)
|
53
|
|
- LinearLayout llProfileStatus;
|
54
|
|
- @BindView(R.id.tv_profile_status)
|
55
|
|
- TextView tvProfileStatus;
|
56
|
|
-
|
57
|
|
- @BindView(R.id.rv_document_problem)
|
58
|
|
- RecyclerView rvDocumentProblem;
|
59
|
|
-
|
60
|
|
- @BindView(R.id.btn_home)
|
61
|
|
- Button btnHome;
|
62
|
|
- @BindView(R.id.btn_scan_again)
|
63
|
|
- Button btnScanAgain;
|
64
|
|
-
|
65
|
32
|
private ScanResultPresenter presenter;
|
66
|
33
|
private ScanResultAdapter adapter;
|
67
|
34
|
private List<DataProblems> problemsList;
|
|
@@ -70,12 +37,14 @@ public class ScanResultActivity extends BaseActivity implements ScanResultView {
|
70
|
37
|
private String idPermit;
|
71
|
38
|
private String numberRfid;
|
72
|
39
|
private String numberRfidTemp;
|
|
40
|
+ private ActivityScanResultBinding binding;
|
73
|
41
|
|
74
|
42
|
@Override
|
75
|
43
|
protected void onCreate(Bundle savedInstanceState) {
|
76
|
44
|
super.onCreate(savedInstanceState);
|
77
|
|
- setContentView(R.layout.activity_scan_result);
|
78
|
|
- ButterKnife.bind(this);
|
|
45
|
+ binding = ActivityScanResultBinding.inflate(getLayoutInflater());
|
|
46
|
+ View view = binding.getRoot();
|
|
47
|
+ setContentView(view);
|
79
|
48
|
|
80
|
49
|
presenter = new ScanResultPresenter(
|
81
|
50
|
getManager(), getAndroidScheduler(), getProcessScheduler());
|
|
@@ -118,16 +87,16 @@ public class ScanResultActivity extends BaseActivity implements ScanResultView {
|
118
|
87
|
|
119
|
88
|
@SuppressLint("SetTextI18n")
|
120
|
89
|
private void initView(){
|
121
|
|
- tvRfidNumber.setText("Nomor RFID : " + numberRfid);
|
|
90
|
+ binding.tvRfidNumber.setText("Nomor RFID : " + numberRfid);
|
122
|
91
|
|
123
|
92
|
problemsList = new ArrayList<>();
|
124
|
93
|
adapter = new ScanResultAdapter(this);
|
125
|
94
|
|
126
|
95
|
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
|
127
|
|
- rvDocumentProblem.setLayoutManager(layoutManager);
|
128
|
|
- rvDocumentProblem.setItemAnimator(new DefaultItemAnimator());
|
129
|
|
- rvDocumentProblem.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
|
130
|
|
- rvDocumentProblem.setAdapter(adapter);
|
|
96
|
+ binding.rvDocumentProblem.setLayoutManager(layoutManager);
|
|
97
|
+ binding.rvDocumentProblem.setItemAnimator(new DefaultItemAnimator());
|
|
98
|
+ binding.rvDocumentProblem.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
|
|
99
|
+ binding.rvDocumentProblem.setAdapter(adapter);
|
131
|
100
|
}
|
132
|
101
|
|
133
|
102
|
private void loadingdata(){
|
|
@@ -137,13 +106,13 @@ public class ScanResultActivity extends BaseActivity implements ScanResultView {
|
137
|
106
|
}
|
138
|
107
|
|
139
|
108
|
private void initEvent(){
|
140
|
|
- btnHome.setOnClickListener(v -> {
|
|
109
|
+ binding.btnHome.setOnClickListener(v -> {
|
141
|
110
|
final Intent intent = new Intent(this, MainActivity.class);
|
142
|
111
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
143
|
112
|
startActivity(intent);
|
144
|
113
|
});
|
145
|
114
|
|
146
|
|
- btnScanAgain.setOnClickListener(v -> finish());
|
|
115
|
+ binding.btnScanAgain.setOnClickListener(v -> finish());
|
147
|
116
|
}
|
148
|
117
|
|
149
|
118
|
@Override
|
|
@@ -152,43 +121,41 @@ public class ScanResultActivity extends BaseActivity implements ScanResultView {
|
152
|
121
|
if (dataResultRfid.getEmployee() != null){
|
153
|
122
|
dataUrl = Constant.URL_PHOTO + dataResultRfid.getEmployee().getUrlPhoto().substring(14);
|
154
|
123
|
|
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());
|
|
124
|
+ binding.tvProfileName.setText(dataResultRfid.getEmployee().getName());
|
|
125
|
+ binding.tvStructuralPosition.setText(dataResultRfid.getEmployee().getStructuralPosition().getName());
|
|
126
|
+ binding.tvFunctionalPosition.setText(dataResultRfid.getEmployee().getFunctionalPosition().getName());
|
|
127
|
+ binding.tvCompanyName.setText(dataResultRfid.getEmployee().getCompany().getName());
|
159
|
128
|
} else {
|
160
|
|
- tvProfileName.setText("-");
|
161
|
|
- tvStructuralPosition.setText("-");
|
162
|
|
- tvFunctionalPosition.setText("-");
|
163
|
|
- tvCompanyName.setText("-");
|
|
129
|
+ binding.tvProfileName.setText("-");
|
|
130
|
+ binding.tvStructuralPosition.setText("-");
|
|
131
|
+ binding.tvFunctionalPosition.setText("-");
|
|
132
|
+ binding.tvCompanyName.setText("-");
|
164
|
133
|
}
|
165
|
134
|
|
166
|
135
|
Glide.with(this)
|
167
|
136
|
.load(dataUrl)
|
168
|
137
|
.placeholder(R.drawable.ic_profile_default)
|
169
|
138
|
.error(R.drawable.ic_profile_default)
|
170
|
|
- .into(ivProfileImage);
|
|
139
|
+ .into(binding.ivProfileImage);
|
171
|
140
|
|
172
|
141
|
if (dataResultRfid.getPassed()){
|
173
|
|
- tvProfileStatus.setText(R.string.label_status_passed);
|
174
|
|
- llProfileStatus.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
|
|
142
|
+ binding.tvProfileStatus.setText(R.string.label_status_passed);
|
|
143
|
+ binding.llProfileStatus.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
|
175
|
144
|
} else {
|
176
|
|
-
|
177
|
145
|
if (dataResultRfid.getAlertType() != null){
|
178
|
|
-
|
179
|
146
|
if (dataResultRfid.getAlertType().equalsIgnoreCase("ERROR")){
|
180
|
|
- tvProfileStatus.setText(R.string.label_status_not_passed);
|
181
|
|
- llProfileStatus.setBackgroundColor(getResources().getColor(R.color.colorRedDark));
|
|
147
|
+ binding.tvProfileStatus.setText(R.string.label_status_not_passed);
|
|
148
|
+ binding.llProfileStatus.setBackgroundColor(getResources().getColor(R.color.colorRedDark));
|
182
|
149
|
}
|
183
|
150
|
|
184
|
151
|
if (dataResultRfid.getAlertType().equalsIgnoreCase("WARNING")){
|
185
|
|
- tvProfileStatus.setText(R.string.label_status_not_valid);
|
186
|
|
- llProfileStatus.setBackgroundColor(getResources().getColor(R.color.colorRedDark));
|
|
152
|
+ binding.tvProfileStatus.setText(R.string.label_status_not_valid);
|
|
153
|
+ binding.llProfileStatus.setBackgroundColor(getResources().getColor(R.color.colorRedDark));
|
187
|
154
|
}
|
188
|
155
|
|
189
|
156
|
} else {
|
190
|
|
- tvProfileStatus.setText(R.string.label_status_not_passed);
|
191
|
|
- llProfileStatus.setBackgroundColor(getResources().getColor(R.color.colorRedDark));
|
|
157
|
+ binding.tvProfileStatus.setText(R.string.label_status_not_passed);
|
|
158
|
+ binding.llProfileStatus.setBackgroundColor(getResources().getColor(R.color.colorRedDark));
|
192
|
159
|
}
|
193
|
160
|
}
|
194
|
161
|
|
|
@@ -210,5 +177,6 @@ public class ScanResultActivity extends BaseActivity implements ScanResultView {
|
210
|
177
|
protected void onDestroy() {
|
211
|
178
|
super.onDestroy();
|
212
|
179
|
presenter.detachView();
|
|
180
|
+ binding = null;
|
213
|
181
|
}
|
214
|
182
|
}
|