Search in sources :

Example 21 with HttpLoggingInterceptor

use of okhttp3.logging.HttpLoggingInterceptor in project AnDevCon-RxPatterns by colintheshots.

the class Example9 method createDriveClient.

private void createDriveClient() {
    if (mDriveClient == null) {
        HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
        loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        OkHttpClient client = new OkHttpClient.Builder().addInterceptor(loggingInterceptor).addInterceptor(chain -> chain.proceed(chain.request().newBuilder().addHeader("Authorization", "Bearer " + Secrets.ACCESS_TOKEN).build())).build();
        mDriveClient = new Retrofit.Builder().addCallAdapterFactory(RxJavaCallAdapterFactory.createWithScheduler(Schedulers.io())).addConverterFactory(GsonConverterFactory.create()).client(client).baseUrl(DRIVE_BASE_URL).build().create(DriveClient.class);
    }
}
Also used : Part(retrofit2.http.Part) Bundle(android.os.Bundle) Environment(android.os.Environment) ImageView(android.widget.ImageView) AndroidSchedulers(rx.android.schedulers.AndroidSchedulers) Action1(rx.functions.Action1) ArrayList(java.util.ArrayList) RequestBody(okhttp3.RequestBody) Observable(rx.Observable) Picasso(com.squareup.picasso.Picasso) Header(retrofit2.http.Header) Multipart(retrofit2.http.Multipart) Func2(rx.functions.Func2) GsonConverterFactory(retrofit2.converter.gson.GsonConverterFactory) Schedulers(rx.schedulers.Schedulers) Canvas(android.graphics.Canvas) Matrix(android.graphics.Matrix) POST(retrofit2.http.POST) Log(android.util.Log) MediaType(okhttp3.MediaType) Expose(com.google.gson.annotations.Expose) IOException(java.io.IOException) File(java.io.File) Retrofit(retrofit2.Retrofit) List(java.util.List) OkHttpClient(okhttp3.OkHttpClient) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor) Bitmap(android.graphics.Bitmap) RxJavaCallAdapterFactory(retrofit2.adapter.rxjava.RxJavaCallAdapterFactory) Activity(android.app.Activity) Retrofit(retrofit2.Retrofit) OkHttpClient(okhttp3.OkHttpClient) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor)

Example 22 with HttpLoggingInterceptor

use of okhttp3.logging.HttpLoggingInterceptor in project AnDevCon-RxPatterns by colintheshots.

the class Example1 method createGithubClient.

private void createGithubClient() {
    if (mGitHubClient == null) {
        HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
        loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        OkHttpClient client = new OkHttpClient.Builder().addInterceptor(loggingInterceptor).addInterceptor(chain -> chain.proceed(chain.request().newBuilder().addHeader("Authorization", "token " + Secrets.GITHUB_PERSONAL_ACCESS_TOKEN).build())).build();
        mGitHubClient = new Retrofit.Builder().client(client).addCallAdapterFactory(RxJavaCallAdapterFactory.createWithScheduler(Schedulers.io())).addConverterFactory(GsonConverterFactory.create()).baseUrl(GITHUB_BASE_URL).build().create(GitHubClient.class);
    }
}
Also used : Context(android.content.Context) Iterables(com.google.common.collect.Iterables) Bundle(android.os.Bundle) AndroidSchedulers(rx.android.schedulers.AndroidSchedulers) Action1(rx.functions.Action1) Observable(rx.Observable) Func1(rx.functions.Func1) Toast(android.widget.Toast) Map(java.util.Map) GsonConverterFactory(retrofit2.converter.gson.GsonConverterFactory) Schedulers(rx.schedulers.Schedulers) View(android.view.View) Expose(com.google.gson.annotations.Expose) LayoutInflater(android.view.LayoutInflater) ViewGroup(android.view.ViewGroup) Retrofit(retrofit2.Retrofit) List(java.util.List) TextView(android.widget.TextView) OkHttpClient(okhttp3.OkHttpClient) BaseAdapter(android.widget.BaseAdapter) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor) GET(retrofit2.http.GET) RxJavaCallAdapterFactory(retrofit2.adapter.rxjava.RxJavaCallAdapterFactory) Path(retrofit2.http.Path) ListView(android.widget.ListView) Activity(android.app.Activity) Retrofit(retrofit2.Retrofit) OkHttpClient(okhttp3.OkHttpClient) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor)

Example 23 with HttpLoggingInterceptor

use of okhttp3.logging.HttpLoggingInterceptor in project Varis-Android by dkhmelenko.

the class NetworkModule method okHttpClient.

@Provides
@Singleton
public OkHttpClient okHttpClient() {
    HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
    interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
    return new OkHttpClient.Builder().addInterceptor(interceptor).followRedirects(false).followSslRedirects(false).build();
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Aggregations

HttpLoggingInterceptor (okhttp3.logging.HttpLoggingInterceptor)22 OkHttpClient (okhttp3.OkHttpClient)17 Provides (dagger.Provides)11 Retrofit (retrofit2.Retrofit)10 Singleton (javax.inject.Singleton)9 GsonBuilder (com.google.gson.GsonBuilder)7 File (java.io.File)6 Cache (okhttp3.Cache)6 GsonConverterFactory (retrofit2.converter.gson.GsonConverterFactory)6 Observable (rx.Observable)6 StethoInterceptor (com.facebook.stetho.okhttp3.StethoInterceptor)5 List (java.util.List)5 Interceptor (okhttp3.Interceptor)5 Activity (android.app.Activity)4 Bundle (android.os.Bundle)4 ListView (android.widget.ListView)4 Gson (com.google.gson.Gson)4 Expose (com.google.gson.annotations.Expose)4 RxJavaCallAdapterFactory (retrofit2.adapter.rxjava.RxJavaCallAdapterFactory)4 Context (android.content.Context)3