Created
December 27, 2013 00:56
-
-
Save krrrr38/8140942 to your computer and use it in GitHub Desktop.
volley + signpost
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.android.volley.toolbox.HurlStack; | |
import oauth.signpost.OAuthConsumer; | |
import oauth.signpost.exception.OAuthCommunicationException; | |
import oauth.signpost.exception.OAuthExpectationFailedException; | |
import oauth.signpost.exception.OAuthMessageSignerException; | |
import java.io.IOException; | |
import java.net.HttpURLConnection; | |
import java.net.URL; | |
public class OAuthStack extends HurlStack{ | |
private final OAuthConsumer consumer; | |
public OAuthStack(OAuthConsumer consumer) { | |
this.consumer = consumer; | |
} | |
@Override | |
protected HttpURLConnection createConnection(URL url) throws IOException { | |
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); | |
try { | |
consumer.sign(connection); | |
} catch (OAuthMessageSignerException e) { | |
e.printStackTrace(); | |
} catch (OAuthExpectationFailedException e) { | |
e.printStackTrace(); | |
} catch (OAuthCommunicationException e) { | |
e.printStackTrace(); | |
} | |
return connection; | |
} | |
} | |
// OAuthConsumer consumer = ~ | |
// RequestQueue queue = Volley.newRequestQueue(this.getActivity(), new OAuthStack(consumer)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nicely done 😄