try catch for user data load
This commit is contained in:
1
.idea/misc.xml
generated
1
.idea/misc.xml
generated
@@ -1,4 +1,3 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="DesignSurface">
|
<component name="DesignSurface">
|
||||||
<option name="filePathToZoomLevelMap">
|
<option name="filePathToZoomLevelMap">
|
||||||
|
|||||||
@@ -109,24 +109,30 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
private fun loadUserData() {
|
private fun loadUserData() {
|
||||||
val dateFormat = SimpleDateFormat("yyyy-MM-dd")
|
try {
|
||||||
val currentDate = Date()
|
val dateFormat = SimpleDateFormat("yyyy-MM-dd")
|
||||||
val formattedDate = dateFormat.format(currentDate)
|
val currentDate = Date()
|
||||||
val query = Firebase.firestore.collection("patientData").whereGreaterThanOrEqualTo("createdAt", formattedDate).orderBy("createdAt", Query.Direction.DESCENDING)
|
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)
|
// 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
|
||||||
} else {
|
} else {
|
||||||
binding.pendingTest.visibility = View.GONE
|
binding.pendingTest.visibility = View.GONE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
val recyclerViewOptions =
|
||||||
|
FirestoreRecyclerOptions.Builder<UserData>().setQuery(query, UserData::class.java)
|
||||||
|
.build()
|
||||||
|
rvAdapter = UserListAdapter(recyclerViewOptions, binding.root)
|
||||||
|
binding.rvOrder.adapter = rvAdapter
|
||||||
|
rvAdapter.startListening()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Firebase.crashlytics.recordException(e)
|
||||||
}
|
}
|
||||||
val recyclerViewOptions =
|
|
||||||
FirestoreRecyclerOptions.Builder<UserData>().setQuery(query, UserData::class.java)
|
|
||||||
.build()
|
|
||||||
rvAdapter = UserListAdapter(recyclerViewOptions, binding.root)
|
|
||||||
binding.rvOrder.adapter = rvAdapter
|
|
||||||
rvAdapter.startListening()
|
|
||||||
}
|
}
|
||||||
private fun saveUserId(userId: String) {
|
private fun saveUserId(userId: String) {
|
||||||
with(sharedPreference.edit()) {
|
with(sharedPreference.edit()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user