com.facebook.stetho.okhttp.StethoInterceptor Java Examples

The following examples show how to use com.facebook.stetho.okhttp.StethoInterceptor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LoginViewModel.java    From hacker-news-android with Apache License 2.0 6 votes vote down vote up
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);
    }
 
Example #2
Source File: ApiClient.java    From githot with Apache License 2.0 5 votes vote down vote up
/**
 * 用于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);
}
 
Example #3
Source File: MyApplication.java    From OkDownload with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    Stetho.initializeWithDefaults(this);
    OkHttpClient client = new OkHttpClient();
    client.networkInterceptors().add(new StethoInterceptor());
}
 
Example #4
Source File: OkClientModule.java    From hacker-news-android with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #5
Source File: DebugWebModule.java    From Qiitanium with MIT License 4 votes vote down vote up
@Override public OkHttpClient provideOkHttpClient(Application app) {
  OkHttpClient client = super.provideOkHttpClient(app);
  client.networkInterceptors().add(new StethoInterceptor());
  return client;
}