From 60aa1973b1345ac15353ab1e2efbc39c0b610aa2 Mon Sep 17 00:00:00 2001 From: leca Date: Sun, 20 Oct 2024 17:14:32 +0300 Subject: [PATCH] fixed parser behaviour on null net weight --- .../java/org/foxarmy/barcodescannerforemployees/Parser.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/foxarmy/barcodescannerforemployees/Parser.kt b/app/src/main/java/org/foxarmy/barcodescannerforemployees/Parser.kt index e046688..91c2f68 100644 --- a/app/src/main/java/org/foxarmy/barcodescannerforemployees/Parser.kt +++ b/app/src/main/java/org/foxarmy/barcodescannerforemployees/Parser.kt @@ -13,8 +13,9 @@ class Parser constructor() { val found = foundByRegex.groupValues[0] text = text.replace(found, "") netWeight = stripNetWeight(found) -// } return Triple(text, netWeight, found) + } else { + return Triple(text, 0.0, "") } } return Triple("", 0.0, "") @@ -40,7 +41,9 @@ class Parser constructor() { "мл" -> { 3 } "шт" -> { 4 } - else -> { -1 } + else -> { + 4 + } } return AbstractProduct(0, "", name, netWeight, "", 0, unitNumber)