Login Feature
This commit is contained in:
@@ -1,94 +0,0 @@
|
|||||||
package com.example.hpos.presentation
|
|
||||||
|
|
||||||
import android.util.Log
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import android.widget.RadioButton
|
|
||||||
import android.widget.RadioGroup
|
|
||||||
import android.widget.TextView
|
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
|
||||||
import com.example.hpos.R
|
|
||||||
import com.example.hpos.data.model.test.Status
|
|
||||||
import com.example.hpos.data.model.test.TestDetails
|
|
||||||
import com.example.hpos.presentation.dashboard.ItemClickListener
|
|
||||||
|
|
||||||
class RecyclerViewAdapter : RecyclerView.Adapter<RecyclerViewAdapter.ViewHolder>() {
|
|
||||||
|
|
||||||
private val dataset = ArrayList<TestDetails>()
|
|
||||||
|
|
||||||
var itemClickListener: ItemClickListener? = null
|
|
||||||
|
|
||||||
var selectedPosition = -1
|
|
||||||
var prev = -1
|
|
||||||
|
|
||||||
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
|
||||||
val tvId: TextView = view.findViewById(R.id.tv_id)
|
|
||||||
val tvName: TextView = view.findViewById(R.id.tv_name)
|
|
||||||
val tvStatus: TextView = view.findViewById(R.id.tv_status)
|
|
||||||
val radioButton: RadioButton = view.findViewById(R.id.radioButton)
|
|
||||||
val radioGroup: RadioGroup = view.findViewById(R.id.radio_group)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
|
||||||
val view = LayoutInflater.from(parent.context)
|
|
||||||
.inflate(R.layout.table_item, parent, false)
|
|
||||||
|
|
||||||
return ViewHolder(view)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
|
||||||
Log.d("RVAdapter", "onBindViewHolder called() : pos = ${position}")
|
|
||||||
val idString = "ID: " + dataset[position].patientID
|
|
||||||
holder.tvId.text = idString
|
|
||||||
holder.tvName.text = dataset[position].patientName
|
|
||||||
holder.tvStatus.text = dataset[position].testStatus.toString()
|
|
||||||
|
|
||||||
|
|
||||||
Log.d("RVAdapter", "For ${dataset[position].patientName}, selected = $selectedPosition")
|
|
||||||
|
|
||||||
holder.radioGroup.clearCheck()
|
|
||||||
if (dataset[position].testStatus == Status.PENDING) {
|
|
||||||
holder.radioButton.isEnabled = true
|
|
||||||
holder.radioButton.isChecked = (position == selectedPosition)
|
|
||||||
Log.d("RVAdapter", "inside pending if")
|
|
||||||
} else {
|
|
||||||
holder.radioButton.isChecked = false
|
|
||||||
holder.radioButton.isEnabled = false
|
|
||||||
Log.d("RVAdapter", "inside pending else")
|
|
||||||
}
|
|
||||||
|
|
||||||
holder.radioButton.setOnClickListener {
|
|
||||||
setSelectedItem(position)
|
|
||||||
}
|
|
||||||
holder.itemView.setOnClickListener {
|
|
||||||
setSelectedItem(position)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun setSelectedItem(position: Int) {
|
|
||||||
Log.d("RVAdapter", "setOnCheckedChangeListener called() -> b true : pos = $position")
|
|
||||||
|
|
||||||
if (position != selectedPosition && dataset[position].testStatus == Status.PENDING) {
|
|
||||||
prev = selectedPosition
|
|
||||||
selectedPosition = position
|
|
||||||
itemClickListener!!.onClick(position)
|
|
||||||
|
|
||||||
if (prev != -1) {
|
|
||||||
notifyItemChanged(prev)
|
|
||||||
}
|
|
||||||
notifyItemChanged(position)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
|
||||||
return dataset.size
|
|
||||||
}
|
|
||||||
|
|
||||||
fun updateDataSet(newDataSet: ArrayList<TestDetails>) {
|
|
||||||
dataset.clear()
|
|
||||||
dataset.addAll(newDataSet)
|
|
||||||
notifyDataSetChanged()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -8,38 +8,23 @@ import com.example.hpostesting.data.model.test.TestRightResultType
|
|||||||
data class UserData(
|
data class UserData(
|
||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
var _id: String = "",
|
var _id: String = "",
|
||||||
var AbhaId: String = "",
|
|
||||||
var AadharId: String = "",
|
|
||||||
var name: String = "",
|
var name: String = "",
|
||||||
var birthYear: String = "",
|
var birthYear: String = "",
|
||||||
var gender: String = "",
|
var userImageURL: String = "",
|
||||||
var phoneNumber: String = "",
|
|
||||||
var careOf: String = "",
|
|
||||||
var maritalStatus: String = "",
|
|
||||||
var caste: String = "",
|
|
||||||
var subCaste: String = "",
|
|
||||||
var house: String = "",
|
|
||||||
var city: String = "",
|
|
||||||
var district: String = "",
|
|
||||||
var state: String = "",
|
|
||||||
var pinCode: String = "",
|
|
||||||
var bloodGroup: String = "",
|
|
||||||
var isUnderMedication: Boolean? = false,
|
|
||||||
var isUnderTransfusion: Boolean? = false,
|
|
||||||
var sickleCellHistory: String? = "",
|
|
||||||
var userImage: String = "",
|
|
||||||
var location: Location? = null,
|
var location: Location? = null,
|
||||||
var uploadTime: String? = "",
|
var createdBy: String? = "",
|
||||||
|
var reportUploadTime: String? = "",
|
||||||
var testTime: String? = "",
|
var testTime: String? = "",
|
||||||
var testStatus: Boolean? = false,
|
var testStatus: Boolean? = false,
|
||||||
var mobileId: String = "",
|
var mobileId: String = "",
|
||||||
var deviceId: String = "",
|
var deviceId: String = "",
|
||||||
|
var deviceSerialNumber: String = "",
|
||||||
var kitSerial: String = "",
|
var kitSerial: String = "",
|
||||||
var csvPath: String = "",
|
var csvPath: String = "",
|
||||||
var reportPath: String = "",
|
var reportPath: String = "",
|
||||||
var result: TestRightResultType? = null,
|
var result: TestRightResultType? = null,
|
||||||
var resultRatio: Double? = null,
|
var resultRatio: Double? = null
|
||||||
){
|
) {
|
||||||
enum class Gender {
|
enum class Gender {
|
||||||
MALE,
|
MALE,
|
||||||
FEMALE,
|
FEMALE,
|
||||||
|
|||||||
@@ -1,94 +0,0 @@
|
|||||||
package com.example.hpostesting.domain
|
|
||||||
|
|
||||||
import com.example.hpostesting.data.constant.Constants
|
|
||||||
import com.example.hpostesting.data.model.test.TestRightCalculationData
|
|
||||||
import com.example.hpostesting.data.model.test.TestRightResultType
|
|
||||||
|
|
||||||
class ResultCalculationWithAvgImpl : TestRightResultCalculation {
|
|
||||||
|
|
||||||
private val testRightCalculationData = TestRightCalculationData()
|
|
||||||
|
|
||||||
override fun getResults(wavelengthToAbsorbance: ArrayList<ArrayList<Double>>): TestRightCalculationData {
|
|
||||||
|
|
||||||
val startWavelengthOne =
|
|
||||||
Constants.WAVELENGTH_OF_INTEREST_ONE - Constants.RANGE_IN_RESULT_CALCULATIONS
|
|
||||||
val endWavelengthOne =
|
|
||||||
Constants.WAVELENGTH_OF_INTEREST_ONE + Constants.RANGE_IN_RESULT_CALCULATIONS + 1
|
|
||||||
var sumOfAbsorbanceAtOne = 0.0
|
|
||||||
var noOfAbsorbanceRecordedOne = 0
|
|
||||||
|
|
||||||
val startWavelengthTwo =
|
|
||||||
Constants.WAVELENGTH_OF_INTEREST_TWO - Constants.RANGE_IN_RESULT_CALCULATIONS
|
|
||||||
val endWavelengthTwo =
|
|
||||||
Constants.WAVELENGTH_OF_INTEREST_TWO + Constants.RANGE_IN_RESULT_CALCULATIONS + 1
|
|
||||||
var sumOfAbsorbanceAtTwo = 0.0
|
|
||||||
var noOfAbsorbanceRecordedTwo = 0
|
|
||||||
|
|
||||||
for (each in wavelengthToAbsorbance) {
|
|
||||||
if (each[0] >= startWavelengthOne && each[0] < endWavelengthOne) {
|
|
||||||
sumOfAbsorbanceAtOne += each[1]
|
|
||||||
noOfAbsorbanceRecordedOne++
|
|
||||||
}
|
|
||||||
if (each[0] >= startWavelengthTwo && each[0] < endWavelengthTwo) {
|
|
||||||
sumOfAbsorbanceAtTwo += each[1]
|
|
||||||
noOfAbsorbanceRecordedTwo++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val avgAbsorbanceOne = (sumOfAbsorbanceAtOne / noOfAbsorbanceRecordedOne)
|
|
||||||
val avgAbsorbanceTwo = (sumOfAbsorbanceAtTwo / noOfAbsorbanceRecordedTwo)
|
|
||||||
|
|
||||||
testRightCalculationData.absorbanceOne = avgAbsorbanceOne
|
|
||||||
testRightCalculationData.absorbanceTwo = avgAbsorbanceTwo
|
|
||||||
|
|
||||||
testRightCalculationData.result = calculateResultsAndRatio(avgAbsorbanceOne, avgAbsorbanceTwo)
|
|
||||||
return testRightCalculationData
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun calculateResultsAndRatio(
|
|
||||||
absorbanceAtWaveOne: Double,
|
|
||||||
absorbanceAtWaveTwo: Double
|
|
||||||
): TestRightResultType {
|
|
||||||
|
|
||||||
if (absorbanceAtWaveOne != Double.MIN_VALUE && absorbanceAtWaveTwo != Double.MIN_VALUE && absorbanceAtWaveOne != 0.0) {
|
|
||||||
val value = absorbanceAtWaveTwo / absorbanceAtWaveOne
|
|
||||||
testRightCalculationData.ratioValue = value
|
|
||||||
|
|
||||||
if (value < 0.24 || value == 0.0) {
|
|
||||||
testRightCalculationData.ratioMinRange = 0.0
|
|
||||||
testRightCalculationData.ratioMaxRange = 0.24
|
|
||||||
return TestRightResultType.NORMAL
|
|
||||||
} else if (value >= 0.24 && value < 0.30) {
|
|
||||||
testRightCalculationData.ratioMinRange = 0.24
|
|
||||||
testRightCalculationData.ratioMaxRange = 0.30
|
|
||||||
return TestRightResultType.SICKLECELLTRAIT
|
|
||||||
} else if (value >= 0.30) {
|
|
||||||
testRightCalculationData.ratioMinRange = 0.30
|
|
||||||
testRightCalculationData.ratioMaxRange = 999.0
|
|
||||||
return TestRightResultType.SICKLECELLDISEASE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return TestRightResultType.UNDEFINED
|
|
||||||
|
|
||||||
// if (absorbanceAtWaveOne != Double.MIN_VALUE && absorbanceAtWaveTwo != Double.MIN_VALUE && absorbanceAtWaveOne != 0.0) {
|
|
||||||
// val value = absorbanceAtWaveTwo / absorbanceAtWaveOne
|
|
||||||
//
|
|
||||||
// if (value < 0.24 || value == 0.0) {
|
|
||||||
// return TestRightResultType.NORMAL
|
|
||||||
// } else if (value >= 0.24 && value < 0.30) {
|
|
||||||
// return TestRightResultType.SICKLECELLTRAIT
|
|
||||||
// } else if (value >= 0.30) {
|
|
||||||
// return TestRightResultType.SICKLECELLDISEASE
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return TestRightResultType.UNDEFINED
|
|
||||||
// Log.d(TAG, "value = $value")
|
|
||||||
// println("value = $value")
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
package com.example.hpostesting.domain
|
|
||||||
|
|
||||||
import android.util.Log
|
|
||||||
import com.example.hpostesting.data.constant.Constants
|
|
||||||
import com.example.hpostesting.data.model.test.TestRightResultType
|
|
||||||
import kotlin.math.log10
|
|
||||||
|
|
||||||
class ResultCalculationWithFirstImpl {
|
|
||||||
|
|
||||||
private val TAG = "Testright"
|
|
||||||
|
|
||||||
fun getResults(
|
|
||||||
wavelengthToPixelArray: ArrayList<ArrayList<Double>>,
|
|
||||||
intensityReferenceArray: ArrayList<ArrayList<Double>>,
|
|
||||||
intensitySampleArray: ArrayList<ArrayList<Double>>
|
|
||||||
) : TestRightResultType {
|
|
||||||
var pixelNoWithWave_427 = 0
|
|
||||||
var pixelNoWithWave_555 = 0
|
|
||||||
|
|
||||||
Log.d(TAG, "wavelengthToPixelArray size = ${wavelengthToPixelArray.size}")
|
|
||||||
// println("wavelengthToPixelArray size = ${wavelengthToPixelArray.size}")
|
|
||||||
for (each in wavelengthToPixelArray) {
|
|
||||||
var diff = each[0] - 427
|
|
||||||
if (pixelNoWithWave_427 == 0 && diff >= 0 && diff < 1) {
|
|
||||||
pixelNoWithWave_427 = each[1].toInt()
|
|
||||||
}
|
|
||||||
|
|
||||||
diff = each[0] - 555
|
|
||||||
if (pixelNoWithWave_555 == 0 && diff >= 0 && diff < 1) {
|
|
||||||
pixelNoWithWave_555 = each[1].toInt()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pixelNoWithWave_427 != 0 && pixelNoWithWave_555 != 0) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Log.d(TAG, "pixelOfInterest_427 = ${pixelNoWithWave_427}")
|
|
||||||
Log.d(TAG, "pixelOfInterest_555 = ${pixelNoWithWave_555}")
|
|
||||||
|
|
||||||
// println("pixelOfInterest_427 = ${pixelNoWithWave_427}")
|
|
||||||
// println("pixelOfInterest_555 = ${pixelNoWithWave_555}")
|
|
||||||
|
|
||||||
val invertedPixel_427 = (Constants.TEST_RIGHT_TOTAL_PIXEL + 1) - pixelNoWithWave_427
|
|
||||||
val invertedPixel_555 = (Constants.TEST_RIGHT_TOTAL_PIXEL + 1) - pixelNoWithWave_555
|
|
||||||
|
|
||||||
var io_427 = 0.0
|
|
||||||
var io_555 = 0.0
|
|
||||||
|
|
||||||
for (each in intensityReferenceArray) {
|
|
||||||
if (each[0].toInt() == invertedPixel_427) {
|
|
||||||
io_427 = each[1]
|
|
||||||
}
|
|
||||||
if (each[0].toInt() == invertedPixel_555) {
|
|
||||||
io_555 = each[1]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Log.d(TAG, "I0 values are I0_427 = $io_427 , IO_555 = $io_555")
|
|
||||||
// println("I0 values are I0_427 = $io_427 , IO_555 = $io_555")
|
|
||||||
|
|
||||||
var i_427 = 0.0
|
|
||||||
var i_555 = 0.0
|
|
||||||
|
|
||||||
for (each in intensitySampleArray) {
|
|
||||||
if (each[0].toInt() == invertedPixel_427) {
|
|
||||||
i_427 = each[1]
|
|
||||||
}
|
|
||||||
if (each[0].toInt() == invertedPixel_555) {
|
|
||||||
i_555 = each[1]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Log.d(TAG, "I values are I_427 = $i_427 , I_555 = $i_555")
|
|
||||||
// println("I values are I_427 = $i_427 , I_555 = $i_555")
|
|
||||||
|
|
||||||
val absorbanceAtPixelWithWave_427 = log10(io_427 / i_427)
|
|
||||||
val absorbanceAtPixelWithWave_555 = log10(io_555 / i_555)
|
|
||||||
Log.d(
|
|
||||||
TAG,
|
|
||||||
"absorbance values are for 427 = $absorbanceAtPixelWithWave_427 , for 555 = $absorbanceAtPixelWithWave_555"
|
|
||||||
)
|
|
||||||
// println("absorbance values are for 427 = $absorbanceAtPixelWithWave_427 , for 555 = $absorbanceAtPixelWithWave_555")
|
|
||||||
|
|
||||||
var value = 0.0
|
|
||||||
if (absorbanceAtPixelWithWave_427 != 0.0 && absorbanceAtPixelWithWave_555 != 0.0) {
|
|
||||||
value = absorbanceAtPixelWithWave_555 / absorbanceAtPixelWithWave_427
|
|
||||||
}
|
|
||||||
Log.d(TAG, "value = $value")
|
|
||||||
// println("value = $value")
|
|
||||||
|
|
||||||
|
|
||||||
if (value < 0.24 || value == 0.0) {
|
|
||||||
return TestRightResultType.NORMAL
|
|
||||||
} else if (value >= 0.24 && value < 0.30) {
|
|
||||||
return TestRightResultType.SICKLECELLTRAIT
|
|
||||||
} else if (value >= 0.30) {
|
|
||||||
return TestRightResultType.SICKLECELLDISEASE
|
|
||||||
}
|
|
||||||
return TestRightResultType.UNDEFINED
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -32,11 +32,9 @@ class UserListAdapter(options: FirestoreRecyclerOptions<UserData>, private val v
|
|||||||
holder.binding.apply {
|
holder.binding.apply {
|
||||||
userName.text = model.name
|
userName.text = model.name
|
||||||
userId.text = model._id
|
userId.text = model._id
|
||||||
Glide.with(view).load(model.userImage).into(userImage)
|
Glide.with(view).load(model.userImageURL).into(userImage)
|
||||||
if (model.testStatus != null) {
|
if (model.testStatus!!) {
|
||||||
if (model.testStatus!!) {
|
userCard.setCardBackgroundColor(view.resources.getColor(R.color.gray))
|
||||||
userCard.setCardBackgroundColor(view.resources.getColor(R.color.gray))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
userCard.setOnClickListener {
|
userCard.setOnClickListener {
|
||||||
if (model.testStatus != null) {
|
if (model.testStatus != null) {
|
||||||
|
|||||||
@@ -91,13 +91,15 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getData(search: String?, field: String) {
|
private fun getData(search: String?, field: String) {
|
||||||
val capitalizedSearch =
|
val capitalizedSearch = search?.replaceFirstChar {
|
||||||
search?.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }
|
if (search.lowercase()
|
||||||
Log.i("Capital", capitalizedSearch.toString())
|
.startsWith(it.lowercase())
|
||||||
|
) it.titlecase(Locale.getDefault()) else it.toString()
|
||||||
|
|
||||||
val query = Firebase.firestore.collection("patientData")
|
}
|
||||||
.orderBy(field)
|
|
||||||
.whereArrayContainsAny(field, listOf(capitalizedSearch))
|
val query = Firebase.firestore.collection("patientData").orderBy(field).startAt(search)
|
||||||
|
.endAt(search + "\uf8ff")
|
||||||
|
|
||||||
val recyclerViewOptions =
|
val recyclerViewOptions =
|
||||||
FirestoreRecyclerOptions.Builder<UserData>().setQuery(query, UserData::class.java)
|
FirestoreRecyclerOptions.Builder<UserData>().setQuery(query, UserData::class.java)
|
||||||
@@ -179,7 +181,11 @@ class HomeFragment : Fragment() {
|
|||||||
viewModel.deleteById(userData._id)
|
viewModel.deleteById(userData._id)
|
||||||
}
|
}
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
Toast.makeText(requireContext(), R.string.upload_success_message, Toast.LENGTH_SHORT).show()
|
Toast.makeText(
|
||||||
|
requireContext(),
|
||||||
|
R.string.upload_success_message,
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.example.hpostesting.presentation.dashboard.ui
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import `in`.sminnovations.hpostesting.databinding.FragmentLoginBinding
|
||||||
|
|
||||||
|
class LoginFragment : Fragment() {
|
||||||
|
|
||||||
|
private var _binding: FragmentLoginBinding? = null
|
||||||
|
private val binding get() = _binding!!
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View {
|
||||||
|
_binding = FragmentLoginBinding.inflate(inflater, container, false)
|
||||||
|
|
||||||
|
return binding.root
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override fun onDestroyView() {
|
||||||
|
super.onDestroyView()
|
||||||
|
_binding = null
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -35,9 +35,7 @@ class TestRightResults : Fragment() {
|
|||||||
): View {
|
): View {
|
||||||
// Inflate the layout for this fragment
|
// Inflate the layout for this fragment
|
||||||
binding = FragmentTestRightResultsBinding.inflate(inflater, container, false)
|
binding = FragmentTestRightResultsBinding.inflate(inflater, container, false)
|
||||||
viewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isNetworkAvailable ->
|
|
||||||
isOnline = isNetworkAvailable
|
|
||||||
}
|
|
||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,16 +134,18 @@ class TestRightResults : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isOnline) {
|
viewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isNetworkAvailable ->
|
||||||
viewModel.uploadResultToDatabase(requireContext(), true)
|
if (isNetworkAvailable) {
|
||||||
binding.progressBar.visibility = View.VISIBLE
|
viewModel.uploadResultToDatabase(requireContext(), true)
|
||||||
} else {
|
binding.progressBar.visibility = View.VISIBLE
|
||||||
viewModel.uploadResultToDatabase(requireContext(), false)
|
} else {
|
||||||
Toast.makeText(
|
viewModel.uploadResultToDatabase(requireContext(), false)
|
||||||
requireContext(),
|
Toast.makeText(
|
||||||
"Internet not available, Test Data added to Local DB",
|
requireContext(),
|
||||||
Toast.LENGTH_SHORT
|
"Internet not available, Test Data added to Local DB",
|
||||||
).show()
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import java.io.File
|
|||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
|
import java.util.Locale
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import kotlin.math.log10
|
import kotlin.math.log10
|
||||||
import kotlin.math.pow
|
import kotlin.math.pow
|
||||||
@@ -437,9 +438,13 @@ class TestRightViewModel @Inject constructor(
|
|||||||
|
|
||||||
private fun addResultTestToDb() {
|
private fun addResultTestToDb() {
|
||||||
testDetails?.location = DataHolder.location
|
testDetails?.location = DataHolder.location
|
||||||
testDetails?.testTime = Calendar.getInstance().time.toString()
|
testDetails?.testTime = SimpleDateFormat(
|
||||||
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
|
).format(Calendar.getInstance().time)
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
testDetails!!.uploadTime = Calendar.getInstance().time.toString()
|
testDetails!!.reportUploadTime = SimpleDateFormat(
|
||||||
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
|
).format(Calendar.getInstance().time)
|
||||||
when (repository.addTestToDatabase(testDetails)) {
|
when (repository.addTestToDatabase(testDetails)) {
|
||||||
is Response.Success -> {
|
is Response.Success -> {
|
||||||
fireBaseUpload.postValue("Success")
|
fireBaseUpload.postValue("Success")
|
||||||
@@ -480,7 +485,9 @@ class TestRightViewModel @Inject constructor(
|
|||||||
// Handle the exception appropriately (e.g., log the error, display an error message)
|
// Handle the exception appropriately (e.g., log the error, display an error message)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
testDetails?.testTime = Calendar.getInstance().time.toString()
|
testDetails?.testTime = SimpleDateFormat(
|
||||||
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
|
).format(Calendar.getInstance().time)
|
||||||
userDao.insertAll(testDetails!!)
|
userDao.insertAll(testDetails!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -514,11 +521,14 @@ class TestRightViewModel @Inject constructor(
|
|||||||
private fun bulkAddResultTestToDb(userData: UserData) {
|
private fun bulkAddResultTestToDb(userData: UserData) {
|
||||||
userData.location = DataHolder.location
|
userData.location = DataHolder.location
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
userData.uploadTime = Calendar.getInstance().time.toString()
|
userData.reportUploadTime = SimpleDateFormat(
|
||||||
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
|
).format(Calendar.getInstance().time)
|
||||||
when (repository.addTestToDatabase(userData)) {
|
when (repository.addTestToDatabase(userData)) {
|
||||||
is Response.Success -> {
|
is Response.Success -> {
|
||||||
fireBaseUpload.postValue("Success")
|
fireBaseUpload.postValue("Success")
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {}
|
else -> {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
13
app/src/main/res/layout/fragment_login.xml
Normal file
13
app/src/main/res/layout/fragment_login.xml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context="com.example.hpostesting.presentation.dashboard.ui.LoginFragment">
|
||||||
|
|
||||||
|
<!-- TODO: Update blank fragment layout -->
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:text="@string/hello_blank_fragment" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
@@ -32,4 +32,9 @@
|
|||||||
android:id="@+id/mainActivity"
|
android:id="@+id/mainActivity"
|
||||||
android:name="com.example.hpostesting.presentation.MainActivity"
|
android:name="com.example.hpostesting.presentation.MainActivity"
|
||||||
android:label="MainActivity" />
|
android:label="MainActivity" />
|
||||||
|
<fragment
|
||||||
|
android:id="@+id/loginFragment"
|
||||||
|
android:name="com.example.hpostesting.presentation.dashboard.ui.LoginFragment"
|
||||||
|
android:label="fragment_login"
|
||||||
|
tools:layout="@layout/fragment_login" />
|
||||||
</navigation>
|
</navigation>
|
||||||
@@ -62,7 +62,7 @@
|
|||||||
<string name="step2"><b><u>Step 2</u> : </b> Press the button below to start the device reading values.</string>
|
<string name="step2"><b><u>Step 2</u> : </b> Press the button below to start the device reading values.</string>
|
||||||
|
|
||||||
<string name="step3"><b><u>Step 1</u> : </b> Enter the sample details to start.</string>
|
<string name="step3"><b><u>Step 1</u> : </b> Enter the sample details to start.</string>
|
||||||
<!-- <string name="step4"><b><u>Step 1</u> : </b> Place the cuvette containing sample for experiment.</string>-->
|
<!-- <string name="step4"><b><u>Step 1</u> : </b> Place the cuvette containing sample for experiment.</string>-->
|
||||||
<string name="step4"><b><u>Step 1</u> : </b> Place the cuvette containing blood sample mixed with kit solution.</string>
|
<string name="step4"><b><u>Step 1</u> : </b> Place the cuvette containing blood sample mixed with kit solution.</string>
|
||||||
<string name="step5"><b><u>Step 2</u> : </b> Press the button below to start the device reading values.</string>
|
<string name="step5"><b><u>Step 2</u> : </b> Press the button below to start the device reading values.</string>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user