public class HttpUtils<T> {
private HttpUtils() {}
//单例模式
public static HttpUtils getHttpUtilsInstance(){
return HttpUtilsInstance.httpUtils;
}
private static class HttpUtilsInstance{
private static HttpUtils httpUtils=new HttpUtils();
}
//拦截器
private static Interceptor getAppInterceptor(){
Interceptor interceptor = new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
Log.i("aaa","--------"+"拦截前");
Response response = chain.proceed(request);
Log.i("aaa","--------"+"拦截后");
return response;
}
};
return interceptor;
}
}
单例模式与拦截器
最新推荐文章于 2023-08-19 10:19:14 发布