List of usage examples for com.squareup.okhttp OkHttpClient OkHttpClient
public OkHttpClient()
From source file:com.linroid.pushapp.module.DataModule.java
License:Apache License
@Provides @Singleton//from w w w . ja va 2s .c om OkHttpClient provideOkHttp(Cache cache) { OkHttpClient okHttp = new OkHttpClient(); okHttp.setCache(cache); okHttp.setConnectTimeout(30, TimeUnit.SECONDS); okHttp.setReadTimeout(30, TimeUnit.SECONDS); okHttp.setWriteTimeout(30, TimeUnit.SECONDS); okHttp.networkInterceptors().add(new StethoInterceptor()); return okHttp; }
From source file:com.liuguangqiang.asyncokhttp.AsyncOkHttp.java
License:Apache License
private AsyncOkHttp() { mHttpClient = new OkHttpClient(); init(Configuration.createDefault()); }
From source file:com.liulishuo.filedownloader.services.FileDownloadMgr.java
License:Apache License
public FileDownloadMgr() { mHelper = new FileDownloadDBHelper(); // init client client = new OkHttpClient(); // TODO }
From source file:com.lobobrowser.LoboBrowser.java
License:Open Source License
/** * Initializes the global URLStreamHandlerFactory. * <p>// w w w .j av a 2 s.c o m * This method is invoked by {@link #init(boolean, boolean)}. */ public static void initProtocols(final SSLSocketFactory sslSocketFactory) { // Configure URL protocol handlers final PlatformStreamHandlerFactory factory = PlatformStreamHandlerFactory.getInstance(); URL.setURLStreamHandlerFactory(factory); final OkHttpClient okHttpClient = new OkHttpClient(); final ArrayList<Protocol> protocolList = new ArrayList<>(2); protocolList.add(Protocol.HTTP_1_1); protocolList.add(Protocol.HTTP_2); okHttpClient.setProtocols(protocolList); okHttpClient.setConnectTimeout(100, TimeUnit.SECONDS); // HttpsURLConnection.setDefaultSSLSocketFactory(sslSocketFactory); okHttpClient.setSslSocketFactory(sslSocketFactory); okHttpClient.setFollowRedirects(false); okHttpClient.setFollowSslRedirects(false); factory.addFactory(new OkUrlFactory(okHttpClient)); factory.addFactory(new LocalStreamHandlerFactory()); }
From source file:com.lyft.reactivehttp.SampleTest.java
License:Apache License
protected ReactiveHttpClient createClient() { return new ReactiveHttpClient(new OkHttpTransport(new OkHttpClient()), gson, Schedulers.io(), new ConsoleLog(), false); }
From source file:com.mallorcasoftware.debitoorapiclient.ApiClient.java
License:Apache License
public ApiClient() { httpClient = new OkHttpClient(); verifyingSsl = true;/*from w w w.j a va 2s . com*/ json = new JSON(this); /* * Use RFC3339 format for date and datetime. * See http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14 */ this.dateFormat = new SimpleDateFormat("yyyy-MM-dd"); // Always use UTC as the default time zone when dealing with date (without time). this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); initDatetimeFormat(); // Be lenient on datetime formats when parsing datetime from string. // See <code>parseDatetime</code>. this.lenientDatetimeFormat = true; // Set default User-Agent. setUserAgent("Swagger-Codegen/1.0.0/java"); // Setup authentications (key: authentication name, value: authentication). authentications = new HashMap<String, Authentication>(); // Prevent the authentications from being modified. authentications = Collections.unmodifiableMap(authentications); }
From source file:com.mallorcasoftware.openweatherclient.ApiClient.java
License:Apache License
public ApiClient() { httpClient = new OkHttpClient(); verifyingSsl = true;/*from ww w . ja va 2 s. c om*/ json = new JSON(this); /* * Use RFC3339 format for date and datetime. * See http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14 */ this.dateFormat = new SimpleDateFormat("yyyy-MM-dd"); // Always use UTC as the default time zone when dealing with date (without time). this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); initDatetimeFormat(); // Be lenient on datetime formats when parsing datetime from string. // See <code>parseDatetime</code>. this.lenientDatetimeFormat = true; // Set default User-Agent. setUserAgent("Swagger-Codegen/1.0.0/java"); // Setup authentications (key: authentication name, value: authentication). authentications = new HashMap<String, Authentication>(); authentications.put("UserSecurity", new ApiKeyAuth("query", "APPID")); // Prevent the authentications from being modified. authentications = Collections.unmodifiableMap(authentications); }
From source file:com.mamashai.pingxx.PingxxAndroidModule.java
License:Open Source License
@Kroll.method public void pay(Object arg) { HashMap<String, String> kd = (HashMap<String, String>) arg; OkHttpClient client = new OkHttpClient(); /*/*from w w w . j a v a 2 s. co m*/ RequestBody formBody = new FormEncodingBuilder() .add("order_no", kd.get("order_no")) .add("amount", kd.get("amount")) .add("channel", kd.get("channel")) .build(); Request request = new Request.Builder().url(url).build(); Response response = client.newCall(request).execute(); */ String url = kd.get("url") + "?order_no=" + kd.get("order_no") + "&amount=" + kd.get("amount") + "&channel=" + kd.get("channel"); Log.d(LCAT, "url :" + url); Request request = new Request.Builder().url(url).build(); try { Response response = client.newCall(request).execute(); if (response.code() >= 200 && response.code() <= 300) { String data = response.body().string(); Log.d(LCAT, "data:" + data); Intent intent = new Intent(); String packageName = _app.getAppCurrentActivity().getPackageName(); ComponentName componentName = new ComponentName(packageName, packageName + ".wxapi.WXPayEntryActivity"); intent.setComponent(componentName); intent.putExtra(PaymentActivity.EXTRA_CHARGE, data); TiActivitySupport support = (TiActivitySupport) TiApplication.getAppCurrentActivity(); support.launchActivityForResult(intent, REQUEST_CODE_PAYMENT, this); Log.d(LCAT, "after launch Activity"); } else { HashMap<String, Object> event = new HashMap<String, Object>(); event.put("code", "error"); event.put("text", "charge" + response); fireEvent("ping_paid", event); Log.d(LCAT, "request error"); } } catch (Exception e) { } }
From source file:com.markupartist.sthlmtraveling.data.misc.HttpHelper.java
License:Apache License
private HttpHelper(final Context context) { mClient = new OkHttpClient(); mClient.setConnectTimeout(15, TimeUnit.SECONDS); mClient.setReadTimeout(15, TimeUnit.SECONDS); installHttpCache(context);/*from w w w.j a va 2s. c o m*/ }
From source file:com.markupartist.sthlmtraveling.utils.HttpHelper.java
License:Apache License
private HttpHelper(final Context context) { mClient = new OkHttpClient(); mClient.setConnectTimeout(30, TimeUnit.SECONDS); installHttpCache(context); }