V3.0 10-12汇总, 优化我的关注和登录页面
This commit is contained in:
@ -4,6 +4,7 @@ import android.app.Application;
|
||||
|
||||
import com.facebook.stetho.Stetho;
|
||||
import com.facebook.stetho.okhttp3.StethoInterceptor;
|
||||
import com.lightgame.utils.Utils;
|
||||
import com.squareup.leakcanary.LeakCanary;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
@ -34,11 +35,33 @@ public class Injection {
|
||||
}
|
||||
|
||||
public static OkHttpClient.Builder provideRetrofitBuilder() {
|
||||
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() {
|
||||
|
||||
@Override
|
||||
public void log(String message) {
|
||||
//分段打印retrofit日志
|
||||
if (message.startsWith("{") || message.startsWith("["))
|
||||
if (message.length() > 4000) {
|
||||
for (int i = 0; i < message.length(); i += 4000) {
|
||||
if (i + 4000 < message.length())
|
||||
Utils.log("OkHttp_Body::" + i, message.substring(i, i + 4000));
|
||||
else
|
||||
Utils.log("OkHttp_Body::" + i, message.substring(i, message.length()));
|
||||
}
|
||||
} else
|
||||
Utils.log("OkHttp_Body::", message);
|
||||
}
|
||||
});
|
||||
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
|
||||
OkHttpClient.Builder builder = new OkHttpClient.Builder();
|
||||
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
|
||||
interceptor.setLevel(HttpLoggingInterceptor.Level.BASIC);
|
||||
builder.addNetworkInterceptor(interceptor);
|
||||
builder.addNetworkInterceptor(new StethoInterceptor());
|
||||
if (BuildConfig.DEBUG) {
|
||||
builder.addNetworkInterceptor(loggingInterceptor);
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user