Search in sources :

Example 1 with Logger

use of com.justwayward.reader.api.support.Logger in project BookReader by JustWayward.

the class BookApiModule method provideOkHttpClient.

@Provides
public OkHttpClient provideOkHttpClient() {
    LoggingInterceptor logging = new LoggingInterceptor(new Logger());
    logging.setLevel(LoggingInterceptor.Level.BODY);
    OkHttpClient.Builder builder = new OkHttpClient.Builder().connectTimeout(10, TimeUnit.SECONDS).connectTimeout(20 * 1000, TimeUnit.MILLISECONDS).readTimeout(20 * 1000, TimeUnit.MILLISECONDS).retryOnConnectionFailure(// 失败重发
    true).addInterceptor(new HeaderInterceptor()).addInterceptor(logging);
    return builder.build();
}
Also used : LoggingInterceptor(com.justwayward.reader.api.support.LoggingInterceptor) OkHttpClient(okhttp3.OkHttpClient) HeaderInterceptor(com.justwayward.reader.api.support.HeaderInterceptor) Logger(com.justwayward.reader.api.support.Logger) Provides(dagger.Provides)

Example 2 with Logger

use of com.justwayward.reader.api.support.Logger in project BookReader by JustWayward.

the class DownloadBookService method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    EventBus.getDefault().register(this);
    LoggingInterceptor logging = new LoggingInterceptor(new Logger());
    logging.setLevel(LoggingInterceptor.Level.BODY);
    bookApi = ReaderApplication.getsInstance().getAppComponent().getReaderApi();
}
Also used : LoggingInterceptor(com.justwayward.reader.api.support.LoggingInterceptor) Logger(com.justwayward.reader.api.support.Logger)

Aggregations

Logger (com.justwayward.reader.api.support.Logger)2 LoggingInterceptor (com.justwayward.reader.api.support.LoggingInterceptor)2 HeaderInterceptor (com.justwayward.reader.api.support.HeaderInterceptor)1 Provides (dagger.Provides)1 OkHttpClient (okhttp3.OkHttpClient)1