mirror of
https://github.com/owncloud/android-library.git
synced 2026-08-17 19:32:56 +00:00
Update sample client to use new library
This commit is contained in:
@@ -45,12 +45,6 @@ import java.io.IOException;
|
||||
public class OwnCloudClientFactory {
|
||||
|
||||
final private static String TAG = OwnCloudClientFactory.class.getSimpleName();
|
||||
|
||||
/** Default timeout for waiting data from the server */
|
||||
public static final int DEFAULT_DATA_TIMEOUT = 60000;
|
||||
|
||||
/** Default timeout for establishing a connection */
|
||||
public static final int DEFAULT_CONNECTION_TIMEOUT = 60000;
|
||||
|
||||
/**
|
||||
* Creates a OwnCloudClient setup for an ownCloud account
|
||||
@@ -157,8 +151,6 @@ public class OwnCloudClientFactory {
|
||||
boolean followRedirects) {
|
||||
OwnCloudClient client = new OwnCloudClient(uri);
|
||||
|
||||
client.setDefaultTimeouts(DEFAULT_DATA_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT);
|
||||
|
||||
client.setFollowRedirects(followRedirects);
|
||||
|
||||
client.setContext(context);
|
||||
|
||||
@@ -100,5 +100,4 @@ public class OwnCloudClientManagerFactory {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -102,6 +102,9 @@ public class HttpClient {
|
||||
OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder()
|
||||
.addInterceptor(getOkHttpInterceptor())
|
||||
.protocols(Arrays.asList(Protocol.HTTP_1_1))
|
||||
.readTimeout(HttpConstants.DEFAULT_DATA_TIMEOUT, TimeUnit.MILLISECONDS)
|
||||
.writeTimeout(HttpConstants.DEFAULT_DATA_TIMEOUT, TimeUnit.MILLISECONDS)
|
||||
.connectTimeout(HttpConstants.DEFAULT_CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS)
|
||||
.followRedirects(false)
|
||||
.sslSocketFactory(sslContext.getSocketFactory(), trustManager)
|
||||
.hostnameVerifier((asdf, usdf) -> true)
|
||||
@@ -126,23 +129,6 @@ public class HttpClient {
|
||||
return sOkHttpInterceptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the connection and wait-for-data timeouts to be applied by default to the methods
|
||||
* performed by this client.
|
||||
*/
|
||||
public void setDefaultTimeouts(int defaultDataTimeout, int defaultConnectionTimeout) {
|
||||
OkHttpClient.Builder clientBuilder = getOkHttpClient().newBuilder();
|
||||
if (defaultDataTimeout >= 0) {
|
||||
clientBuilder
|
||||
.readTimeout(defaultDataTimeout, TimeUnit.MILLISECONDS)
|
||||
.writeTimeout(defaultDataTimeout, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
if (defaultConnectionTimeout >= 0) {
|
||||
clientBuilder.connectTimeout(defaultConnectionTimeout, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
sOkHttpClient = clientBuilder.build();
|
||||
}
|
||||
|
||||
public void disableAutomaticCookiesHandling() {
|
||||
OkHttpClient.Builder clientBuilder = getOkHttpClient().newBuilder();
|
||||
clientBuilder.cookieJar(new CookieJar() {
|
||||
|
||||
@@ -174,4 +174,14 @@ public class HttpConstants {
|
||||
public static final int HTTP_HTTP_VERSION_NOT_SUPPORTED = 505;
|
||||
// 507 Insufficient Storage (WebDAV - RFC 2518)
|
||||
public static final int HTTP_INSUFFICIENT_STORAGE = 507;
|
||||
|
||||
/***********************************************************************************************************
|
||||
*************************************************** TIMEOUTS **********************************************
|
||||
***********************************************************************************************************/
|
||||
|
||||
/** Default timeout for waiting data from the server */
|
||||
public static final int DEFAULT_DATA_TIMEOUT = 60000;
|
||||
|
||||
/** Default timeout for establishing a connection */
|
||||
public static final int DEFAULT_CONNECTION_TIMEOUT = 60000;
|
||||
}
|
||||
Reference in New Issue
Block a user