add logiid in constants and userlist order

This commit is contained in:
Pritimay Sarkar
2023-09-27 02:55:09 +05:30
parent 9b38a5dff7
commit e1dbfc9d89
4 changed files with 23 additions and 28 deletions

View File

@@ -51,6 +51,16 @@ object Constants {
"HC-V1-008", "HC-V1-008",
"HC-V1-009", "HC-V1-009",
"HC-V1-010", "HC-V1-010",
"HC-V1-011",
"HC-V1-012",
"HC-V1-013",
"HC-V1-014",
"HC-V1-015",
"HC-V1-016",
"HC-V1-017",
"HC-V1-018",
"HC-V1-019",
"HC-V1-020",
) )
const val password = "SMI@12345" const val password = "SMI@12345"

View File

@@ -10,6 +10,7 @@ import com.example.hpostesting.data.model.patient.DeviceData
import com.example.hpostesting.data.model.patient.HemoCubeTestData import com.example.hpostesting.data.model.patient.HemoCubeTestData
import com.example.hpostesting.data.model.patient.UserData import com.example.hpostesting.data.model.patient.UserData
import com.google.android.datatransport.runtime.dagger.Provides import com.google.android.datatransport.runtime.dagger.Provides
import com.google.firebase.crashlytics.ktx.crashlytics
import com.google.firebase.firestore.FirebaseFirestore import com.google.firebase.firestore.FirebaseFirestore
import com.google.firebase.firestore.ktx.firestore import com.google.firebase.firestore.ktx.firestore
import com.google.firebase.ktx.Firebase import com.google.firebase.ktx.Firebase
@@ -40,7 +41,6 @@ class DatabaseRepository : Repository {
} }
} }
suspend fun addTestToDatabase(data: UserData?): Response<String> { suspend fun addTestToDatabase(data: UserData?): Response<String> {
return try { return try {
val userdata = db.collection("patientData").whereEqualTo("_id", data!!._id).get().await() val userdata = db.collection("patientData").whereEqualTo("_id", data!!._id).get().await()
@@ -52,14 +52,11 @@ class DatabaseRepository : Repository {
db.collection("testData").add(data!!).await() db.collection("testData").add(data!!).await()
Response.Success(data!!._id) Response.Success(data!!._id)
} catch (e: Exception) { } catch (e: Exception) {
Firebase.crashlytics.recordException(e)
Response.Error(e) Response.Error(e)
} }
} }
suspend fun uploadFileToStorage(patientID: String, filePath: String): Response<Boolean> { suspend fun uploadFileToStorage(patientID: String, filePath: String): Response<Boolean> {
try { try {
@@ -67,9 +64,8 @@ class DatabaseRepository : Repository {
val riversRef = storage.reference.child("$patientID/${file.lastPathSegment}") val riversRef = storage.reference.child("$patientID/${file.lastPathSegment}")
riversRef.putFile(file).await() riversRef.putFile(file).await()
return Response.Success(true) return Response.Success(true)
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() Firebase.crashlytics.recordException(e)
return Response.Error(e) return Response.Error(e)
} }
} }
@@ -81,7 +77,7 @@ class DatabaseRepository : Repository {
Response.Success(true) Response.Success(true)
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() Firebase.crashlytics.recordException(e)
Response.Error(e) Response.Error(e)
} }
} }
@@ -100,7 +96,7 @@ class DatabaseRepository : Repository {
pendingList pendingList
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() Firebase.crashlytics.recordException(e)
pendingList pendingList
} }
} }
@@ -111,7 +107,7 @@ class DatabaseRepository : Repository {
Response.Success(true) Response.Success(true)
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() Firebase.crashlytics.recordException(e)
Response.Error(e) Response.Error(e)
} }
} }
@@ -120,7 +116,6 @@ class DatabaseRepository : Repository {
return db.collection("devices").get().await().toObjects(DeviceData::class.java) return db.collection("devices").get().await().toObjects(DeviceData::class.java)
} }
suspend fun getDeviceDataById(deviceId: String): DeviceData? { suspend fun getDeviceDataById(deviceId: String): DeviceData? {
val querySnapshot = db.collection("devices").get().await() val querySnapshot = db.collection("devices").get().await()
val allDeviceDataList = querySnapshot.toObjects(DeviceData::class.java) val allDeviceDataList = querySnapshot.toObjects(DeviceData::class.java)
@@ -128,7 +123,4 @@ class DatabaseRepository : Repository {
// Find the DeviceData object with the specified deviceId // Find the DeviceData object with the specified deviceId
return allDeviceDataList.find { it.deviceId == deviceId } return allDeviceDataList.find { it.deviceId == deviceId }
} }
} }

View File

@@ -90,18 +90,6 @@ class MainActivity : AppCompatActivity() {
startActivity(Intent(this, DashboardActivity::class.java)) startActivity(Intent(this, DashboardActivity::class.java))
finish() finish()
} }
// val crashButton = Button(this)
// crashButton.text = "Test Crash"
// crashButton.setOnClickListener {
// throw RuntimeException("Test Crash") // Force a crash
// }
//
// addContentView(crashButton, ViewGroup.LayoutParams(
// ViewGroup.LayoutParams.MATCH_PARENT,
// ViewGroup.LayoutParams.WRAP_CONTENT))
} }
private fun checkAndUpdateUsbConnection() { private fun checkAndUpdateUsbConnection() {

View File

@@ -28,6 +28,8 @@ import com.google.firebase.ktx.Firebase
import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.AndroidEntryPoint
import `in`.sminnovations.hpostesting.R import `in`.sminnovations.hpostesting.R
import `in`.sminnovations.hpostesting.databinding.FragmentHomeBinding import `in`.sminnovations.hpostesting.databinding.FragmentHomeBinding
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale import java.util.Locale
@AndroidEntryPoint @AndroidEntryPoint
@@ -107,8 +109,11 @@ class HomeFragment : Fragment() {
} }
} }
private fun loadUserData() { private fun loadUserData() {
val query = Firebase.firestore.collection("patientData").whereEqualTo("testStatus", false) val dateFormat = SimpleDateFormat("yyyy-MM-dd")
// .orderBy("createdAt", Query.Direction.DESCENDING) val currentDate = Date()
val formattedDate = dateFormat.format(currentDate)
val query = Firebase.firestore.collection("patientData").whereGreaterThanOrEqualTo("createdAt", formattedDate).orderBy("createdAt", Query.Direction.DESCENDING)
// val query = Firebase.firestore.collection("patientData").whereEqualTo("testStatus", false)
query.get().addOnSuccessListener { query.get().addOnSuccessListener {
if (it.documents.isEmpty()) { if (it.documents.isEmpty()) {
binding.pendingTest.visibility = View.VISIBLE binding.pendingTest.visibility = View.VISIBLE