Android网络封装包:IceNet

jopen 10年前

这个库是一款Android网络封装,由Volley, OkHttpGson组合组成。
Initialization

public class YourApplications extends Application {      ...        @Override      public void onCreate() {          super.onCreate();          initIceNet();      }        public void initIceNet() {          IceNetConfig config = new IceNetConfig.Builder()                  .setBaseUrl(BuildConfig.SERVER_URL)                  .setContext(getApplicationContext())                  .build();          IceNet.init(config);      }        ...  }   

GET REQUEST

 IceNet.connect()                  .createRequest()                  .get()                  .pathUrl("/v1/feeds")                  .fromJsonArray()                  .mappingInto(Feeds.class)                  .execute(REQUEST_TAG, callback);


POST REQUEST

IceNet.connect()                  .createRequest()                  .post(bodyRequest)                  .pathUrl("/v1/feed")                  .fromJsonObject()                  .mappingInto(PostResponse.class)                  .execute(REQUEST_TAG, callback);


STRING REQUEST (NEW)

IceNet.connect()                  .createRequest()                  .get()                  .pathUrl("/string")                  .fromString()                  .execute("REQUEST_TAG", callback);

项目主页:http://www.open-open.com/lib/view/home/1425221223776</p> </strong>