I’m not sure if this is a Kotlin question, an Andr...
# android
i
I’m not sure if this is a Kotlin question, an Android question, or a Retrofit question but here goes,
Copy code
class GetCoordinatesApiManager: Callback<LocationResult> {

    var completionHandler: (flag:Boolean) -> Unit = {}

    fun getCoordinates(userIds: ArrayList<Int>, handler: (flag: Boolean) -> Unit) {
        completionHandler = handler
        ApiClient.apiInterface.getCoordinates(userIds, UserState.bearerToken!!).enqueue(this)
    }
Android Studio complains that
this
in
enqueue(this)
is
Type Mismatch Required: Callback <LocationResult!>! Found: GetCoordinatesApiManager
a
Just for kicks - did you triple check if it is importing the right callback class? I've been bit by this before when multiple libraries have a class named
Callback
.
i
Yeah, it’s importing
retrofit2.Callback
just like the other class. I’ve been bitten by that one already.
It seems to have something to do with the type in the callback
It’s in the ApiClient.apiInterface. It’s pulling in a Google UserLocation object instead of my UserLocation.
So it was importing the wrong class, after all. 😜
a
nailed it 😜
I just guessed the wrong one.
i
Yup. Thanks for pointing me in the right direction.
a
No problem. A good chunk of software development is silly errors like this.
l
@Iain Doesn't directly solve your problem, but can help: https://github.com/gildor/kotlin-coroutines-retrofit
k
Thanks for your replies, I have made a mistake in model class. Actually I have copied param names from json2pojo and pojo param replace user_name to username.