I'm a newbie in Kotlin. I'm building an app like Twitter. I want to create custom class extends TwitterApiClient - to use more endpoints. Twitter's tutorial is here Tutorial
Here's my code:
class TwitterApiList(session: TwitterSession) : TwitterApiClient(session) {
fun getHomeTimeline(): TwitterCustom {
return getService(TwitterCustom::class.java)
}
}
// TwitterCustom interface
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 this line
apiClient.getHomeTimeline().home_timeline(null, null, null, object : Callback<List<Tweet>>()
Please help me to solve this problem.
Thank you all.