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
28 changes: 20 additions & 8 deletions app/src/main/java/org/piramalswasthya/cho/repositories/UserRepo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -217,25 +217,34 @@
val responseJson = JSONObject(responseString)
val data = responseJson.getJSONObject("data")
val vanSpDetailsArray = data.getJSONArray("UserVanSpDetails")
var validEntryFound = false
var missingFacilityFound = false

for (i in 0 until vanSpDetailsArray.length()) {
val vanSp = vanSpDetailsArray.getJSONObject(i)
if (!vanSp.has("facilityID")) {
missingFacilityFound = true
continue
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
validEntryFound = true
val vanId = vanSp.getInt("vanID")
user?.vanId = vanId
val servicePointId = vanSp.getInt("servicePointID")
user?.servicePointId = servicePointId
val servicePointName = vanSp.getString("servicePointName")
user?.servicePointName = servicePointName
if (!vanSp.has("facilityID")) {
Toast.makeText(context, "Facility ID not found", Toast.LENGTH_LONG).show()
delay(3000)
}
val facilityId = vanSp.getInt("facilityID")
user?.facilityID = facilityId
user?.parkingPlaceId = vanSp.getInt("parkingPlaceID")

}
true
if (missingFacilityFound) {
withContext(Dispatchers.Main) {

Check warning on line 242 in app/src/main/java/org/piramalswasthya/cho/repositories/UserRepo.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Avoid hardcoded dispatchers.

See more on https://sonarcloud.io/project/issues?id=PSMRI_HWC-Mobile-App&issues=AZ3Aoc4Vhn7hAhIBrEnB&open=AZ3Aoc4Vhn7hAhIBrEnB&pullRequest=253
Toast.makeText(context, "Facility ID not found", Toast.LENGTH_LONG).show()
}
delay(3000)
}
validEntryFound
} else {
false
}
Expand Down Expand Up @@ -328,10 +337,13 @@
user?.serviceMapId = serviceMapId
TokenInsertTmcInterceptor.setToken(token)
preferenceDao.registerPrimaryApiToken(token)
preferenceDao.registerUser(user!!)
getUserVanSpDetails(context)
if (!getUserVanSpDetails(context)) {
user = null
return@withContext
}
getLocDetailsBasedOnSpIDAndPsmID()
getUserMasterVillage()
preferenceDao.registerUser(user!!)
} else {
val errorMessage = responseBody.getString("errorMessage")
GlobalScope.launch(Dispatchers.Main) {
Expand Down Expand Up @@ -598,4 +610,4 @@
return true
}

}
}