offline incubation code is added
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package com.example.hpostesting.presentation.adapter
|
package com.example.hpostesting.presentation.adapter
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
@@ -54,12 +55,19 @@ class OfflineUserListAdapter(private val view: View, private val batLevel: Int)
|
|||||||
return differ.currentList.size
|
return differ.currentList.size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n")
|
||||||
override fun onBindViewHolder(holder: OfflineUserListViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: OfflineUserListViewHolder, position: Int) {
|
||||||
val userList = differ.currentList[position]
|
val userList = differ.currentList[position]
|
||||||
holder.binding.apply {
|
holder.binding.apply {
|
||||||
userID.text = "User ID: ${userList._id}"
|
userID.text = "User ID: ${userList._id}"
|
||||||
bloodGroup.text = "Blood group: ${userList.bloodGroup}"
|
bloodGroup.text = "Blood group: ${userList.bloodGroup}"
|
||||||
time.text = "Time: ${userList.incubationTime}"
|
time.text = "Time: ${isBetween15And30Minutes(userList.incubationTime)} \n Started at: ${
|
||||||
|
SimpleDateFormat("HH:mm:ss").format(
|
||||||
|
SimpleDateFormat(
|
||||||
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
|
).parse(userList.incubationTime)!!
|
||||||
|
)
|
||||||
|
}"
|
||||||
userCard.setOnClickListener {
|
userCard.setOnClickListener {
|
||||||
if (batLevel < 40) {
|
if (batLevel < 40) {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
@@ -109,6 +117,8 @@ class OfflineUserListAdapter(private val view: View, private val batLevel: Int)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,4 +132,13 @@ class OfflineUserListAdapter(private val view: View, private val batLevel: Int)
|
|||||||
|
|
||||||
return diffMillis / (60 * 1000)
|
return diffMillis / (60 * 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun saveIncubationLocally(incubationTime: String) {
|
||||||
|
val sharedPreferences = view.context.getSharedPreferences("LocalData", Context.MODE_PRIVATE)
|
||||||
|
val editor = sharedPreferences.edit()
|
||||||
|
editor.putString("localIncubationTime", incubationTime)
|
||||||
|
// Add any other necessary data
|
||||||
|
editor.apply()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -138,6 +138,7 @@ class HomeFragment : Fragment() {
|
|||||||
binding.btnSubmit.setOnClickListener {
|
binding.btnSubmit.setOnClickListener {
|
||||||
val userId = binding.userId.text.toString()
|
val userId = binding.userId.text.toString()
|
||||||
val bloodGroup = binding.etBloodGroup.text
|
val bloodGroup = binding.etBloodGroup.text
|
||||||
|
|
||||||
if (userId.length >= 18 && !bloodGroup.equals("Select Blood Group") || !bloodGroup.isNullOrBlank()) {
|
if (userId.length >= 18 && !bloodGroup.equals("Select Blood Group") || !bloodGroup.isNullOrBlank()) {
|
||||||
hemoCubeViewModel.addUser(
|
hemoCubeViewModel.addUser(
|
||||||
HemoCubeTestData(
|
HemoCubeTestData(
|
||||||
|
|||||||
@@ -359,23 +359,11 @@ class HemoCubeFragment : Fragment() {
|
|||||||
val led2Average = log10(led2BufferForDevice?.div(led2Sample!!) ?: 0.0)
|
val led2Average = log10(led2BufferForDevice?.div(led2Sample!!) ?: 0.0)
|
||||||
val deviceRatio = led1Average / led2Average
|
val deviceRatio = led1Average / led2Average
|
||||||
val coefficientsList = Constants.COEFFICIENTS[deviceSerialNo]
|
val coefficientsList = Constants.COEFFICIENTS[deviceSerialNo]
|
||||||
if (coefficientsList != null) {
|
// if (coefficientsList != null) {
|
||||||
val coefficient1 = coefficientsList.getOrNull(0)?.get(0) ?: 0.0
|
val coefficient1 = coefficientsList?.get(0)?.get(0).toString()
|
||||||
val coefficient2 = coefficientsList.getOrNull(1)?.get(0) ?: 0.0
|
val coefficient2 = coefficientsList?.get(1)?.get(0).toString()
|
||||||
coefficient = "$coefficient1,$coefficient2"
|
val coefficientsString = "$coefficient1,$coefficient2"
|
||||||
// Now, you can use 'coefficients' to store in Firebase.
|
|
||||||
} else {
|
|
||||||
coefficient = currentDeviceData?.coefficients?.get(0)
|
|
||||||
.toString() + ", " + currentDeviceData?.coefficients?.get(1).toString()
|
|
||||||
}
|
|
||||||
// if (isOnline) {
|
|
||||||
// // Online mode, use coefficients from the server
|
|
||||||
// coefficients = currentDeviceData?.coefficients?.get(0)
|
|
||||||
// .toString() + ", " + currentDeviceData?.coefficients?.get(1).toString()
|
|
||||||
// } else {
|
|
||||||
// Offline mode, provide default coefficients or handle as needed
|
|
||||||
|
|
||||||
// }
|
|
||||||
// if (led1BufferForDevice!! > 20000 && led1BufferForDevice < 24000 && led2BufferForDevice!! > 20000 && led2BufferForDevice < 24000) {
|
// if (led1BufferForDevice!! > 20000 && led1BufferForDevice < 24000 && led2BufferForDevice!! > 20000 && led2BufferForDevice < 24000) {
|
||||||
// if (led1Sample!! < led1BufferForDevice && led1Sample < 24000 && led2Sample!! < led2BufferForDevice && led2Sample < 24000) {
|
// if (led1Sample!! < led1BufferForDevice && led1Sample < 24000 && led2Sample!! < led2BufferForDevice && led2Sample < 24000) {
|
||||||
// if (deviceRatio < 0.08) {
|
// if (deviceRatio < 0.08) {
|
||||||
@@ -405,7 +393,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
this.deviceRatio = deviceRatio
|
this.deviceRatio = deviceRatio
|
||||||
this.calculatedRatio = calculateRatio(deviceRatio)
|
this.calculatedRatio = calculateRatio(deviceRatio)
|
||||||
// this.coefficients = currentDeviceData?.coefficients?.get(0).toString() + ", " + currentDeviceData?.coefficients?.get(1).toString()
|
// this.coefficients = currentDeviceData?.coefficients?.get(0).toString() + ", " + currentDeviceData?.coefficients?.get(1).toString()
|
||||||
this.coefficients = coefficient
|
this.coefficients = coefficientsString
|
||||||
this.classificationResult = findResult(calculatedRatio)
|
this.classificationResult = findResult(calculatedRatio)
|
||||||
hemoCubeViewModel.messages.postValue(this.classificationResult)
|
hemoCubeViewModel.messages.postValue(this.classificationResult)
|
||||||
this.resultData = deviceLog
|
this.resultData = deviceLog
|
||||||
|
|||||||
@@ -62,8 +62,7 @@
|
|||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/bloodGroup"
|
app:layout_constraintTop_toBottomOf="@id/bloodGroup"
|
||||||
tools:text="Test Status: Completed" />
|
tools:text="startedAt: yyyy-MM-dd HH:mm:ss" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
</androidx.cardview.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|||||||
Reference in New Issue
Block a user