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


Java PersistentCookieJar类代码示例

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


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

示例1: onCreate

import com.franmontiel.persistentcookiejar.PersistentCookieJar; //导入依赖的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.PersistentCookieJar; //导入依赖的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: ApiManager

import com.franmontiel.persistentcookiejar.PersistentCookieJar; //导入依赖的package包/类
private ApiManager() {
    cookieJar = new PersistentCookieJar(new SetCookieCache(),
            new SharedPrefsCookiePersistor(Utils.getApp()));

    OkHttpClient.Builder builder = new OkHttpClient().newBuilder();
    builder.readTimeout(30, TimeUnit.SECONDS);
    builder.connectTimeout(29, TimeUnit.SECONDS);
    builder.cookieJar(cookieJar);
    builder.addInterceptor(new RequestInterceptor());
    builder.addNetworkInterceptor(new NetworkInterceptor());
    OkHttpClient okHttpClient = builder.build();

    Retrofit retrofit = new Retrofit.Builder()
            .baseUrl("http://" + domain)
            .client(okHttpClient)
            .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
            .build();

    apiService = retrofit.create(ApiService.class);
}
 
开发者ID:RanKKI,项目名称:PSNine,代码行数:21,代码来源:ApiManager.java

示例4: init

import com.franmontiel.persistentcookiejar.PersistentCookieJar; //导入依赖的package包/类
void init(String username, String password, Context context) {
    this.username = username;
    this.password = password;
    cookieJar = new PersistentCookieJar(new SetCookieCache(),
            new SharedPrefsCookiePersistor(context));
    client = new OkHttpClient.Builder()
            .cookieJar(cookieJar)
            .build();
    expireTime = 0;
}
 
开发者ID:sgloutnikov,项目名称:NeterraProxy,代码行数:11,代码来源:NeterraProxy.java

示例5: HttpClient

import com.franmontiel.persistentcookiejar.PersistentCookieJar; //导入依赖的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

示例6: onCreate

import com.franmontiel.persistentcookiejar.PersistentCookieJar; //导入依赖的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

示例7: getRetrofit

import com.franmontiel.persistentcookiejar.PersistentCookieJar; //导入依赖的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

示例8: getRetrofit

import com.franmontiel.persistentcookiejar.PersistentCookieJar; //导入依赖的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

示例9: init

import com.franmontiel.persistentcookiejar.PersistentCookieJar; //导入依赖的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

示例10: onCreate

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

    mClearableCookieJar = new PersistentCookieJar(new SetCookieCache(), new SharedPrefsCookiePersistor(this));

    mDBHelper = new DBHelper(this);

    mCredentials = Credentials.create();
    mLoggedUser = User.create();
}
 
开发者ID:Sar777,项目名称:onliner_old,代码行数:13,代码来源:App.java

示例11: onCreate

import com.franmontiel.persistentcookiejar.PersistentCookieJar; //导入依赖的package包/类
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.activity_fake);

        tv = (TextView)findViewById(R.id.tv_01);
        et = (EditText)findViewById(R.id.et_01);
        fab = (FloatingActionButton)findViewById(R.id.fab);
        toolbar = (Toolbar)findViewById(R.id.toolbar);

        setSupportActionBar(toolbar);

        // Cookies, for login
        CookieJar cookiejar = new PersistentCookieJar(new SetCookieCache(), new SharedPrefsCookiePersistor(this));
        OkHttpClient okHttpClient = new OkHttpClient.Builder().cookieJar(cookiejar).build();

        service = new Retrofit.Builder().baseUrl(PunchcardService.END_POINT).client(okHttpClient)
                .addConverterFactory(GsonConverterFactory.create()).build().create(PunchcardService.class);
        shanbayService = new Retrofit.Builder().baseUrl(ShanbayService.END_POINT)
                .addConverterFactory(GsonConverterFactory.create()).build().create(ShanbayService.class);

        // first login, then use the same http client to access other apis
        service.login(new LoginRequest("leasunhy", "123456")).enqueue(new ToastFailureCallback<User>(fab) {
            @Override
            protected void onSuccess(Call<User> call, Response<User> response) {
                getUserInfo();
            }
        });

//        queryWord();
//        getUserInfo();
//        Register();
//        getAllUser();
    }
 
开发者ID:coolspring1293,项目名称:PunchCard,代码行数:35,代码来源:FakeActivity.java

示例12: onCreate

import com.franmontiel.persistentcookiejar.PersistentCookieJar; //导入依赖的package包/类
@Override
public void onCreate()
{
    super.onCreate();//必须调用父类方法
    Log.i("CREATE","application created....");
    CookieJar cookiejar = new PersistentCookieJar(new SetCookieCache(), new SharedPrefsCookiePersistor(this));
    OkHttpClient okHttpClient = new OkHttpClient.Builder().cookieJar(cookiejar).build();
    service = new Retrofit.Builder().baseUrl(PunchcardService.END_POINT).client(okHttpClient)
            .addConverterFactory(GsonConverterFactory.create()).build().create(PunchcardService.class);

    num = 0;
    total = 10;

}
 
开发者ID:coolspring1293,项目名称:PunchCard,代码行数:15,代码来源:Util.java

示例13: onCreate

import com.franmontiel.persistentcookiejar.PersistentCookieJar; //导入依赖的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

示例14: getRetrofit

import com.franmontiel.persistentcookiejar.PersistentCookieJar; //导入依赖的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

示例15: getCookieJar

import com.franmontiel.persistentcookiejar.PersistentCookieJar; //导入依赖的package包/类
public CookieJar getCookieJar(){
	if(this.cookieJar.get() == null){
		this.cookieJar.compareAndSet(null,
		new PersistentCookieJar(new SetCookieCache(), new SharedPrefsCookiePersistor(this)));
	}
	return this.cookieJar.get();
}
 
开发者ID:kebernet,项目名称:shortyz,代码行数:8,代码来源:ShortyzApplication.java


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