Skip to content
This repository has been archived by the owner on Feb 14, 2020. It is now read-only.

Commit

Permalink
Merge 0883c0c into 4bb89cb
Browse files Browse the repository at this point in the history
  • Loading branch information
vjames19 committed Feb 9, 2016
2 parents 4bb89cb + 0883c0c commit e7ec918
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions library/src/main/java/com/parse/twitter/Twitter.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@
*/
package com.parse.twitter;

import com.parse.internal.signpost.basic.DefaultOAuthConsumer;
import com.parse.internal.signpost.basic.DefaultOAuthProvider;
import com.parse.internal.signpost.basic.HttpURLConnectionClient;
import org.apache.http.client.methods.HttpUriRequest;

import android.app.ProgressDialog;
import android.content.Context;
import android.net.Uri;
import android.os.AsyncTask;
import android.webkit.CookieSyncManager;

import com.parse.oauth.OAuth1FlowDialog;
import com.parse.oauth.OAuth1FlowException;
import com.parse.oauth.OAuth1FlowDialog.FlowResultHandler;
import com.parse.internal.signpost.OAuthConsumer;
import com.parse.internal.signpost.OAuthProvider;
import com.parse.internal.signpost.basic.DefaultOAuthConsumer;
import com.parse.internal.signpost.basic.DefaultOAuthProvider;
import com.parse.internal.signpost.basic.HttpURLConnectionClient;
import com.parse.internal.signpost.commonshttp.CommonsHttpOAuthConsumer;
import com.parse.internal.signpost.http.HttpParameters;
import com.parse.oauth.OAuth1FlowDialog;
import com.parse.oauth.OAuth1FlowDialog.FlowResultHandler;
import com.parse.oauth.OAuth1FlowException;

import org.apache.http.client.methods.HttpUriRequest;

import java.net.HttpURLConnection;

Expand All @@ -52,8 +52,6 @@ public class Twitter {
private String userId;
private String screenName;

private final HttpURLConnectionClient httpURLConnectionClient = HttpURLConnectionClient.create();

public Twitter(String consumerKey, String consumerSecret) {
this.consumerKey = consumerKey;
this.consumerSecret = consumerSecret;
Expand Down Expand Up @@ -137,7 +135,7 @@ public void authorize(final Context context, final AsyncCallback callback) {
}

final OAuthProvider provider = new DefaultOAuthProvider(REQUEST_TOKEN_URL, ACCESS_TOKEN_URL, AUTHORIZE_URL,
httpURLConnectionClient);
getHttpUrlConnectionClientInstance());
provider.setRequestHeader("User-Agent", USER_AGENT);
final OAuthConsumer consumer = new DefaultOAuthConsumer(getConsumerKey(), getConsumerSecret());

Expand Down Expand Up @@ -247,4 +245,11 @@ protected String doInBackground(Void... params) {
task.execute();
}

private HttpURLConnectionClient getHttpUrlConnectionClientInstance() {
return HttpURLClientLazySingletonHolder.INSTANCE;
}

private static class HttpURLClientLazySingletonHolder {
static final HttpURLConnectionClient INSTANCE = HttpURLConnectionClient.create();
}
}

0 comments on commit e7ec918

Please sign in to comment.