Ayden
06/17/2018, 1:05 AMMainActivity.kt
fun retrieveApiData() {
val vibeApi: VibeApi
var vibeList = mutableListOf<Vibes>()
val retrofit: Retrofit = Retrofit.Builder()
.baseUrl(Constants.baseUrl)
.addConverterFactory(MoshiConverterFactory.create())
.build()
vibeApi = retrofit.create(VibeApi::class.java)
val call = vibeApi.getVibes()
// Object is not abstract and does not implement abstract member public abstract fun onResponse(call: Call<kotlin.collections.ArrayList<VibeList> /* = java.util.ArrayList<VibeList> */!>!, response: Response<kotlin.collections.ArrayList<VibeList> /* = java.util.ArrayList<VibeList> */!>!): Unit defined in retrofit2.Callback
call.enqueue(object: Callback<ArrayList<VibeList>> {
// Modifier 'override' is not applicable to 'local function'
override fun onResponse(call: Call<Vibes>?, response: Response<Vibes>?) {
var vibes = response?.body()
}
// Modifier 'override' is not applicable to 'local function'
override fun onFailure(call: Call<Vibes>?, t: Throwable?) {
Log.d("Vibe Adapter", "Failure")
}
})
}
DataClass
data class Vibes(@Json(name = "result") val vibeList: ArrayList<VibeList>)
data class VibeList(
@Json(name = "id") val id: Integer?,
@Json(name = "url") val url: String?,
@Json(name = "author") val author: String?)
rkeazor
06/17/2018, 3:24 AMrkeazor
06/17/2018, 3:28 AMtrevjones
06/17/2018, 4:26 AMonResponse
and onFailure
are marked as null which was probably done by the IDE auto complete. but the compiler is probably respecting the non null by default behavior that the squares put into these libraries last year. because of the mis match of nullability the compiler is saying the method signatures don't match thus the override is invalid
and the object doesn't implement fun
errorstrevjones
06/17/2018, 4:30 AMList
you are using val and immutable types everywhere else so I would guess you don't need or want the mutable list interface exposed there.Ayden
06/17/2018, 7:26 AMAyden
06/17/2018, 7:26 AMAyden
06/17/2018, 7:32 AMrkeazor
06/17/2018, 12:02 PMrkeazor
06/17/2018, 12:04 PMrkeazor
06/17/2018, 12:05 PMrkeazor
06/17/2018, 12:10 PMrkeazor
06/17/2018, 12:21 PMAyden
06/17/2018, 2:29 PMAyden
06/17/2018, 2:29 PMAyden
06/17/2018, 2:29 PMrkeazor
06/17/2018, 2:31 PMrkeazor
06/17/2018, 2:31 PM