Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions app/src/main/java/org/piramalswasthya/cho/repositories/UserRepo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,25 @@ class UserRepo @Inject constructor(
val servicePointName = vanSp.getString("servicePointName")
user?.servicePointName = servicePointName
if (!vanSp.has("facilityID")) {
Toast.makeText(context, "Facility ID not found", Toast.LENGTH_LONG).show()
withContext(Dispatchers.Main) {
Toast.makeText(context, "Facility ID not found", Toast.LENGTH_LONG).show()
}
delay(3000)
// Set a default value instead of trying to access a non-existent field
user?.facilityID = -1 // Use a default value like -1 to indicate missing data
} else {
val facilityId = vanSp.getInt("facilityID")
user?.facilityID = facilityId
}
val facilityId = vanSp.getInt("facilityID")
user?.facilityID = facilityId
user?.parkingPlaceId = vanSp.getInt("parkingPlaceID")

if (!vanSp.has("parkingPlaceID")) {
user?.parkingPlaceId = -1 // Default value
} else {
user?.parkingPlaceId = vanSp.getInt("parkingPlaceID")
}
// Remove these redundant lines that are causing the crash
// val facilityId = vanSp.getInt("facilityID")
// user?.facilityID = facilityId
// user?.parkingPlaceId = vanSp.getInt("parkingPlaceID")
}
true
} else {
Expand Down