Created
May 14, 2016 10:38
-
-
Save gino2010/55ad8ae112f79c61ac71a5aea587e22e to your computer and use it in GitHub Desktop.
OkHttp3Stack extends HrulStack
This file contains hidden or 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
package com.gino; | |
import com.android.volley.toolbox.HurlStack; | |
import java.io.IOException; | |
import java.net.HttpURLConnection; | |
import java.net.URL; | |
import okhttp3.OkHttpClient; | |
import okhttp3.OkUrlFactory; | |
/** | |
* Created by gino on 5/14/16. | |
*/ | |
public class OkHttp3Stack extends HurlStack { | |
private final OkUrlFactory okUrlFactory; | |
public OkHttp3Stack() { | |
this(new OkUrlFactory(new OkHttpClient())); | |
} | |
public OkHttp3Stack(OkUrlFactory okUrlFactory) { | |
if (okUrlFactory == null) { | |
throw new NullPointerException("Client must not be null."); | |
} | |
this.okUrlFactory = okUrlFactory; | |
} | |
@Override | |
protected HttpURLConnection createConnection(URL url) throws IOException { | |
return okUrlFactory.open(url); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
need com.squareup.okhttp3:okhttp-urlconnection lib