The below is my code where im trying to return false whenever the body is not empty, but the variable blocker is not overwritten when the body has content in it. The code itself is working but it seems to not get the Code out of the onResponse method.
private fun checkTime(date : String, time : String): Boolean {
var blocker = true
val checkapt = ReservationBySalon(
listOf(CheckApt(
hairdresser_key = "asru6sxqrifl",
date = date,
status = "aktiv",
time_from = time)
))
val retrofitData = DbApi.retrofitService.validateAppointment(checkapt)
retrofitData.enqueue(object : Callback<ReservationsList?> {
override fun onResponse(
call: Call<ReservationsList?>,
response: Response<ReservationsList?>
) {
if(response.body()?.paging.toString() > 0.toString()){
blocker = false
}else{
}
}
override fun onFailure(call: Call<ReservationsList?>, t: Throwable) {
Log.e("Reserve", "onFailure: " + t.message)
}
})
return blocker
}
Answers are much appreciated