fixed adding months to product
This commit is contained in:
parent
4e11a7b4b9
commit
b1b987e5f6
|
@ -79,7 +79,5 @@ fun calculateProductFreshness(dateOfProduction: Long, dateOfExpiry: Long): Doubl
|
|||
val productLifeSpan = dateOfExpiry - dateOfProduction;
|
||||
val lifeSpanLeft: Long = dateOfExpiry - Date().time / 1000
|
||||
|
||||
Log.d("QWERTYUIOP", "ProductLifeSpan: ${productLifeSpan}, Lifespan left: ${lifeSpanLeft}, percent: ${lifeSpanLeft / productLifeSpan.toDouble()}")
|
||||
|
||||
return lifeSpanLeft / productLifeSpan.toDouble()
|
||||
}
|
|
@ -167,14 +167,10 @@ class AddProductActivity : AppCompatActivity() {
|
|||
}
|
||||
|
||||
val c = Calendar.getInstance()
|
||||
|
||||
// val dateOfProductionSplit = dateOfProduction.split(".")
|
||||
c.set(Calendar.YEAR, Date(dateOfProduction).year)
|
||||
c.set(Calendar.MONTH, Date(dateOfProduction).month)
|
||||
c.set(Calendar.DAY_OF_MONTH, Date(dateOfProduction).day)
|
||||
c.timeInMillis = dateOfProduction * 1000
|
||||
|
||||
c.add(Calendar.MONTH, shelfLifeMonths)
|
||||
dateOfExpiry = SimpleDateFormat("dd.MM.yyyy").parse("${c.get(Calendar.YEAR)}.${c.get(Calendar.MONTH)}.${c.get(Calendar.DAY_OF_MONTH)}").time / 1000
|
||||
dateOfExpiry = c.timeInMillis / 1000
|
||||
}
|
||||
|
||||
fun findAndDisplayAbstractProductByBarcode(barcode: String) {
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.foxarmy.barcodescannerforemployees.dataclasses.AbstractProduct
|
|||
import org.foxarmy.barcodescannerforemployees.dataclasses.Product
|
||||
import java.io.File
|
||||
import java.text.DecimalFormat
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import kotlin.concurrent.thread
|
||||
|
||||
|
@ -100,7 +101,7 @@ class ProductView: LinearLayout {
|
|||
productNetWeightTextView.text = linkedAbstractProduct.netWeight.toString()
|
||||
productAmountTextView.text = product.amount.toString()
|
||||
productCategoryView.text = DBStorageController(activity).getCategoryNameById(DBStorageController(activity).readableDatabase, linkedAbstractProduct.category)
|
||||
productLifeSpan.text = "${Date(product.dateOfProduction*1000)}-${Date(product.dateOfExpiry*1000)}"
|
||||
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) {
|
||||
"Expired"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools" android:layout_width="190dp"
|
||||
android:layout_height="wrap_content" app:barrierMargin="1dp" android:clickable="false"
|
||||
android:layout_height="330dp" app:barrierMargin="1dp" android:clickable="false"
|
||||
android:outlineProvider="background" android:background="@drawable/outline">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto" android:orientation="vertical"
|
||||
android:layout_width="190dp"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="345dp">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
Loading…
Reference in New Issue