fix unit
This commit is contained in:
parent
c112eec868
commit
e9ef4c44f9
|
@ -1,5 +1,6 @@
|
||||||
package org.foxarmy.barcodescannerforemployees
|
package org.foxarmy.barcodescannerforemployees
|
||||||
|
|
||||||
|
import android.util.Log
|
||||||
import org.foxarmy.barcodescannerforemployees.dataclasses.AbstractProduct
|
import org.foxarmy.barcodescannerforemployees.dataclasses.AbstractProduct
|
||||||
|
|
||||||
class Parser constructor() {
|
class Parser constructor() {
|
||||||
|
@ -34,7 +35,19 @@ class Parser constructor() {
|
||||||
Regex("[0-9]+,?[0-9*]\\s*((шт)|(Шт))")
|
Regex("[0-9]+,?[0-9*]\\s*((шт)|(Шт))")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
var unitNumber = -1
|
||||||
|
val strippedUnit = unit.lowercase().replace(Regex("\\d"), "").strip()
|
||||||
|
unitNumber = when (strippedUnit) {
|
||||||
|
"кг" -> { 0 }
|
||||||
|
"г" -> { 1 }
|
||||||
|
"л" -> { 2 }
|
||||||
|
"мл" -> { 3 }
|
||||||
|
"шт" -> { 4 }
|
||||||
|
|
||||||
return AbstractProduct(0, "", name, netWeight, "", 0, unit)
|
else -> { -1 }
|
||||||
|
}
|
||||||
|
Log.d("QWERTYUIOP", "Unit: ${strippedUnit}, number: ${unitNumber}")
|
||||||
|
|
||||||
|
return AbstractProduct(0, "", name, netWeight, "", 0, unitNumber)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<string name="gram">g</string>
|
|
||||||
<string name="kilogram">kg</string>
|
<string name="kilogram">kg</string>
|
||||||
|
<string name="gram">g</string>
|
||||||
<string name="liter">l</string>
|
<string name="liter">l</string>
|
||||||
<string name="milliliter">ml</string>
|
<string name="milliliter">ml</string>
|
||||||
<string name="pieces">pc</string>
|
<string name="pieces">pc</string>
|
||||||
|
|
Loading…
Reference in New Issue