Skip to content

Commit

Permalink
new features
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcos Thomaz committed Jan 27, 2016
1 parent 68be5dd commit 8627e90
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion HttpProject.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="HttpProject" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<module external.linked.project.id="httpproject" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle">
<configuration>
Expand Down
3 changes: 2 additions & 1 deletion app/app.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="HttpProject" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="httpproject" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
Expand All @@ -23,6 +23,7 @@
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
<option name="LIBRARY_PROJECT" value="true" />
</configuration>
</facet>
</component>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ public interface AsyncTaskListener {

/**
* @param object
* @param success
* @throws Exception
*/
void onSuccess(JSONObject object);
void onSuccess(JSONObject object, boolean success) throws Exception;

/**
*
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/thomaz/com/br/httpproject/suport/Get.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
*/
public class Get extends PrepareRequest implements Tasked {

public Get() { }

public Get(String url) {
super(url);
}

public Get(Request.Builder request) {
super(request);
}

@Override
public Request prepare() {
return request.build();
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/thomaz/com/br/httpproject/suport/Post.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
*/
public class Post extends PrepareRequest implements Tasked {

public Post() { }

public Post(String url) {
super(url);
}

public Post(Request.Builder request) {
super(request);
}

@Override
public Request prepare() {
request.url(String.format("%s%s", url, parameters));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,30 @@
*/
public abstract class PrepareRequest {

protected Request.Builder request = new Request.Builder();
protected Request.Builder request;
protected StringBuilder parameters = new StringBuilder();
protected String url;
private JSONObject object;

public PrepareRequest() {
request = new Request.Builder();
}

/**
* @param url
*/
public PrepareRequest(String url) {
this();
this.url = url;
}

/**
* @param request
*/
public PrepareRequest(Request.Builder request) {
this.request = request;
}

/**
* Address to consult
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public Request(Tasked task) {
@Override
protected void onPreExecute() throws Exception {
if( taskListener == null )
throw new NullPointerException("Must instance AsyncTaskListener via setListener method");
throw new NullPointerException("Must to be instance of AsyncTaskListener.");

taskListener.onPreExecute();
}
Expand All @@ -34,7 +34,7 @@ public JSONObject call() throws Exception {

@Override
protected void onSuccess(JSONObject object) throws Exception {
taskListener.onSuccess(object);
taskListener.onSuccess(object, object.getBoolean("success"));
}

@Override
Expand Down

0 comments on commit 8627e90

Please sign in to comment.