diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt index 9b2a24b6..1bdc573a 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt @@ -10,6 +10,7 @@ import android.os.Build import android.os.Bundle import android.os.Parcelable import android.text.InputType +import android.text.InputType.TYPE_CLASS_NUMBER import android.text.InputType.TYPE_CLASS_TEXT import android.util.Log.d import android.view.KeyEvent @@ -48,6 +49,7 @@ import es.verdnatura.presentation.view.feature.collection.adapter.SaleAdapter import es.verdnatura.presentation.view.feature.main.activity.MainActivity import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO import es.verdnatura.presentation.view.feature.sacador.model.* +import org.json.JSONObject @Suppress("UNUSED_ANONYMOUS_PARAMETER") @@ -266,8 +268,16 @@ class CollectionFragment( } - private fun showPrevia() { + private fun markPrevia(saleGroupScanned: String) { + sales.forEachIndexed { pos, s -> + if (!s.saleGroupFk.isNullOrEmpty() && s.saleGroupFk == saleGroupScanned) { + markLine(pos, type) + } + } + } + private fun showPrevia() { + customDialogList.getEditText().setRawInputType(TYPE_CLASS_NUMBER) customDialogList.setTitle(getString(R.string.scanPreviousTicket)) .setOkButton(getString(R.string.end)) { ma.hideKeyboard(customDialogList.getEditText()) @@ -283,12 +293,7 @@ class CollectionFragment( if (!customDialogList.getValue().isEmpty()) { ma.hideKeyboard(customDialogList.getEditText()) var saleGroupScanned = customDialogList.getValue() - sales.forEachIndexed { pos, s -> - if (!s.saleGroupFk.isNullOrEmpty() && s.saleGroupFk == saleGroupScanned) { - markLine(pos, type) - } - } - + markPrevia(saleGroupScanned) customDialogList.dismiss() } customDialogList.setValue("") @@ -356,14 +361,18 @@ class CollectionFragment( //de momento solo está el qr de artículo isScanned = event != null && event.action == ACTION_DOWN && event.keyCode == KeyEvent.KEYCODE_ENTER - var myItem = try { - itemScanValue( - binding.scanInput.text.toString(), - "buy", - "more" - ).toString() - } catch (ex: Exception) { - binding.scanInput.text.toString() + + if (itemScanIsQr(binding.scanInput.text.toString())) { + var myQr = itemScanned(JSONObject(binding.scanInput.text.toString())) + when (myQr.table) { + "saleGroup" -> { + markPrevia(myQr.id.toString()) + } + "buy" -> binding.scanInput.setText(myQr.more) + + } + } else { + findSale(binding.scanInput.text.toString()) } buttonPushedGetCollection = false