Ill*_*lyk 3 android kotlin rx-java retrofit2
我试着将Kotlin RxJava和retrofit2结合起来.
@GET("/xxxxxxxxxxxx/{id}.json")
fun getHotel(@Part("id") id : String) : Observable<Response<Hotel>>
Run Code Online (Sandbox Code Playgroud)
当我尝试调用此方法时(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)
Run Code Online (Sandbox Code Playgroud)
我拿这个:
@Part参数只能与多部分编码一起使用.
| 归档时间: |
|
| 查看次数: |
862 次 |
| 最近记录: |