I’m a newbie at Kotlin, and I’m building an Android app like Twitter using Kotlin. But Twitter has no tutorial for Kotlin.
I read a tutorial here Adding custom queries [Android]
I want to ask a version of Kotlin for above tutorial, but that topic is closed.
Here is my code
class TwitterApiList(session: TwitterSession) : TwitterApiClient(session) {
fun getHomeTimeline(): TwitterCustom {
return getService(TwitterCustom::class.java)
}
}
public interface TwitterCustom {
@GET("/1.1/statuses/home_timeline.json")
fun home_timeline(@Query("count") count: Int?, @Query("since_id") since_id: Int?, @Query("max_id") max_id: Int?, cb: Callback<List<Tweet>>)
}
// And how I use it
val apiClient = TwitterApiList(TwitterCore.getInstance().sessionManager.activeSession)
apiClient.getHomeTimeline().home_timeline(null, null, null, object : Callback<List<Tweet>>() {
override fun success(result: Result<List<Tweet>>?) {
Log.d("result", result.toString())
}
override fun failure(exception: TwitterException?) {
Log.d("failed", exception?.message)
}
})
When I run app, it’s always crash with message “Service methods cannot return void.” at the line
apiClient.getHomeTimeline().home_timeline(null, null, null, object : Callback<List<Tweet>>()
Please help me fix this.
Thank you all.