From cba0e8594f3e730c96f9b1d37e812fa498efd665 Mon Sep 17 00:00:00 2001 From: leca Date: Sat, 19 Oct 2024 18:03:52 +0300 Subject: [PATCH] fixed negative percents of freshness --- .../org/foxarmy/barcodescannerforemployees/views/ProductView.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/org/foxarmy/barcodescannerforemployees/views/ProductView.kt b/app/src/main/java/org/foxarmy/barcodescannerforemployees/views/ProductView.kt index 1e88960..936784e 100644 --- a/app/src/main/java/org/foxarmy/barcodescannerforemployees/views/ProductView.kt +++ b/app/src/main/java/org/foxarmy/barcodescannerforemployees/views/ProductView.kt @@ -103,7 +103,7 @@ class ProductView: LinearLayout { productCategoryView.text = DBStorageController(activity).getCategoryNameById(DBStorageController(activity).readableDatabase, linkedAbstractProduct.category) productLifeSpan.text = "${SimpleDateFormat("dd.MM.yyyy").format(Date(product.dateOfProduction*1000))}-${SimpleDateFormat("dd.MM.yyyy").format(Date(product.dateOfExpiry*1000))}" productFreshnessTextView.text = - if (product.freshness == Double.NEGATIVE_INFINITY || product.freshness == Double.POSITIVE_INFINITY) { + if (product.freshness == Double.NEGATIVE_INFINITY || product.freshness == Double.POSITIVE_INFINITY || product.freshness < 0) { "Expired" } else { "${DecimalFormat("#.#").format(product.freshness*100)}%"