当前位置: 首页>>代码示例>>Java>>正文


Java StethoInterceptor类代码示例

本文整理汇总了Java中com.facebook.stetho.okhttp.StethoInterceptor的典型用法代码示例。如果您正苦于以下问题:Java StethoInterceptor类的具体用法?Java StethoInterceptor怎么用?Java StethoInterceptor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StethoInterceptor类属于com.facebook.stetho.okhttp包,在下文中一共展示了StethoInterceptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRestAdapter

import com.facebook.stetho.okhttp.StethoInterceptor; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:iem-devs,项目名称:apna-library,代码行数:31,代码来源:ApiClient.java

示例2: instance

import com.facebook.stetho.okhttp.StethoInterceptor; //导入依赖的package包/类
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;
}
 
开发者ID:LoopTeam,项目名称:LoopSeries-Mobile,代码行数:23,代码来源:APIFactory.java

示例3: instance

import com.facebook.stetho.okhttp.StethoInterceptor; //导入依赖的package包/类
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;
}
 
开发者ID:imallan,项目名称:tuchong-daily-android,代码行数:17,代码来源:APIFactory.java

示例4: setPicasso

import com.facebook.stetho.okhttp.StethoInterceptor; //导入依赖的package包/类
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);
}
 
开发者ID:imallan,项目名称:tuchong-daily-android,代码行数:19,代码来源:TuchongApplication.java

示例5: providesOkHttpClient

import com.facebook.stetho.okhttp.StethoInterceptor; //导入依赖的package包/类
@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;
}
 
开发者ID:tevjef,项目名称:Vapor,代码行数:17,代码来源:OkCloudAppModule.java

示例6: LoginViewModel

import com.facebook.stetho.okhttp.StethoInterceptor; //导入依赖的package包/类
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);
    }
 
开发者ID:dinosaurwithakatana,项目名称:hacker-news-android,代码行数:25,代码来源:LoginViewModel.java

示例7: NetworkingModule

import com.facebook.stetho.okhttp.StethoInterceptor; //导入依赖的package包/类
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;
}
 
开发者ID:john1jan,项目名称:ReactNativeSignatureExample,代码行数:12,代码来源:NetworkingModule.java

示例8: provideOkHttp

import com.facebook.stetho.okhttp.StethoInterceptor; //导入依赖的package包/类
@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;
}
 
开发者ID:pakoito,项目名称:SongkickInterview,代码行数:14,代码来源:NetworkModule.java

示例9: getOkClient

import com.facebook.stetho.okhttp.StethoInterceptor; //导入依赖的package包/类
/**
 * 用于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);
}
 
开发者ID:andyiac,项目名称:githot,代码行数:11,代码来源:ApiClient.java

示例10: onCreate

import com.facebook.stetho.okhttp.StethoInterceptor; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    Stetho.initializeWithDefaults(this);
    OkHttpClient client = new OkHttpClient();
    client.networkInterceptors().add(new StethoInterceptor());
}
 
开发者ID:succlz123,项目名称:OkDownload,代码行数:8,代码来源:MyApplication.java

示例11: provideOkHttpClient

import com.facebook.stetho.okhttp.StethoInterceptor; //导入依赖的package包/类
@Provides
@Singleton
OkHttpClient provideOkHttpClient(Interceptor interceptor) {
    OkHttpClient okHttpClient = new OkHttpClient();

    okHttpClient.interceptors().add(interceptor);

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

    return okHttpClient;
}
 
开发者ID:JohnnyZhou,项目名称:MovieMe,代码行数:13,代码来源:ApiModule.java

示例12: getClient

import com.facebook.stetho.okhttp.StethoInterceptor; //导入依赖的package包/类
public static OkHttpClient getClient() {
    if (client == null) {
        client = new OkHttpClient();
        client.setReadTimeout(10, TimeUnit.SECONDS);
        client.networkInterceptors().add(new StethoInterceptor());
    }
    return client;
}
 
开发者ID:frc2052,项目名称:FRC-Krawler,代码行数:9,代码来源:HTTP.java

示例13: createClient

import com.facebook.stetho.okhttp.StethoInterceptor; //导入依赖的package包/类
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;
}
 
开发者ID:feragusper,项目名称:BuenosAiresAntesYDespues,代码行数:14,代码来源:ApiConnection.java

示例14: providesOkClient

import com.facebook.stetho.okhttp.StethoInterceptor; //导入依赖的package包/类
@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);
}
 
开发者ID:dinosaurwithakatana,项目名称:hacker-news-android,代码行数:16,代码来源:OkClientModule.java

示例15: provideNetworkInterceptors

import com.facebook.stetho.okhttp.StethoInterceptor; //导入依赖的package包/类
@Provides
@Singleton
@ApiModule.NetworkInterceptors
List<Interceptor> provideNetworkInterceptors() {
    ArrayList<Interceptor> networkInterceptors = new ArrayList<>();
    networkInterceptors.add(new StethoInterceptor());
    return networkInterceptors;
}
 
开发者ID:peter-tackage,项目名称:soundmap,代码行数:9,代码来源:InstrumentationModule.java


注:本文中的com.facebook.stetho.okhttp.StethoInterceptor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。