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


Java ClearableCookieJar类代码示例

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


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

示例1: onCreate

import com.franmontiel.persistentcookiejar.ClearableCookieJar; //导入依赖的package包/类
@Override
public void onCreate() {
  super.onCreate();

  Log.i(TAG, String.format("Using Kolibri %s version", BuildConfig.VERSION_NAME));

  final DisplayMetrics lDisplayMetrics = getResources().getDisplayMetrics();
  viewportWidthPixels = Math.round(lDisplayMetrics.widthPixels / lDisplayMetrics.density);
  viewportHeightPixels = Math.round(lDisplayMetrics.heightPixels / lDisplayMetrics.density);

  final ClearableCookieJar cookieJar = new PersistentCookieJar(new SetCookieCache(),
      new SharedPrefsCookiePersistor(this));

  instance = this;

  netmetrixClient = new OkHttpClient.Builder().cookieJar(cookieJar).build();
}
 
开发者ID:azmedien,项目名称:kolibri-android,代码行数:18,代码来源:KolibriApp.java

示例2: init

import com.franmontiel.persistentcookiejar.ClearableCookieJar; //导入依赖的package包/类
/**
 * @param context
 * @param baseUrl
 * @return
 */
public AntCloud init(Context context, String baseUrl) {
    mManager = new AntCloudSubscription();
    mHttpClientBuilder = new OkHttpClient.Builder();
    ClearableCookieJar cookieJar =
            new PersistentCookieJar(new SetCookieCache(), new SharedPrefsCookiePersistor(context));
    mHttpClientBuilder.connectTimeout(timeout == 0 ? DEFAULT_TIMEOUT : timeout, TimeUnit.SECONDS);
    mHttpClientBuilder.cookieJar(cookieJar);//添加cookie 持久化管理
    addInterceptor(new LoggingInterceptor());//添加日志打印
    mRetrofit = new Retrofit.Builder()
            .client(mHttpClientBuilder.build())
            .addConverterFactory(GsonConverterFactory.create())
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .baseUrl(baseUrl)
            .build();
    return this;
}
 
开发者ID:themores,项目名称:AntCloud,代码行数:22,代码来源:AntCloud.java

示例3: HttpClient

import com.franmontiel.persistentcookiejar.ClearableCookieJar; //导入依赖的package包/类
private HttpClient() {
    ClearableCookieJar cookieJar = new PersistentCookieJar(new SetCookieCache(), new SharedPrefsCookiePersistor(Utils.getContext()));
    //HttpsUtil.SSLParams sslParams = HttpsUtil.getSslSocketFactory(Utils.getContext(), R.raw.cer,STORE_PASS , STORE_ALIAS);
    okHttpClient = new OkHttpClient.Builder()
            .connectTimeout(10000L, TimeUnit.MILLISECONDS)
            //.sslSocketFactory(sslParams.sSLSocketFactory, sslParams.trustManager)
            // .hostnameVerifier(HttpsUtil.getHostnameVerifier())
            .addInterceptor(new LoggerInterceptor(null, true))
            .cookieJar(cookieJar)
            .build();
}
 
开发者ID:guiying712,项目名称:AndroidModulePattern,代码行数:12,代码来源:HttpClient.java

示例4: onCreate

import com.franmontiel.persistentcookiejar.ClearableCookieJar; //导入依赖的package包/类
@Override
    public void onCreate()
    {
        super.onCreate();

        ClearableCookieJar cookieJar1 = new PersistentCookieJar(new SetCookieCache(), new SharedPrefsCookiePersistor(getApplicationContext()));

        HttpsUtils.SSLParams sslParams = HttpsUtils.getSslSocketFactory(null, null, null);

//        CookieJarImpl cookieJar1 = new CookieJarImpl(new MemoryCookieStore());
        OkHttpClient okHttpClient = new OkHttpClient.Builder()
                .connectTimeout(10000L, TimeUnit.MILLISECONDS)
                .readTimeout(10000L, TimeUnit.MILLISECONDS)
                .addInterceptor(new LoggerInterceptor("TAG"))
                .cookieJar(cookieJar1)
                .hostnameVerifier(new HostnameVerifier()
                {
                    @Override
                    public boolean verify(String hostname, SSLSession session)
                    {
                        return true;
                    }
                })
                .sslSocketFactory(sslParams.sSLSocketFactory, sslParams.trustManager)
                .build();
        OkHttpUtils.initClient(okHttpClient);

    }
 
开发者ID:laotanggit,项目名称:okhttputils-masterlaotang,代码行数:29,代码来源:MyApplication.java

示例5: getRetrofit

import com.franmontiel.persistentcookiejar.ClearableCookieJar; //导入依赖的package包/类
public Retrofit getRetrofit() {
    // 指定缓存路径,缓存大小 50Mb
    Cache cache = new Cache(new File(mContext.getCacheDir(), "HttpCache"),
            1024 * 1024 * 50);

    // Cookie 持久化
    ClearableCookieJar cookieJar =
            new PersistentCookieJar(new SetCookieCache(), new SharedPrefsCookiePersistor(mContext));

    OkHttpClient.Builder builder = new OkHttpClient.Builder()
            .cookieJar(cookieJar)
            .cache(cache)
            .addInterceptor(cacheControlInterceptor)
            .connectTimeout(10, TimeUnit.SECONDS)
            .readTimeout(15, TimeUnit.SECONDS)
            .writeTimeout(15, TimeUnit.SECONDS)
            .retryOnConnectionFailure(true);

    // Log 拦截器
    if (BuildConfig.DEBUG) {
        builder = SdkManager.initInterceptor(builder);
    }

    return new Retrofit.Builder()
            .baseUrl(IApi.API_BASE)
            .client(builder.build())
            .addConverterFactory(GsonConverterFactory.create())
            .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
            .build();
}
 
开发者ID:iMeiji,项目名称:Daily,代码行数:31,代码来源:RetrofitHelper.java

示例6: getRetrofit

import com.franmontiel.persistentcookiejar.ClearableCookieJar; //导入依赖的package包/类
public static Retrofit getRetrofit() {
    if (sRetrofit == null) {
        synchronized (RetrofitFactory.class) {
            if (sRetrofit == null) {
                // 指定缓存路径,缓存大小 50Mb
                Cache cache = new Cache(new File(App.sAppContext.getCacheDir(), "HttpCache"),
                        1024 * 1024 * 50);

                // Cookie 持久化
                ClearableCookieJar cookieJar =
                        new PersistentCookieJar(new SetCookieCache(), new SharedPrefsCookiePersistor(App.sAppContext));

                OkHttpClient.Builder builder = new OkHttpClient.Builder()
                        .cookieJar(cookieJar)
                        .cache(cache)
                        .addInterceptor(cacheControlInterceptor)
                        .connectTimeout(10, TimeUnit.SECONDS)
                        .readTimeout(15, TimeUnit.SECONDS)
                        .writeTimeout(15, TimeUnit.SECONDS)
                        .retryOnConnectionFailure(true);

                // Log 拦截器
                if (BuildConfig.DEBUG) {
                    builder = SdkManager.initInterceptor(builder);
                }

                sRetrofit = new Retrofit.Builder()
                        .baseUrl(IApi.API_BASE)
                        .client(builder.build())
                        .addConverterFactory(GsonConverterFactory.create())
                        .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                        .build();
            }
        }
    }
    return sRetrofit;
}
 
开发者ID:iMeiji,项目名称:Daily,代码行数:38,代码来源:RetrofitFactory.java

示例7: init

import com.franmontiel.persistentcookiejar.ClearableCookieJar; //导入依赖的package包/类
public void init(Context context, String dns, boolean sslOrTls) {
    // init gson
    gson = new GsonBuilder()
            .setDateFormat("EEE, dd MMM yyyy HH:mm:ss Z")
            .setPrettyPrinting()
            .registerTypeAdapter(User.class, new UserSerializer())
            .create();


    ClearableCookieJar cookieJar =
            new PersistentCookieJar(new SetCookieCache(), new SharedPrefsCookiePersistor(context));

    HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
    interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);

    OkHttpClient client = new OkHttpClient().newBuilder()
            .connectTimeout(CONNECT_TIMEOUT, TimeUnit.MINUTES)
            .readTimeout(READ_TIMEOUT, TimeUnit.MINUTES)
            .writeTimeout(WRITE_TIMEOUT, TimeUnit.MINUTES)
            .addInterceptor(interceptor)
            //.addNetworkInterceptor(new StethoInterceptor())
            .cookieJar(cookieJar)
            .build();


    apiInterface = new Retrofit.Builder()
            .baseUrl("{protocol}://{dns}/traccar/rest/".replace("{protocol}", sslOrTls ? "https" : "http").replace("{dns}", dns))
            .client(client)
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .addConverterFactory(GsonConverterFactory.create(gson))
            .build().create(ApiInterface.class);
}
 
开发者ID:erlymon,项目名称:erlymon-litvak-monitor-android,代码行数:33,代码来源:ApiModule.java

示例8: provideOkHttpClient

import com.franmontiel.persistentcookiejar.ClearableCookieJar; //导入依赖的package包/类
@Provides
@Singleton
public OkHttpClient provideOkHttpClient(ClearableCookieJar cookieJar, HttpLoggingInterceptor interceptor) {
    return  new OkHttpClient().newBuilder()
            .connectTimeout(CONNECT_TIMEOUT, TimeUnit.MINUTES)
            .readTimeout(READ_TIMEOUT, TimeUnit.MINUTES)
            .writeTimeout(WRITE_TIMEOUT, TimeUnit.MINUTES)
            .cookieJar(cookieJar)
            //.addInterceptor(interceptor)
            .addNetworkInterceptor(new StethoInterceptor())
            .build();
}
 
开发者ID:erlymon,项目名称:erlymon-monitor-android,代码行数:13,代码来源:HttpClientModule.java

示例9: onCreate

import com.franmontiel.persistentcookiejar.ClearableCookieJar; //导入依赖的package包/类
@Override
    public void onCreate() {
        super.onCreate();

        mInstance = this;

        //持久化存储cookie
        ClearableCookieJar cookieJar =
                new PersistentCookieJar(new SetCookieCache(), new SharedPrefsCookiePersistor(getApplicationContext()));

        //log拦截器
        HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
        logging.setLevel(HttpLoggingInterceptor.Level.BODY);

        //自定义OkHttp
        OkHttpClient okHttpClient = new OkHttpClient.Builder()
                .connectTimeout(10000L, TimeUnit.MILLISECONDS)
                .readTimeout(10000L, TimeUnit.MILLISECONDS)
                .cookieJar(cookieJar)       //设置开启cookie
                .addInterceptor(logging)            //设置开启log
                .build();
        mMyOkHttp = new MyOkHttp(okHttpClient);

        //默认
//        mMyOkHttp = new MyOkHttp();

        mDownloadMgr = (DownloadMgr) new DownloadMgr.Builder()
                .myOkHttp(mMyOkHttp)
                .maxDownloadIngNum(5)       //设置最大同时下载数量(不设置默认5)
                .saveProgressBytes(50 * 1204)   //设置每50kb触发一次saveProgress保存进度 (不能在onProgress每次都保存 过于频繁) 不设置默认50kb
                .build();

        mDownloadMgr.resumeTasks();     //恢复本地所有未完成的任务
    }
 
开发者ID:tsy12321,项目名称:MyOkHttp,代码行数:35,代码来源:MyApplication.java

示例10: getRetrofit

import com.franmontiel.persistentcookiejar.ClearableCookieJar; //导入依赖的package包/类
@NonNull
public static Retrofit getRetrofit() {
    if (retrofit == null) {
        synchronized (RetrofitFactory.class) {
            if (retrofit == null) {
                // 指定缓存路径,缓存大小 50Mb
                Cache cache = new Cache(new File(InitApp.AppContext.getCacheDir(), "HttpCache"),
                        1024 * 1024 * 50);

                // Cookie 持久化
                ClearableCookieJar cookieJar =
                        new PersistentCookieJar(new SetCookieCache(), new SharedPrefsCookiePersistor(InitApp.AppContext));

                OkHttpClient.Builder builder = new OkHttpClient.Builder()
                        .cookieJar(cookieJar)
                        .cache(cache)
                        .addInterceptor(cacheControlInterceptor)
                        .connectTimeout(10, TimeUnit.SECONDS)
                        .readTimeout(15, TimeUnit.SECONDS)
                        .writeTimeout(15, TimeUnit.SECONDS)
                        .retryOnConnectionFailure(true);

                // Log 拦截器
                if (BuildConfig.DEBUG) {
                    builder = SdkManager.initInterceptor(builder);
                }

                retrofit = new Retrofit.Builder()
                        .baseUrl(INewsApi.HOST)
                        .client(builder.build())
                        .addConverterFactory(GsonConverterFactory.create())
                        .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                        .build();
            }
        }
    }
    return retrofit;
}
 
开发者ID:iMeiji,项目名称:Toutiao,代码行数:39,代码来源:RetrofitFactory.java

示例11: provideClearableCookieJar

import com.franmontiel.persistentcookiejar.ClearableCookieJar; //导入依赖的package包/类
@Provides
@Singleton
public ClearableCookieJar provideClearableCookieJar(Context context) {
    return new PersistentCookieJar(new SetCookieCache(), new SharedPrefsCookiePersistor(context));
}
 
开发者ID:erlymon,项目名称:erlymon-monitor-android,代码行数:6,代码来源:HttpClientModule.java

示例12: getClearableCookieJar

import com.franmontiel.persistentcookiejar.ClearableCookieJar; //导入依赖的package包/类
@NonNull
public static ClearableCookieJar getClearableCookieJar() {
    return mClearableCookieJar;
}
 
开发者ID:Sar777,项目名称:onliner_old,代码行数:5,代码来源:App.java

示例13: getOkClient

import com.franmontiel.persistentcookiejar.ClearableCookieJar; //导入依赖的package包/类
public static OkHttpClient getOkClient(Context c) {
    if (client != null) {
        return client;
    }

    final CertificatePinner certificatePinner = new CertificatePinner.Builder()
            .add(API_HOSTNAME, "sha256/dVphPQ9xG7woPpEKXrNalw4eMUQ4Fw9r3OXTzxfuL5A=") //Fakultaet fuer Informatik
            .add(API_HOSTNAME, "sha256/SwdQoHL7SB/6o12XsIhbQJ9bANVnbrJoHTLzlu/qXT0=") //Technische Universitaet Muenchen
            .add(API_HOSTNAME, "sha256/VzL+FtAKvzb4N5igmFJyv83GD7CBK7Yyw+R6XdRRfmg=") //DFN-Verein PCA Global
            .add(API_HOSTNAME, "sha256/0d4q5hyN8vpiOWYWPUxz1GC/xCjldYW+a/65pWMj0bY=") //Deutsche Telekom Root CA 2
            .add(API_HOSTNAME, "sha256/YLh1dUR9y6Kja30RrAn7JKnbQG/uEtLMkBgFF2Fuihg=") //Let's Encrypt Authority X3
            .add(API_HOSTNAME, "sha256/Vjs8r4z+80wjNcr1YKepWQboSIRi63WsWXhIMN+eWys=") //LE Cross Sign: DST Root CA X3
            .add(API_HOSTNAME_NEW, "sha256/dVphPQ9xG7woPpEKXrNalw4eMUQ4Fw9r3OXTzxfuL5A=") //Fakultaet fuer Informatik
            .add(API_HOSTNAME_NEW, "sha256/SwdQoHL7SB/6o12XsIhbQJ9bANVnbrJoHTLzlu/qXT0=") //Technische Universitaet Muenchen
            .add(API_HOSTNAME_NEW, "sha256/VzL+FtAKvzb4N5igmFJyv83GD7CBK7Yyw+R6XdRRfmg=") //DFN-Verein PCA Global
            .add(API_HOSTNAME_NEW, "sha256/0d4q5hyN8vpiOWYWPUxz1GC/xCjldYW+a/65pWMj0bY=") //Deutsche Telekom Root CA 2
            .add(API_HOSTNAME_NEW, "sha256/YLh1dUR9y6Kja30RrAn7JKnbQG/uEtLMkBgFF2Fuihg=") //Let's Encrypt Authority X3
            .add(API_HOSTNAME_NEW, "sha256/Vjs8r4z+80wjNcr1YKepWQboSIRi63WsWXhIMN+eWys=") //LE Cross Sign: DST Root CA X3
            .add(STUDYROOM_HOST, "sha256/dVphPQ9xG7woPpEKXrNalw4eMUQ4Fw9r3OXTzxfuL5A=") //wwwv2.tum.de
            .add(STUDYROOM_HOST, "sha256/K64RzAqr/RSxwfpHN6fe0DcmdaIVmzAyi511ufYaK1s=") //wwwv4.tum.de
            .add(STUDYROOM_HOST, "sha256/SwdQoHL7SB/6o12XsIhbQJ9bANVnbrJoHTLzlu/qXT0=") //Zertifizierungsstelle der TUM
            .add(STUDYROOM_HOST, "sha256/VzL+FtAKvzb4N5igmFJyv83GD7CBK7Yyw+R6XdRRfmg=") //DFN-Verein PCA Global - G01
            .add(STUDYROOM_HOST, "sha256/0d4q5hyN8vpiOWYWPUxz1GC/xCjldYW+a/65pWMj0bY=") //Deutsche Telekom Root CA 2
            .build();

    //We want to persist our cookies through app session
    ClearableCookieJar cookieJar = new PersistentCookieJar(new SetCookieCache(), new SharedPrefsCookiePersistor(c));

    //Start building the http client
    OkHttpClient.Builder builder = new OkHttpClient.Builder()
            .cookieJar(cookieJar)
            .certificatePinner(certificatePinner);

    //Add the device identifying header
    builder.addInterceptor(Helper.getDeviceInterceptor(c));

    builder.connectTimeout(Helper.HTTP_TIMEOUT, TimeUnit.MILLISECONDS);
    builder.readTimeout(Helper.HTTP_TIMEOUT, TimeUnit.MILLISECONDS);

    builder.addNetworkInterceptor(new TumHttpLoggingInterceptor(message -> Utils.logwithTag(TAG, message)));

    //Save it to the static handle and return
    client = builder.build();
    return client;
}
 
开发者ID:TCA-Team,项目名称:TumCampusApp,代码行数:46,代码来源:Helper.java


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