Skip to content

Instantly share code, notes, and snippets.

@azuby
Created November 27, 2012 05:02
Show Gist options
  • Save azuby/4152486 to your computer and use it in GitHub Desktop.
Save azuby/4152486 to your computer and use it in GitHub Desktop.
Job job = new Job(activity);
// Create
job.create();
// Read
ArrayList<NameValuePair> parameters;
Job.where(parameters)
// Update
job.update();
// Destroy
job.destroy();
public class Job extends Model {
private static final String ROUTE = "jobs";
public Job(Activity activity) {
super(ROUTE, activity);
}
}
public class Model {
JSONClient clientFactory;
private final String resource;
protected Model(String resource, Activity activity) {
this.resource = resource;
clientFactory = new JSONClient(activity);
}
public JSONObject create() {
return clientFactory.requestPost(resource, this);
}
public JSONObject update() {
return clientFactory.requestUpdate(resource, this);
}
public JSONObject destroy() {
return clientFactory.requestDelete(resource, this);
}
public static JSONObject where(ArrayList<NameValuePair> parameters) {
return clientFactory.requestGet(resource, parameters);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment