|
20 | 20 |
|
21 | 21 | import android.annotation.TargetApi;
|
22 | 22 | import android.app.Activity;
|
23 |
| -import android.content.Context; |
24 | 23 | import android.graphics.Color;
|
25 | 24 | import android.os.Build;
|
26 | 25 | import android.os.Bundle;
|
|
36 | 35 |
|
37 | 36 | import com.loopj.android.http.AsyncHttpClient;
|
38 | 37 | import com.loopj.android.http.AsyncHttpRequest;
|
39 |
| -import com.loopj.android.http.RequestHandle; |
40 | 38 | import com.loopj.android.http.impl.AsyncHttpClientOptions;
|
41 | 39 | import com.loopj.android.http.impl.AsyncHttpRequestOptions;
|
42 | 40 | import com.loopj.android.http.interfaces.AsyncHttpClientInterface;
|
| 41 | +import com.loopj.android.http.interfaces.AsyncHttpRequestInterface; |
43 | 42 | import com.loopj.android.http.interfaces.RequestHandleInterface;
|
| 43 | +import com.loopj.android.http.interfaces.RequestOptionsInterface; |
44 | 44 | import com.loopj.android.http.interfaces.ResponseHandlerInterface;
|
45 | 45 |
|
46 | 46 | import org.apache.http.Header;
|
47 | 47 | import org.apache.http.HttpEntity;
|
48 |
| -import org.apache.http.client.HttpClient; |
49 | 48 | import org.apache.http.client.methods.HttpUriRequest;
|
50 | 49 | import org.apache.http.entity.StringEntity;
|
51 |
| -import org.apache.http.impl.client.DefaultHttpClient; |
52 | 50 | import org.apache.http.message.BasicHeader;
|
53 |
| -import org.apache.http.protocol.HttpContext; |
54 | 51 |
|
55 | 52 | import java.io.PrintWriter;
|
56 | 53 | import java.io.StringWriter;
|
|
62 | 59 |
|
63 | 60 | public abstract class SampleParentActivity extends Activity implements SampleInterface {
|
64 | 61 |
|
65 |
| - private AsyncHttpClientInterface asyncHttpClient = AsyncHttpClient.getInstance( |
| 62 | + private AsyncHttpClientInterface asyncHttpClient = new AsyncHttpClient( |
66 | 63 | new AsyncHttpClientOptions()
|
67 |
| - .setDefaultRequestOptions( |
68 |
| - new AsyncHttpRequestOptions() |
69 |
| - .setConnectTimeout(5000) |
70 |
| - .setGzipSupportEnabled(true) |
71 |
| - .setHttpPort(80) |
72 |
| - .setHttpsPort(443) |
73 |
| - ) |
74 |
| - .enableLogging() |
75 |
| - .setLoggingVerbosity(Log.VERBOSE) |
76 |
| - ); |
77 |
| -// private AsyncHttpClient asyncHttpClient = new AsyncHttpClient() { |
78 |
| -// |
79 |
| -// @Override |
80 |
| -// protected AsyncHttpRequest newAsyncHttpRequest(DefaultHttpClient client, HttpContext httpContext, HttpUriRequest uriRequest, String contentType, ResponseHandlerInterface responseHandler, Context context) { |
81 |
| -// AsyncHttpRequest httpRequest = getHttpRequest(client, httpContext, uriRequest, contentType, responseHandler, context); |
82 |
| -// return httpRequest == null |
83 |
| -// ? super.newAsyncHttpRequest(client, httpContext, uriRequest, contentType, responseHandler, context) |
84 |
| -// : httpRequest; |
85 |
| -// } |
86 |
| -// }; |
| 64 | + .setDefaultRequestOptions( |
| 65 | + new AsyncHttpRequestOptions() |
| 66 | + .setConnectTimeout(5000) |
| 67 | + .setGzipSupportEnabled(true) |
| 68 | + .setHttpPort(80) |
| 69 | + .setHttpsPort(443) |
| 70 | + ) |
| 71 | + .enableLogging() |
| 72 | + .setLoggingVerbosity(Log.VERBOSE) |
| 73 | + ) { |
| 74 | + @Override |
| 75 | + public AsyncHttpRequestInterface getConfiguredAsyncHttpRequest(HttpUriRequest request, RequestOptionsInterface requestOptionsInterface, ResponseHandlerInterface responseHandlerInterface) { |
| 76 | + AsyncHttpRequestInterface customRequest = getHttpRequest(request, requestOptionsInterface, responseHandlerInterface); |
| 77 | + return customRequest == null ? super.getConfiguredAsyncHttpRequest(request, requestOptionsInterface, responseHandlerInterface) : customRequest; |
| 78 | + } |
| 79 | + }; |
| 80 | + |
87 | 81 | private EditText urlEditText, headersEditText, bodyEditText;
|
88 | 82 | private LinearLayout responseLayout;
|
89 | 83 | public LinearLayout customFieldsLayout;
|
@@ -174,7 +168,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
|
174 | 168 | }
|
175 | 169 |
|
176 | 170 | @Override
|
177 |
| - public AsyncHttpRequest getHttpRequest(HttpClient client, HttpContext httpContext, HttpUriRequest uriRequest, String contentType, ResponseHandlerInterface responseHandler, Context context) { |
| 171 | + public AsyncHttpRequest getHttpRequest(HttpUriRequest request, RequestOptionsInterface requestOptionsInterface, ResponseHandlerInterface responseHandlerInterface) { |
178 | 172 | return null;
|
179 | 173 | }
|
180 | 174 |
|
|
0 commit comments