99import net .servicestack .client .IReturn ;
1010import net .servicestack .client .JsonServiceClient ;
1111
12+ import java .lang .reflect .Type ;
1213import java .net .HttpURLConnection ;
1314import java .util .Map ;
1415
@@ -88,6 +89,28 @@ protected void onPostExecute(T response) {
8889 }, path );
8990 }
9091
92+ @ Override
93+ public <T > void getAsync (String path , final Type responseType , final AsyncResult <T > asyncResult ) {
94+ final AndroidServiceClient client = this ;
95+ execTask (new AsyncTask <String , Void , T >() {
96+ @ Override
97+ protected T doInBackground (String ... params ) {
98+ try {
99+ return client .get (params [0 ], responseType );
100+ } catch (Exception e ) {
101+ asyncResult .setError (e );
102+ return null ;
103+ }
104+ }
105+
106+ @ Override
107+ protected void onPostExecute (T response ) {
108+ asyncResult .completeResult (response );
109+ }
110+
111+ }, path );
112+ }
113+
91114 public void getAsync (String path , final AsyncResult <HttpURLConnection > asyncResult ) {
92115 final AndroidServiceClient client = this ;
93116 execTask (new AsyncTask <String , Void , HttpURLConnection >() {
@@ -155,6 +178,28 @@ protected void onPostExecute(T response) {
155178 }, path );
156179 }
157180
181+ @ Override
182+ public <T > void postAsync (String path , final Object request , final Type responseType , final AsyncResult <T > asyncResult ) {
183+ final AndroidServiceClient client = this ;
184+ execTask (new AsyncTask <String , Void , T >() {
185+ @ Override
186+ protected T doInBackground (String ... params ) {
187+ try {
188+ return client .post (params [0 ], request , responseType );
189+ } catch (Exception e ) {
190+ asyncResult .setError (e );
191+ return null ;
192+ }
193+ }
194+
195+ @ Override
196+ protected void onPostExecute (T response ) {
197+ asyncResult .completeResult (response );
198+ }
199+
200+ }, path );
201+ }
202+
158203 @ Override
159204 public <T > void postAsync (String path , final byte [] requestBody , final String contentType , final Class responseType , final AsyncResult <T > asyncResult ) {
160205 final AndroidServiceClient client = this ;
@@ -177,6 +222,28 @@ protected void onPostExecute(T response) {
177222 }, path );
178223 }
179224
225+ @ Override
226+ public <T > void postAsync (String path , final byte [] requestBody , final String contentType , final Type responseType , final AsyncResult <T > asyncResult ) {
227+ final AndroidServiceClient client = this ;
228+ execTask (new AsyncTask <String , Void , T >() {
229+ @ Override
230+ protected T doInBackground (String ... params ) {
231+ try {
232+ return client .post (params [0 ], requestBody , contentType , responseType );
233+ } catch (Exception e ) {
234+ asyncResult .setError (e );
235+ return null ;
236+ }
237+ }
238+
239+ @ Override
240+ protected void onPostExecute (T response ) {
241+ asyncResult .completeResult (response );
242+ }
243+
244+ }, path );
245+ }
246+
180247 @ Override
181248 public void postAsync (String path , final byte [] requestBody , final String contentType , final AsyncResult <HttpURLConnection > asyncResult ) {
182249 final AndroidServiceClient client = this ;
@@ -245,6 +312,28 @@ protected void onPostExecute(T response) {
245312 }, path );
246313 }
247314
315+ @ Override
316+ public <T > void putAsync (String path , final Object request , final Type responseType , final AsyncResult <T > asyncResult ) {
317+ final AndroidServiceClient client = this ;
318+ execTask (new AsyncTask <String , Void , T >() {
319+ @ Override
320+ protected T doInBackground (String ... params ) {
321+ try {
322+ return client .put (params [0 ], request , responseType );
323+ } catch (Exception e ) {
324+ asyncResult .setError (e );
325+ return null ;
326+ }
327+ }
328+
329+ @ Override
330+ protected void onPostExecute (T response ) {
331+ asyncResult .completeResult (response );
332+ }
333+
334+ }, path );
335+ }
336+
248337 @ Override
249338 public <T > void putAsync (String path , final byte [] requestBody , final String contentType , final Class responseType , final AsyncResult <T > asyncResult ) {
250339 final AndroidServiceClient client = this ;
@@ -267,6 +356,28 @@ protected void onPostExecute(T response) {
267356 }, path );
268357 }
269358
359+ @ Override
360+ public <T > void putAsync (String path , final byte [] requestBody , final String contentType , final Type responseType , final AsyncResult <T > asyncResult ) {
361+ final AndroidServiceClient client = this ;
362+ execTask (new AsyncTask <String , Void , T >() {
363+ @ Override
364+ protected T doInBackground (String ... params ) {
365+ try {
366+ return client .put (params [0 ], requestBody , contentType , responseType );
367+ } catch (Exception e ) {
368+ asyncResult .setError (e );
369+ return null ;
370+ }
371+ }
372+
373+ @ Override
374+ protected void onPostExecute (T response ) {
375+ asyncResult .completeResult (response );
376+ }
377+
378+ }, path );
379+ }
380+
270381 @ Override
271382 public void putAsync (String path , final byte [] requestBody , final String contentType , final AsyncResult <HttpURLConnection > asyncResult ) {
272383 final AndroidServiceClient client = this ;
@@ -354,6 +465,28 @@ protected void onPostExecute(T response) {
354465 }, path );
355466 }
356467
468+ @ Override
469+ public <T > void deleteAsync (String path , final Type responseType , final AsyncResult <T > asyncResult ) {
470+ final AndroidServiceClient client = this ;
471+ execTask (new AsyncTask <String , Void , T >() {
472+ @ Override
473+ protected T doInBackground (String ... params ) {
474+ try {
475+ return client .delete (params [0 ], responseType );
476+ } catch (Exception e ) {
477+ asyncResult .setError (e );
478+ return null ;
479+ }
480+ }
481+
482+ @ Override
483+ protected void onPostExecute (T response ) {
484+ asyncResult .completeResult (response );
485+ }
486+
487+ }, path );
488+ }
489+
357490 public void deleteAsync (String path , final AsyncResult <HttpURLConnection > asyncResult ) {
358491 final AndroidServiceClient client = this ;
359492 execTask (new AsyncTask <String , Void , HttpURLConnection >() {
0 commit comments