You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So what am trying to do here is, i take 3 routes from the map when user chooses a location to go, from these routes i take all the pins
and compare them with my pin list(i take it from our backend) for calculating toll price. But when i try to do this on background with another thread using coroutine, library wouldnt allow me to do and gives a crash or when i try to do it foreground it freezes the ui of course.
What am i suppose to do here ?
this is my method for comparing lists and posting them on our api.
private fun calculateTollPrice(routes: List) {
val highwayTollList = retrieveDataModelSharedPref(
"PIN_TOLL_LIST",
PinTollListResponse::class.java
)
val vehicleType = SPUtils.getInstance().getInt(SPPARAM.VEHICLE_TYPE)
var tmpTollPointLoc: Point
routes.forEachIndexed { index, drivingRoute ->
if (drivingRoute.metadata.flags.hasTolls) {
drivingRoute.geometry.points.forEach { point ->
tollList.addAll(highwayTollList?.items?.filter { tollItem ->
tmpTollPointLoc = Point(tollItem.latitude, tollItem.longitude)
val distance = Geo.distance(tmpTollPointLoc, point)
distance < tollItem.radius
} ?: emptyList()
)
}
viewModel.calculateTollPrice(
CalculateTollPriceRequest(
tollList.distinctBy { it.id },
index,
tollList.count(),
vehicleType
)
)
tollList.clear()
}
}
}
The text was updated successfully, but these errors were encountered:
So what am trying to do here is, i take 3 routes from the map when user chooses a location to go, from these routes i take all the pins
and compare them with my pin list(i take it from our backend) for calculating toll price. But when i try to do this on background with another thread using coroutine, library wouldnt allow me to do and gives a crash or when i try to do it foreground it freezes the ui of course.
What am i suppose to do here ?
this is my method for comparing lists and posting them on our api.
private fun calculateTollPrice(routes: List) {
The text was updated successfully, but these errors were encountered: