https://kotlinlang.org logo
#android
Title
# android
i

Iain

12/26/2017, 5:41 PM
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

adam-mcneilly

12/26/2017, 5:43 PM
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

Iain

12/26/2017, 5:52 PM
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

adam-mcneilly

12/26/2017, 6:33 PM
nailed it 😜
I just guessed the wrong one.
i

Iain

12/26/2017, 6:42 PM
Yup. Thanks for pointing me in the right direction.
a

adam-mcneilly

12/26/2017, 6:44 PM
No problem. A good chunk of software development is silly errors like this.
l

louiscad

12/27/2017, 12:25 AM
@Iain Doesn't directly solve your problem, but can help: https://github.com/gildor/kotlin-coroutines-retrofit
k

Katariya

12/27/2017, 3:10 AM
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.
2 Views