|
@@ -22,6 +22,7 @@ import com.fusi24.rfid.databinding.ActivityScanResultBinding;
|
22
|
22
|
|
23
|
23
|
import java.util.ArrayList;
|
24
|
24
|
import java.util.List;
|
|
25
|
+import java.util.Locale;
|
25
|
26
|
|
26
|
27
|
public class ScanResultActivity extends BaseActivity implements ScanResultView {
|
27
|
28
|
|
|
@@ -56,27 +57,16 @@ public class ScanResultActivity extends BaseActivity implements ScanResultView {
|
56
|
57
|
numberRfidTemp = getIntent().getStringExtra(RFID_CARD_NUMBER);
|
57
|
58
|
}
|
58
|
59
|
|
59
|
|
- // Setting digit rfid card
|
|
60
|
+ // Setting digit rfid card using MAX_NUMBER = 10
|
|
61
|
+ /* FORMAT "%010d"
|
|
62
|
+ * % ==> used as formatter, 0 ==> used to pad with zeroes instead of spaces
|
|
63
|
+ * 10 ==> minimum of 10 characters wide
|
|
64
|
+ * d ==> as a decimal integer */
|
60
|
65
|
if (numberRfidTemp != null){
|
61
|
|
- switch (numberRfidTemp.length()){
|
62
|
|
- case 5:
|
63
|
|
- numberRfid = "00000" + numberRfidTemp;
|
64
|
|
- break;
|
65
|
|
- case 6:
|
66
|
|
- numberRfid = "0000" + numberRfidTemp;
|
67
|
|
- break;
|
68
|
|
- case 7:
|
69
|
|
- numberRfid = "000" + numberRfidTemp;
|
70
|
|
- break;
|
71
|
|
- case 8:
|
72
|
|
- numberRfid = "00" + numberRfidTemp;
|
73
|
|
- break;
|
74
|
|
- case 9:
|
75
|
|
- numberRfid = "0" + numberRfidTemp;
|
76
|
|
- break;
|
77
|
|
- default:
|
78
|
|
- numberRfid = numberRfidTemp;
|
79
|
|
- break;
|
|
66
|
+ if (numberRfidTemp.length() < 10){
|
|
67
|
+ numberRfid = String.format(Locale.getDefault(), "%010d", Integer.valueOf(numberRfidTemp));
|
|
68
|
+ } else {
|
|
69
|
+ numberRfid = numberRfidTemp;
|
80
|
70
|
}
|
81
|
71
|
}
|
82
|
72
|
|