-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alexander James Wallar
committed
Jan 20, 2014
1 parent
4080336
commit 287df0f
Showing
3 changed files
with
111 additions
and
87 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.locaudio.net; | ||
|
||
import java.io.IOException; | ||
import java.util.concurrent.ExecutionException; | ||
|
||
import org.apache.http.client.ClientProtocolException; | ||
|
||
import android.os.AsyncTask; | ||
|
||
import com.locaudio.net.Requests; | ||
|
||
public class AsyncGetRequest<T> extends AsyncTask<Requests, Integer, T> { | ||
|
||
private Class<T> tClass; | ||
private String[] urlParams = null; | ||
|
||
public AsyncGetRequest(Class<T> tClass, String... urlParams) { | ||
this.tClass = tClass; | ||
this.urlParams = urlParams; | ||
} | ||
|
||
public T getResponse(Requests reqs) { | ||
try { | ||
this.execute(reqs); | ||
return this.get(); | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); | ||
return null; | ||
} catch (ExecutionException e) { | ||
e.printStackTrace(); | ||
return null; | ||
} | ||
} | ||
|
||
@Override | ||
protected T doInBackground(Requests... reqs) { | ||
try { | ||
return reqs[0].get(this.tClass, this.urlParams); | ||
} catch (ClientProtocolException e) { | ||
e.printStackTrace(); | ||
return null; | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
return null; | ||
} | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.locaudio.net; | ||
|
||
import java.io.IOException; | ||
import java.util.Map; | ||
import java.util.concurrent.ExecutionException; | ||
|
||
import org.apache.http.client.ClientProtocolException; | ||
|
||
import android.os.AsyncTask; | ||
|
||
import com.locaudio.net.Requests; | ||
|
||
public class AsyncPostRequest<T> extends AsyncTask<Requests, Integer, T> { | ||
|
||
private Class<T> tClass; | ||
private Map<String, ?> postForm = null; | ||
private String[] urlParams = null; | ||
|
||
public AsyncPostRequest(Class<T> tClass, Map<String, ?> postForm, | ||
String... urlParams) { | ||
this.tClass = tClass; | ||
this.postForm = postForm; | ||
this.urlParams = urlParams; | ||
} | ||
|
||
public T getResponse(Requests reqs) { | ||
try { | ||
this.execute(reqs); | ||
return this.get(); | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); | ||
return null; | ||
} catch (ExecutionException e) { | ||
e.printStackTrace(); | ||
return null; | ||
} | ||
} | ||
|
||
@Override | ||
protected T doInBackground(Requests... reqs) { | ||
try { | ||
return reqs[0].post(this.tClass, this.postForm, this.urlParams); | ||
} catch (ClientProtocolException e) { | ||
e.printStackTrace(); | ||
return null; | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
return null; | ||
} | ||
} | ||
|
||
} |