fixed negative percents of freshness

This commit is contained in:
leca 2024-10-19 18:03:52 +03:00
parent 244ef95a99
commit cba0e8594f
1 changed files with 1 additions and 1 deletions

View File

@ -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)}%"