Retrofit 2.6.
@GET("/event")
suspend fun getEvents(@Query("orgn") base: Int, @Query("event") quote: Int): Response<List<Event>>
In service:
import retrofit2.Response
suspend fun getEvents(
orgn: Int,
event: Int,
isCustomtHandle: Boolean = false
): Response<*> {
return waitressCallRestClient.getEvents(orgn, event)
}
and in my ViewModel:
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
viewModelScope.launch(Dispatchers.Main) {
val response = TransportService.getEvents(100, 200)
if (response.isSuccessful) {
val eventList: List<Event> = response.body() as List<Event>
As you can see I must cast to List<Event>
Is it possible to avoid manual cast?