Unable to create call adapter for class example.Simple

后端 未结 14 1221
隐瞒了意图╮
隐瞒了意图╮ 2020-12-04 23:14

I am using retrofit 2.0.0-beta1 with SimpleXml. I want the retrieve a Simple (XML) resource from a REST service. Marshalling/Unmarshalling the Simple object with SimpleXML w

14条回答
  •  感动是毒
    2020-12-04 23:42

    Just to make the Call examples clearer for people who are migrating, not using Rx, or who want synchronous calls - Call essentially replaces (wraps) Response, meaning:

    Response createRecord(...);
    

    becomes

    Call createRecord(...);
    

    and not

    Call> createRecord(...);
    

    (which will still require an adapter)


    The Call will then allow you to still use isSuccessful as it actually returns a Response. So you can do something like:

    myApi.createRecord(...).execute().isSuccessful()
    

    Or access your Type (MyObject) like:

    MyObject myObj = myApi.createRecord(...).execute().body();
    

提交回复
热议问题