Retrofit

作者: 人心所向便是阳光 | 来源:发表于2018-12-20 18:57 被阅读0次

代码

public class RetrofitUtil {
private static RetrofitUtil instance;
private Retrofit mRetrofit;
public static RetrofitUtil getInstance() {
    if (instance==null) {
        instance=new RetrofitUtil();
    }
    return instance;
}

public RetrofitUtil() {
    mRetrofit=new Retrofit.Builder()
            .baseUrl(GlobalConstant.BASE_URL)
            .addConverterFactory(GsonConverterFactory.create())
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .client(OkHttpUtil.okHttpClient)
            .build();
}

public <T> T create(Class<T> cls){
    T t = mRetrofit.create(cls);
    return t;
}
}

相关文章

网友评论

      本文标题:Retrofit

      本文链接:https://www.haomeiwen.com/subject/zwdukqtx.html