Fixed Navigation, Location, and updated user card and gitignore file
This commit is contained in:
@@ -56,6 +56,8 @@ class MainActivity : AppCompatActivity() {
|
||||
locationResult.lastLocation?.let { location ->
|
||||
DataHolder.location =
|
||||
UserData.Location(location.latitude, location.longitude)
|
||||
DataHolder.selectedTest?.location =
|
||||
UserData.Location(location.latitude, location.longitude)
|
||||
Log.i("Location", DataHolder.location.toString())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import android.view.ViewGroup
|
||||
import android.widget.Toast
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.example.hpostesting.data.DataHolder
|
||||
import com.example.hpostesting.data.constant.Constants
|
||||
import com.example.hpostesting.data.constant.HemoCubeCommands
|
||||
@@ -18,6 +17,7 @@ import com.example.hpostesting.data.model.patient.DeviceData
|
||||
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
||||
import com.example.hpostesting.presentation.KitScanActivity
|
||||
import com.example.hpostesting.presentation.UsbServiceListener
|
||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||
import com.example.hpostesting.presentation.utils.MyDialogListener
|
||||
import com.example.hpostesting.presentation.utils.UIUtils
|
||||
import `in`.sminnovations.hpostesting.R
|
||||
@@ -61,12 +61,14 @@ class HemoCubeFragment : Fragment() {
|
||||
Toast.makeText(
|
||||
requireContext(), "Test Results Uploaded Successfully", Toast.LENGTH_SHORT
|
||||
).show()
|
||||
findNavController().navigate(R.id.action_hemocubeFragment_to_homeFragment)
|
||||
startActivity(Intent(requireActivity(), DashboardActivity::class.java))
|
||||
}
|
||||
binding.progressBar.visibility = View.GONE
|
||||
}
|
||||
|
||||
hemoCubeViewModel.getDeviceData(sharedPreference.getString(Constants.USER_ID, "").toString())
|
||||
hemoCubeViewModel.getDeviceData(
|
||||
sharedPreference.getString(Constants.USER_ID, "").toString()
|
||||
)
|
||||
|
||||
hemoCubeViewModel.deviceData.observe(viewLifecycleOwner) {
|
||||
deviceData = it
|
||||
@@ -99,8 +101,7 @@ class HemoCubeFragment : Fragment() {
|
||||
listenToHemoCube()
|
||||
startSample()
|
||||
}
|
||||
}
|
||||
)
|
||||
})
|
||||
} else {
|
||||
listenToHemoCube()
|
||||
startBuffer()
|
||||
@@ -108,8 +109,10 @@ class HemoCubeFragment : Fragment() {
|
||||
}
|
||||
|
||||
private fun checkBufferValue(): Boolean {
|
||||
return if (sharedPreference.getString(Constants.BUFFER_VALUE_1, "") != ""
|
||||
&& sharedPreference.getString(Constants.BUFFER_VALUE_2, "") != ""
|
||||
return if (sharedPreference.getString(
|
||||
Constants.BUFFER_VALUE_1,
|
||||
""
|
||||
) != "" && sharedPreference.getString(Constants.BUFFER_VALUE_2, "") != ""
|
||||
) {
|
||||
sharedPreference.getString(Constants.BUFFER_VALUE_1, "")
|
||||
?.toDouble()!! > 0.0 && sharedPreference.getString(Constants.BUFFER_VALUE_2, "")
|
||||
@@ -176,8 +179,7 @@ class HemoCubeFragment : Fragment() {
|
||||
listenToHemoCube()
|
||||
startBuffer()
|
||||
}
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
if (stringData.contains("ERROR 501")) {
|
||||
@@ -195,8 +197,7 @@ class HemoCubeFragment : Fragment() {
|
||||
listenToHemoCube()
|
||||
startSample()
|
||||
}
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -217,8 +218,7 @@ class HemoCubeFragment : Fragment() {
|
||||
listenToHemoCube()
|
||||
startSample()
|
||||
}
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,11 +233,11 @@ class HemoCubeFragment : Fragment() {
|
||||
if (stringData.contains("RESULT") || resultData.contains("REND")) {
|
||||
// DEVICE RESPONSE FORMAT: RESULT SN <DEVICE_SERIAL_NUMBER> <GREEN_BUFFER_INTENSITY> <BLUE_BUFFER_INTENSITY> <GREEN_SAMPLE_INTENSITY> <BLUE_SAMPLE_INTENSITY> REND
|
||||
// // For example, "RESULT SN 18291 1937.23 2828.11 28211.20 121829.12 REND"
|
||||
var validString = ""
|
||||
var results: List<String>
|
||||
var validString: String
|
||||
val results: List<String>
|
||||
if (stringData.contains("RESULT")) {
|
||||
validString = isValidResult(stringData)
|
||||
if (validString.isNullOrEmpty()) {
|
||||
if (validString.isEmpty()) {
|
||||
results = resultData.split("\n")
|
||||
validString = parseResult(results)
|
||||
}
|
||||
@@ -246,7 +246,8 @@ class HemoCubeFragment : Fragment() {
|
||||
validString = parseResult(results)
|
||||
}
|
||||
|
||||
if (!validString.isNullOrEmpty()) {
|
||||
|
||||
if (validString.isNotEmpty()) {
|
||||
val result = validString.split(" ")
|
||||
if (result.size == 8) {
|
||||
val deviceSerialNo = result[2]
|
||||
@@ -258,15 +259,21 @@ class HemoCubeFragment : Fragment() {
|
||||
val led2Average = log10(led2Buffer?.div(led2Sample!!) ?: 0.0)
|
||||
val deviceRatio = led1Average / led2Average
|
||||
DataHolder.hemoCubeTestData?.deviceSerialNumber = deviceSerialNo
|
||||
val kitCount = sharedPreference.getInt(Constants.KIT_COUNT, 0)?.toInt()
|
||||
if (kitCount != null && kitCount < 35 && sharedPreference.getString(Constants.BUFFER_VALUE_1, "").isNullOrEmpty())
|
||||
DataHolder.hemoCubeTestData?.led1Buffer = led1Buffer
|
||||
else
|
||||
DataHolder.hemoCubeTestData?.led1Buffer = sharedPreference.getString(Constants.BUFFER_VALUE_1, "")?.toDoubleOrNull()
|
||||
if (kitCount != null && kitCount < 35 && sharedPreference.getString(Constants.BUFFER_VALUE_2, "").isNullOrEmpty())
|
||||
DataHolder.hemoCubeTestData?.led2Buffer = led2Buffer
|
||||
else
|
||||
DataHolder.hemoCubeTestData?.led2Buffer = sharedPreference.getString(Constants.BUFFER_VALUE_2, "")?.toDoubleOrNull()
|
||||
val kitCount = sharedPreference.getInt(Constants.KIT_COUNT, 0)
|
||||
if (kitCount < 35 && sharedPreference.getString(
|
||||
Constants.BUFFER_VALUE_1, ""
|
||||
).isNullOrEmpty()
|
||||
) DataHolder.hemoCubeTestData?.led1Buffer = led1Buffer
|
||||
else DataHolder.hemoCubeTestData?.led1Buffer =
|
||||
sharedPreference.getString(Constants.BUFFER_VALUE_1, "")
|
||||
?.toDoubleOrNull()
|
||||
if (kitCount < 35 && sharedPreference.getString(
|
||||
Constants.BUFFER_VALUE_2, ""
|
||||
).isNullOrEmpty()
|
||||
) DataHolder.hemoCubeTestData?.led2Buffer = led2Buffer
|
||||
else DataHolder.hemoCubeTestData?.led2Buffer =
|
||||
sharedPreference.getString(Constants.BUFFER_VALUE_2, "")
|
||||
?.toDoubleOrNull()
|
||||
DataHolder.hemoCubeTestData?.led1Sample = led1Sample
|
||||
DataHolder.hemoCubeTestData?.led2Sample = led2Sample
|
||||
DataHolder.hemoCubeTestData?.led1Average = led1Average
|
||||
@@ -275,8 +282,8 @@ class HemoCubeFragment : Fragment() {
|
||||
DataHolder.hemoCubeTestData?.calculatedRatio =
|
||||
calculateRatio(deviceRatio)
|
||||
|
||||
DataHolder.hemoCubeTestData?.resultData = resultData
|
||||
resultRatio = deviceRatio?.toString()
|
||||
DataHolder.hemoCubeTestData?.resultData = resultData
|
||||
resultRatio = deviceRatio.toString()
|
||||
if (!checkBufferValue()) {
|
||||
with(sharedPreference.edit()) {
|
||||
putString(Constants.BUFFER_VALUE_1, led1Buffer.toString())
|
||||
@@ -317,7 +324,6 @@ class HemoCubeFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
}
|
||||
hemoCubeViewModel.progressBar.postValue(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -331,41 +337,39 @@ class HemoCubeFragment : Fragment() {
|
||||
private fun startBuffer() {
|
||||
hemoCubeViewModel.progressBar.postValue(true)
|
||||
|
||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.startBuffer,
|
||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(
|
||||
HemoCubeCommands.startBuffer,
|
||||
object : UsbServiceListener {
|
||||
override fun onUsbRead(data: ByteArray?) {}
|
||||
override fun onUsbError(e: Exception?) {
|
||||
hemoCubeViewModel.progressBar.postValue(false)
|
||||
}
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
private fun startSample() {
|
||||
hemoCubeViewModel.progressBar.postValue(true)
|
||||
val fullReadOutput = StringBuilder()
|
||||
|
||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.startSample,
|
||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(
|
||||
HemoCubeCommands.startSample,
|
||||
object : UsbServiceListener {
|
||||
override fun onUsbRead(data: ByteArray?) {}
|
||||
override fun onUsbError(e: Exception?) {
|
||||
hemoCubeViewModel.progressBar.postValue(false)
|
||||
}
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
private fun getResult() {
|
||||
hemoCubeViewModel.progressBar.postValue(true)
|
||||
|
||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.getSample,
|
||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(
|
||||
HemoCubeCommands.getSample,
|
||||
object : UsbServiceListener {
|
||||
override fun onUsbRead(data: ByteArray?) {}
|
||||
override fun onUsbError(e: Exception?) {
|
||||
hemoCubeViewModel.progressBar.postValue(false)
|
||||
}
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
private fun calculateRatio(ratio: Double): Double {
|
||||
@@ -377,8 +381,7 @@ class HemoCubeFragment : Fragment() {
|
||||
private fun parseResult(frames: List<String>): String {
|
||||
val lines = mutableListOf<String>()
|
||||
for (frame in frames.reversed()) {
|
||||
if (frame.contains("REND") || frame.contains("RESULT"))
|
||||
lines += frame
|
||||
if (frame.contains("REND") || frame.contains("RESULT")) lines += frame
|
||||
if (frame.contains("RESULT")) {
|
||||
break
|
||||
}
|
||||
|
||||
@@ -70,7 +70,6 @@
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/internetAvailableCL"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -1,75 +1,80 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout 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="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/userCard"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
app:cardBackgroundColor="@color/primary_light"
|
||||
app:cardCornerRadius="25dp"
|
||||
app:cardElevation="0dp"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/userCard"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="12dp">
|
||||
android:layout_marginTop="24dp"
|
||||
app:cardBackgroundColor="@color/primary_light"
|
||||
app:cardCornerRadius="25dp"
|
||||
app:cardElevation="0dp"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/userImage"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/userName"
|
||||
android:layout_width="0dp"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/poppins_bold"
|
||||
android:layout_marginTop="16dp"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/userImage" />
|
||||
android:padding="12dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/userId"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/poppins_bold"
|
||||
android:layout_marginTop="16dp"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/userName" />
|
||||
<ImageView
|
||||
android:id="@+id/userImage"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:src="@drawable/ic_launcher_foreground" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/teststatus"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/poppins_bold"
|
||||
android:layout_marginTop="16dp"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/userId" />
|
||||
<TextView
|
||||
android:id="@+id/userName"
|
||||
style="@style/title1_1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:gravity="start"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/userImage"
|
||||
app:layout_constraintTop_toTopOf="@+id/userImage"
|
||||
tools:text="Name: MohamedKaif" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/userId"
|
||||
style="@style/title1_1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:gravity="start"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/userImage"
|
||||
app:layout_constraintTop_toBottomOf="@id/userName"
|
||||
tools:text="UserID: MohamedKaif" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/teststatus"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/title1_1"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:gravity="start"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/userImage"
|
||||
app:layout_constraintTop_toBottomOf="@id/userId"
|
||||
tools:text="Test Status: Completed"/>
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -47,18 +47,5 @@
|
||||
app:popUpTo="@id/mobile_navigation"
|
||||
app:popUpToInclusive="true"/>
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/hemocubeFragment"
|
||||
android:name="com.example.hpostesting.presentation.hemocube.HemoCubeFragment"
|
||||
android:label="fragment_hemocube"
|
||||
tools:layout="@layout/fragment_hemo_cube_reference" >
|
||||
|
||||
|
||||
<action
|
||||
android:id="@+id/action_hemocubeFragment_to_homeFragment"
|
||||
app:destination="@id/nav_home"
|
||||
app:popUpTo="@id/mobile_navigation"
|
||||
app:popUpToInclusive="true"/>
|
||||
</fragment>
|
||||
|
||||
</navigation>
|
||||
Reference in New Issue
Block a user