|
@@ -1,4 +1,4 @@
|
1
|
|
-package com.fusi24.rfid;
|
|
1
|
+package com.fusi24.rfid.ui.home;
|
2
|
2
|
|
3
|
3
|
import android.annotation.SuppressLint;
|
4
|
4
|
import android.content.Intent;
|
|
@@ -9,14 +9,18 @@ import android.view.MenuItem;
|
9
|
9
|
import android.view.View;
|
10
|
10
|
import android.widget.AdapterView;
|
11
|
11
|
import android.widget.ArrayAdapter;
|
12
|
|
-import android.widget.LinearLayout;
|
13
|
|
-import android.widget.RadioButton;
|
14
|
12
|
import android.widget.TextView;
|
15
|
13
|
import android.widget.Toast;
|
16
|
14
|
|
17
|
15
|
import androidx.annotation.NonNull;
|
18
|
16
|
import androidx.appcompat.widget.Toolbar;
|
|
17
|
+import androidx.recyclerview.widget.DefaultItemAnimator;
|
|
18
|
+import androidx.recyclerview.widget.LinearLayoutManager;
|
19
|
19
|
|
|
20
|
+import com.fusi24.rfid.BuildConfig;
|
|
21
|
+import com.fusi24.rfid.R;
|
|
22
|
+import com.fusi24.rfid.SplashScreenActivity;
|
|
23
|
+import com.fusi24.rfid.adapter.StatusScanAdapter;
|
20
|
24
|
import com.fusi24.rfid.base.BaseActivity;
|
21
|
25
|
import com.fusi24.rfid.config.Constant;
|
22
|
26
|
import com.fusi24.rfid.data.api.RestService;
|
|
@@ -36,15 +40,14 @@ import retrofit2.Callback;
|
36
|
40
|
import retrofit2.Response;
|
37
|
41
|
import timber.log.Timber;
|
38
|
42
|
|
39
|
|
-public class HomeActivity extends BaseActivity implements View.OnClickListener {
|
|
43
|
+public class HomeActivity extends BaseActivity implements StatusScanAdapter.OnItemSelected {
|
40
|
44
|
|
41
|
45
|
private DataEntryPermit dataEntryPermit;
|
42
|
46
|
private List<DataEntryPermit> entryPermitList;
|
43
|
47
|
private List<DataDetail> statusScanList;
|
44
|
48
|
private ActivityHomeBinding binding;
|
45
|
|
- Toolbar toolbar;
|
46
|
|
- TextView toolbarTitle;
|
47
|
|
- RadioButton rb;
|
|
49
|
+ private StatusScanAdapter adapter;
|
|
50
|
+ private Integer idStatus = null;
|
48
|
51
|
|
49
|
52
|
@Override
|
50
|
53
|
protected void onCreate(Bundle savedInstanceState) {
|
|
@@ -53,10 +56,10 @@ public class HomeActivity extends BaseActivity implements View.OnClickListener {
|
53
|
56
|
View view = binding.getRoot();
|
54
|
57
|
setContentView(view);
|
55
|
58
|
|
56
|
|
- toolbar = findViewById(R.id.toolbar);
|
57
|
|
- toolbarTitle = findViewById(R.id.toolbar_text);
|
|
59
|
+ Toolbar toolbar = findViewById(R.id.toolbar);
|
|
60
|
+ TextView toolbarTitle = findViewById(R.id.toolbar_text);
|
58
|
61
|
|
59
|
|
- if(toolbarTitle!=null && toolbar!=null) {
|
|
62
|
+ if(toolbarTitle !=null && toolbar !=null) {
|
60
|
63
|
toolbarTitle.setText(getString(R.string.app_name));
|
61
|
64
|
setSupportActionBar(toolbar);
|
62
|
65
|
}
|
|
@@ -65,10 +68,8 @@ public class HomeActivity extends BaseActivity implements View.OnClickListener {
|
65
|
68
|
getSupportActionBar().setDisplayShowTitleEnabled(false);
|
66
|
69
|
}
|
67
|
70
|
|
68
|
|
- entryPermitList = new ArrayList<>();
|
69
|
|
- statusScanList = new ArrayList<>();
|
70
|
|
-
|
71
|
71
|
initView();
|
|
72
|
+ loadingData();
|
72
|
73
|
getDataPermit();
|
73
|
74
|
getDataStatusScan();
|
74
|
75
|
}
|
|
@@ -105,8 +106,18 @@ public class HomeActivity extends BaseActivity implements View.OnClickListener {
|
105
|
106
|
initEvent();
|
106
|
107
|
}
|
107
|
108
|
|
108
|
|
- @SuppressLint("SetTextI18n")
|
109
|
109
|
private void initView(){
|
|
110
|
+ entryPermitList = new ArrayList<>();
|
|
111
|
+ statusScanList = new ArrayList<>();
|
|
112
|
+
|
|
113
|
+ adapter = new StatusScanAdapter(this, this);
|
|
114
|
+ binding.rvStatusScan.setLayoutManager(new LinearLayoutManager(this));
|
|
115
|
+ binding.rvStatusScan.setItemAnimator(new DefaultItemAnimator());
|
|
116
|
+ binding.rvStatusScan.setAdapter(adapter);
|
|
117
|
+ }
|
|
118
|
+
|
|
119
|
+ @SuppressLint("SetTextI18n")
|
|
120
|
+ private void loadingData(){
|
110
|
121
|
binding.tvRfidGunId.setText("RFID-" + Build.ID + "-" + Build.DEVICE);
|
111
|
122
|
binding.tvRfidCardNumber.setText(getSessionManager().getUserRfidNumber());
|
112
|
123
|
binding.tvEmployeeName.setText(getSessionManager().getEmployeeName());
|
|
@@ -136,13 +147,16 @@ public class HomeActivity extends BaseActivity implements View.OnClickListener {
|
136
|
147
|
return;
|
137
|
148
|
}
|
138
|
149
|
|
|
150
|
+ if (idStatus == null){
|
|
151
|
+ Toast.makeText(this, "Status Scan Belum Terpilih", Toast.LENGTH_SHORT).show();
|
|
152
|
+ return;
|
|
153
|
+ }
|
|
154
|
+
|
139
|
155
|
Intent intent = new Intent(this, ScanActivity.class);
|
140
|
156
|
intent.putExtra(ScanActivity.ID_PERMIT, String.valueOf(dataEntryPermit.getId()));
|
141
|
157
|
startActivity(intent);
|
142
|
158
|
});
|
143
|
159
|
|
144
|
|
- binding.rgStatusScan.setOnCheckedChangeListener((group, checkedId) -> Timber.i("DEVELOPER : %s", checkedId));
|
145
|
|
-
|
146
|
160
|
}
|
147
|
161
|
|
148
|
162
|
private void getDataPermit() {
|
|
@@ -173,7 +187,8 @@ public class HomeActivity extends BaseActivity implements View.OnClickListener {
|
173
|
187
|
public void onResponse(@NotNull Call<List<DataDetail>> call, @NotNull Response<List<DataDetail>> response) {
|
174
|
188
|
if (response.body() != null){
|
175
|
189
|
statusScanList.addAll(response.body());
|
176
|
|
- setDataStatusScan();
|
|
190
|
+ adapter.updateDetailList(statusScanList);
|
|
191
|
+ adapter.notifyDataSetChanged();
|
177
|
192
|
}
|
178
|
193
|
}
|
179
|
194
|
|
|
@@ -190,17 +205,6 @@ public class HomeActivity extends BaseActivity implements View.OnClickListener {
|
190
|
205
|
binding.spinnerPermit.setAdapter(adapter);
|
191
|
206
|
}
|
192
|
207
|
|
193
|
|
- private void setDataStatusScan(){
|
194
|
|
- binding.rgStatusScan.setOrientation(LinearLayout.VERTICAL);
|
195
|
|
- for (int i=0; i<statusScanList.size(); i++){
|
196
|
|
- rb = new RadioButton(this);
|
197
|
|
- rb.setId(View.generateViewId());
|
198
|
|
- rb.setText(statusScanList.get(i).getName());
|
199
|
|
- rb.setOnClickListener(this);
|
200
|
|
- binding.rgStatusScan.addView(rb);
|
201
|
|
- }
|
202
|
|
- }
|
203
|
|
-
|
204
|
208
|
@Override
|
205
|
209
|
protected void onDestroy() {
|
206
|
210
|
super.onDestroy();
|
|
@@ -208,12 +212,9 @@ public class HomeActivity extends BaseActivity implements View.OnClickListener {
|
208
|
212
|
}
|
209
|
213
|
|
210
|
214
|
@Override
|
211
|
|
- public void onClick(View v) {
|
212
|
|
-
|
213
|
|
- rb.setOnClickListener(v1 -> {
|
214
|
|
- Timber.i("DEVELOPER RB : %s", v1.getId());
|
215
|
|
- });
|
216
|
|
-
|
217
|
|
- Timber.tag(HomeActivity.class.getName()).d("DEVELOPER : Name " + ((RadioButton) v).getText() + " Id is " + v.getId());
|
|
215
|
+ public void onSelected(Integer idStatus) {
|
|
216
|
+ this.idStatus = idStatus;
|
|
217
|
+ Timber.tag(HomeActivity.class.getName()).d("DEVELOPER idStatus : %s", idStatus);
|
|
218
|
+ Toast.makeText(this, idStatus.toString(), Toast.LENGTH_SHORT).show();
|
218
|
219
|
}
|
219
|
220
|
}
|