feat qr #refs 7520

This commit is contained in:
Sergio De la torre 2024-06-18 12:30:27 +02:00
parent cc8e8aa2b3
commit 95c02274d8
1 changed files with 15 additions and 1 deletions

View File

@ -10,6 +10,7 @@ import es.verdnatura.domain.toast
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnBarcodeRowClickListener
import es.verdnatura.presentation.common.hideKeyboard
import es.verdnatura.presentation.common.itemScanValue
import es.verdnatura.presentation.view.feature.articulo.model.BarcodeVO
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
import es.verdnatura.presentation.view.feature.parking.adapter.ParkingAdapter
@ -49,7 +50,19 @@ class ParkingFragment(var menuOrigin: String) :
binding.scanInput.setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
if (!binding.scanInput.text.isNullOrEmpty()) {
checkScan(binding.scanInput.text.toString())
try {
checkScan(
itemScanValue(
binding.scanInput.text.toString(),
arrayOf("ticket", "saleGroup"),
"id"
).toString()
)
} catch (ex: Exception) {
ex.toast(requireContext())
}
}
binding.scanInput.setText("")
requireActivity().hideKeyboard()
@ -107,6 +120,7 @@ class ParkingFragment(var menuOrigin: String) :
}
private fun checkScan(txtScan: String) {
println("txtScan $txtScan")
var isParking = false
if (txtScan.trim().length == 4 && isLetter(txtScan.substring(txtScan.length - 1)) || txtScan.contains(
"-"