3
我試着將Kotlin RxJava和retrofit2結合起來。Retrofit2和kotlin
@GET("/xxxxxxxxxxxx/{id}.json")
fun getHotel(@Part("id") id : String) : Observable<Response<Hotel>>
當我嘗試調用此方法(getHotels()):
var subscription = HotelsFactory.getHotelService((activity.applicationContext as App)
.client)
.getHotel(arguments.getInt("id").toString())
.subscribeOn(Schedulers.computation())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({response -> showHotels(response)})
{throwable -> throwable.printStackTrace()}
mSubscription.add(subscription)
我藉此之一:
@part參數只能與多部分編碼時使用。
您應該使用'@ Path'而不是'@ Part' – jturolla