Java 类com.facebook.stetho.okhttp.StethoInterceptor 实例源码

项目:apna-library    文件:ApiClient.java   
/**
 * Initializes the adapter and returns it
 * The REST Adapter is created with Retrofit methods defined in MainApiClient
 * Injects authorization headers into request
 * Inspects status codes from response
 * @return rest adapter
 */
private MainApiClient getRestAdapter() {

    httpClient = new OkHttpClient();
    httpClient.networkInterceptors().add(new StethoInterceptor());
    httpClient.interceptors().add(new Interceptor() {
        @Override
        public com.squareup.okhttp.Response intercept(Chain chain) throws IOException {
            Request request = chain.request();
            com.squareup.okhttp.Response response = chain.proceed(request);
            statusCode = response.code();
            return response;
        }
    });

    mRestAdapter = new RestAdapter.Builder()
            .setEndpoint(URL_UAT)
            .setClient(new OkClient(httpClient))
            .setRequestInterceptor(authHeader())
            .setLogLevel(RestAdapter.LogLevel.FULL)
            .build();

    return mRestAdapter.create(MainApiClient.class);
}
项目:LoopSeries-Mobile    文件:APIFactory.java   
public static APIService instance() {
    synchronized (APIFactory.class) {
        if (sAPIServiceInstance == null) {
            Gson gson = new GsonBuilder()
                    .create();
            OkHttpClient client = new OkHttpClient();
            client.networkInterceptors().add(new StethoInterceptor());
            /**
             * please see http://git.io/vcure to setup your own server
             * or PM @joshlopes to ask for our domain/clientId/secret
             */
            Retrofit retrofit = new Retrofit.Builder()
                    .baseUrl(LoopAnimeAPISettings.BASE_URL)
                    .client(client)
                    .addConverterFactory(GsonConverterFactory.create(gson))
                    .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                    .build();
            sAPIServiceInstance = retrofit.create(APIService.class);
        }
    }
    return sAPIServiceInstance;
}
项目:tuchong-daily-android    文件:APIFactory.java   
public static API instance() {
    if (instance == null) {
        OkHttpClient client = new OkHttpClient();
        if (BuildConfig.DEBUG) {
            client.networkInterceptors().add(new StethoInterceptor());
        }

        RestAdapter restAdapter = new RestAdapter.Builder()
                .setEndpoint(BASE_URL)
                .setClient(new OkClient(client))
                .setLogLevel(RestAdapter.LogLevel.FULL)
                .build();
        instance = new API(restAdapter.create(APIGet.class));
    }
    return instance;
}
项目:tuchong-daily-android    文件:TuchongApplication.java   
public void setPicasso() {
    OkHttpClient client = new OkHttpClient();
    client.networkInterceptors().add(new StethoInterceptor());
    File cache = new File(this.getCacheDir(), PICASSO_CACHE);
    if (!cache.exists()) {
        //noinspection ResultOfMethodCallIgnored
        cache.mkdirs();
    }
    try {
        client.setCache(new Cache(cache, PICASSO_CACHE_SIZE));
    } catch (IOException e) {
        e.printStackTrace();
    }
    Picasso picasso = new Picasso.Builder(this)
            .downloader(new OkHttpDownloader(client))
            .build();
    Picasso.setSingletonInstance(picasso);
}
项目:Vapor    文件:OkCloudAppModule.java   
@Provides
@Singleton
public OkHttpClient providesOkHttpClient(Context context) {
    OkHttpClient client = new OkHttpClient();
    HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
    interceptor.setLevel(HttpLoggingInterceptor.Level.HEADERS);
    client.interceptors().add(interceptor);
    client.networkInterceptors().add(new StethoInterceptor());
    File httpCacheDir = new File(context.getCacheDir() + "/okhttp");
    httpCacheDir.mkdirs();
    cleanDir(httpCacheDir);
    long httpCacheSize = 50 * 1024 * 1024; // 50 MiB
    Cache cache = new Cache(httpCacheDir, httpCacheSize);
    client.setCache(cache);
    return client;
}
项目:hacker-news-android    文件:LoginViewModel.java   
public LoginViewModel() {

        List<Interceptor> interceptors = new ArrayList<>();
        interceptors.add(new StethoInterceptor());
        interceptors.add(chain -> {
            Response response = chain.proceed(chain.request());
            List<String> cookieHeaders = response.headers("set-cookie");
            for (String header : cookieHeaders) {
                if (header.contains("user")) {
                    mUserCookie = header.split(";")[0];
                }
                else if(header.contains("__cfduid")){
                    mCfduid = header.split(";")[0];
                }
            }
            return response;
        });
        DaggerNetworkServiceComponent.builder()
                                     .okClientModule(new OkClientModule(interceptors))
                                     .appModule(HackerNewsApplication.getAppModule())
                                     .appComponent(HackerNewsApplication.getAppComponent())
                                     .build()
                                     .inject(this);
    }
项目:ReactNativeSignatureExample    文件:NetworkingModule.java   
NetworkingModule(
    ReactApplicationContext reactContext,
    @Nullable String defaultUserAgent,
    OkHttpClient client) {
  super(reactContext);
  mClient = client;
  mClient.networkInterceptors().add(new StethoInterceptor());
  mCookieHandler = new ForwardingCookieHandler(reactContext);
  mShuttingDown = false;
  mDefaultUserAgent = defaultUserAgent;
}
项目:react-native-ibeacon-android    文件:NetworkingModule.java   
NetworkingModule(
    ReactApplicationContext reactContext,
    @Nullable String defaultUserAgent,
    OkHttpClient client) {
  super(reactContext);
  mClient = client;
  mClient.networkInterceptors().add(new StethoInterceptor());
  mCookieHandler = new ForwardingCookieHandler(reactContext);
  mShuttingDown = false;
  mDefaultUserAgent = defaultUserAgent;
}
项目:SongkickInterview    文件:NetworkModule.java   
@Provides
@Singleton
OkHttpClient provideOkHttp(final Cache cache, LoggerInterceptor loggerInterceptor,
        StethoInterceptor stethoInterceptor) {
    final OkHttpClient okHttpClient = new OkHttpClient();
    okHttpClient.setCache(cache);
    okHttpClient.networkInterceptors().add(loggerInterceptor);
    okHttpClient.networkInterceptors().add(stethoInterceptor);
    okHttpClient.setConnectTimeout(DEFAULT_CONNECT_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
    okHttpClient.setReadTimeout(DEFAULT_READ_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
    okHttpClient.setWriteTimeout(DEFAULT_WRITE_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
    return okHttpClient;
}
项目:githot    文件:ApiClient.java   
/**
 * 用于Stethoscope调试的ttpClient
 */
public static OkClient getOkClient() {
    OkHttpClient client = new OkHttpClient();
    client.setConnectTimeout(CONNECT_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
    client.setReadTimeout(READ_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
    client.networkInterceptors().add(new StethoInterceptor());
    return new OkClient(client);
}
项目:OkDownload    文件:MyApplication.java   
@Override
public void onCreate() {
    super.onCreate();
    Stetho.initializeWithDefaults(this);
    OkHttpClient client = new OkHttpClient();
    client.networkInterceptors().add(new StethoInterceptor());
}
项目:MovieMe    文件:ApiModule.java   
@Provides
@Singleton
OkHttpClient provideOkHttpClient(Interceptor interceptor) {
    OkHttpClient okHttpClient = new OkHttpClient();

    okHttpClient.interceptors().add(interceptor);

    if (BuildConfig.DEBUG)
        okHttpClient.networkInterceptors().add(new StethoInterceptor());

    return okHttpClient;
}
项目:FRC-Krawler    文件:HTTP.java   
public static OkHttpClient getClient() {
    if (client == null) {
        client = new OkHttpClient();
        client.setReadTimeout(10, TimeUnit.SECONDS);
        client.networkInterceptors().add(new StethoInterceptor());
    }
    return client;
}
项目:BuenosAiresAntesYDespues    文件:ApiConnection.java   
private OkHttpClient createClient() {
    HttpLoggingInterceptor.Level logLevel = HttpLoggingInterceptor.Level.BODY;
    HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();
    httpLoggingInterceptor.setLevel(logLevel);

    final OkHttpClient okHttpClient = new OkHttpClient();
    okHttpClient.networkInterceptors().add(new StethoInterceptor());
    okHttpClient.networkInterceptors().add(httpLoggingInterceptor);
    okHttpClient.setReadTimeout(10000, TimeUnit.MILLISECONDS);
    okHttpClient.setConnectTimeout(15000, TimeUnit.MILLISECONDS);

    return okHttpClient;
}
项目:hacker-news-android    文件:OkClientModule.java   
@Provides
@Named("okclient")
OkClient providesOkClient(){
    OkHttpClient okHttpClient = new OkHttpClient();
    okHttpClient.setFollowRedirects(true);
    okHttpClient.setFollowSslRedirects(true);

    if(mInterceptorList != null){
        okHttpClient.networkInterceptors().addAll(mInterceptorList);
    }

    okHttpClient.networkInterceptors().add(new StethoInterceptor());

    return new OkClient(okHttpClient);
}
项目:soundmap    文件:InstrumentationModule.java   
@Provides
@Singleton
@ApiModule.NetworkInterceptors
List<Interceptor> provideNetworkInterceptors() {
    ArrayList<Interceptor> networkInterceptors = new ArrayList<>();
    networkInterceptors.add(new StethoInterceptor());
    return networkInterceptors;
}
项目:LoopSeries-Mobile    文件:LoopAnimeGlideModule.java   
@Override
public void registerComponents(Context context, Glide glide) {
    if (BuildConfig.DEBUG) {
        OkHttpClient client = new OkHttpClient();
        client.networkInterceptors().add(new StethoInterceptor());
        OkHttpUrlLoader.Factory factory = new OkHttpUrlLoader.Factory(client);
        glide.register(GlideUrl.class, InputStream.class, factory);
    }
}
项目:redbooth-android-demo    文件:ApiModule.java   
@Provides @Singleton OkHttpClient provideOkHttpClient() {
    OkHttpClient client = new OkHttpClient();
    client.networkInterceptors().add(new StethoInterceptor());
    return client;
}
项目:SongkickInterview    文件:NetworkModule.java   
@Provides
@Singleton
StethoInterceptor stethoInterceptor() {
    return new StethoInterceptor();
}
项目:moment-for-android-wear    文件:StethoUtil.java   
public static void addStethoInterceptor(OkHttpClient client) {
    client.networkInterceptors().add(new StethoInterceptor());
}
项目:yandex-disk-restapi-java    文件:RestClientUtil.java   
public static RestClient getInstance(final Credentials credentials) {
    OkHttpClient client = OkHttpClientFactory.makeClient();
    client.networkInterceptors().add(new StethoInterceptor());
    return new RestClient(credentials, client);
}
项目:listahu-android    文件:RetrofitUtils.java   
public static OkHttpClient getClient() {
    OkHttpClient client = new OkHttpClient();
    client.networkInterceptors().add(new StethoInterceptor());
    return client;
}
项目:Qiitanium    文件:DebugWebModule.java   
@Override public OkHttpClient provideOkHttpClient(Application app) {
  OkHttpClient client = super.provideOkHttpClient(app);
  client.networkInterceptors().add(new StethoInterceptor());
  return client;
}