mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Switch to using ThreadedPoolConnectionManager
Is probably the cause of the IllegalStateExceptions. Change-Id: I6160dcd42d77f49396fdb934643b5a8e00f6779f
This commit is contained in:
parent
8396b2426f
commit
884709b470
1 changed files with 14 additions and 3 deletions
|
|
@ -26,6 +26,11 @@ import org.acra.ACRA;
|
|||
import org.acra.ReportingInteractionMode;
|
||||
import org.acra.annotation.ReportsCrashes;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.conn.*;
|
||||
import org.apache.http.conn.scheme.*;
|
||||
import org.apache.http.conn.ssl.*;
|
||||
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
|
||||
import org.apache.http.params.BasicHttpParams;
|
||||
import org.mediawiki.api.*;
|
||||
import org.wikimedia.commons.auth.WikiAccountAuthenticator;
|
||||
import org.apache.http.impl.client.*;
|
||||
|
|
@ -70,9 +75,15 @@ public class CommonsApplication extends Application {
|
|||
public RequestQueue volleyQueue;
|
||||
|
||||
public static AbstractHttpClient createHttpClient() {
|
||||
DefaultHttpClient client = new DefaultHttpClient();
|
||||
client.getParams().setParameter(CoreProtocolPNames.USER_AGENT, "Commons/" + APPLICATION_VERSION + " (https://mediawiki.org/wiki/Apps/Commons) Android/" + Build.VERSION.RELEASE);
|
||||
return client;
|
||||
BasicHttpParams params = new BasicHttpParams();
|
||||
SchemeRegistry schemeRegistry = new SchemeRegistry();
|
||||
schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
|
||||
final SSLSocketFactory sslSocketFactory = SSLSocketFactory.getSocketFactory();
|
||||
schemeRegistry.register(new Scheme("https", sslSocketFactory, 443));
|
||||
ClientConnectionManager cm = new ThreadSafeClientConnManager(params, schemeRegistry);
|
||||
params.setParameter(CoreProtocolPNames.USER_AGENT, "Commons/" + APPLICATION_VERSION + " (https://mediawiki.org/wiki/Apps/Commons) Android/" + Build.VERSION.RELEASE);
|
||||
DefaultHttpClient httpclient = new DefaultHttpClient(cm, params);
|
||||
return httpclient;
|
||||
}
|
||||
|
||||
public static MWApi createMWApi() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue