From 94ae7310f4e95be3f273309d8ad419afc699efff Mon Sep 17 00:00:00 2001 From: Mariya Date: Fri, 13 Oct 2023 12:48:01 +0530 Subject: [PATCH] Blood group and incubation time added together. --- .../presentation/adapter/UserListAdapter.kt | 45 +++++++++---------- app/src/main/res/layout/user_item_view.xml | 11 +---- 2 files changed, 23 insertions(+), 33 deletions(-) diff --git a/app/src/main/java/com/example/hpostesting/presentation/adapter/UserListAdapter.kt b/app/src/main/java/com/example/hpostesting/presentation/adapter/UserListAdapter.kt index f568b52..9c5003f 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/adapter/UserListAdapter.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/adapter/UserListAdapter.kt @@ -52,7 +52,7 @@ class UserListAdapter( userName.text = "Name: ${model.name}" userId.text = "User ID:${model._id}" if (model.incubationTime == "") { - btnStartIncubation.visibility = View.VISIBLE + } else { userId.text = "User ID:${model._id} \n Time: ${isBetween15And30Minutes(model.incubationTime)} \n Started at: ${ @@ -62,7 +62,7 @@ class UserListAdapter( ).parse(model.incubationTime)!! ) }" - btnStartIncubation.visibility = View.GONE + } @@ -112,6 +112,25 @@ class UserListAdapter( "Blood group updated successfully", Toast.LENGTH_SHORT ).show() + btnBlood.visibility = View.GONE + Firebase.firestore.collection("patientData").whereEqualTo("_id", model._id).get() + .addOnSuccessListener { data -> + if (data.documents.isNotEmpty()) { + data.documents.forEach { userData -> + Firebase.firestore.collection("patientData").document(userData.id) + .update( + "incubationTime", SimpleDateFormat( + "yyyy-MM-dd HH:mm:ss", Locale.getDefault() + ).format(Calendar.getInstance().time).toString() + ).addOnSuccessListener { + Toast.makeText( + view.context, "Incubation started", Toast.LENGTH_SHORT + ).show() + startListening() + } + } + } + } } .addOnFailureListener { e -> Toast.makeText( @@ -149,27 +168,7 @@ class UserListAdapter( alertDialog.show() } - btnStartIncubation.setOnClickListener { - it.visibility = View.GONE - Firebase.firestore.collection("patientData").whereEqualTo("_id", model._id).get() - .addOnSuccessListener { data -> - if (data.documents.isNotEmpty()) { - data.documents.forEach { userData -> - Firebase.firestore.collection("patientData").document(userData.id) - .update( - "incubationTime", SimpleDateFormat( - "yyyy-MM-dd HH:mm:ss", Locale.getDefault() - ).format(Calendar.getInstance().time).toString() - ).addOnSuccessListener { - Toast.makeText( - view.context, "Incubation started", Toast.LENGTH_SHORT - ).show() - startListening() - } - } - } - } - } + userCard.setOnClickListener { if (batLevel < 40) { Toast.makeText( diff --git a/app/src/main/res/layout/user_item_view.xml b/app/src/main/res/layout/user_item_view.xml index d910040..2024ec0 100644 --- a/app/src/main/res/layout/user_item_view.xml +++ b/app/src/main/res/layout/user_item_view.xml @@ -72,15 +72,7 @@ app:layout_constraintTop_toBottomOf="@id/userId" tools:text="Test Status: Completed"/> -