private static final HttpUntils ourInstance = new HttpUntils();api
public static HttpUntils getInstance() {
return ourInstance;
}ide
private HttpUntils() {
}ui
public static void getDataByRe(final ModelInf.CallBackLister callBackLister){
Retrofit retrofit = new Retrofit.Builder().baseUrl("http://mapi.univs.cn/").build();
ApiServier apiServier = retrofit.create(ApiServier.class);
Call<ResponseBody> data = apiServier.getData();
data.enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
try {
callBackLister.sendMessage(response.body().string());
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void onFailure(Call<ResponseBody> call, Throwable t) {.net
}
});
}get