Skip to content

Commit

Permalink
Completed Pro Features
Browse files Browse the repository at this point in the history
The Instruction is available in the README file
  • Loading branch information
Poorya Abbasi authored and Poorya Abbasi committed May 15, 2017
1 parent 5277184 commit cd1c6e1
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 0 deletions.
116 changes: 116 additions & 0 deletions app/src/main/java/org/marlik/innovelopers/gonnect/Gonnect.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,36 @@ public static void sendRequest(String url, ContentValues values, final ResponseS

//Pro Requests

public static void sendProRequest(String url, ContentValues values, final FullResponseListener listener){

RequestBody requestBody=setupRequestBody(values);

Request request = new Request.Builder()
.url(url)
.post(requestBody)
.build();


okHttpClient.newCall(request).enqueue(new Callback() {
@Override public void onFailure(Call call, IOException e) {


}

@Override public void onResponse(Call call, Response response) throws IOException {

FullResponseStructure fullResponseStructure=new FullResponseStructure();
fullResponseStructure.body=response.body().string();
fullResponseStructure.headers=response.headers();

listener.responseRecieved(fullResponseStructure);


}
});

}

public static void sendProRequest(String url, ContentValues values, final FullResponseListener listener,Headers headers){

RequestBody requestBody=setupRequestBody(values);
Expand Down Expand Up @@ -192,6 +222,37 @@ public static void sendProRequest(String url, ContentValues values, final FullRe

}

public static void sendProRequest(String url, ContentValues values, final FullResponseListener listener,final ResponseFailureListener failureListener){

RequestBody requestBody=setupRequestBody(values);

Request request = new Request.Builder()
.url(url)
.post(requestBody)
.build();


okHttpClient.newCall(request).enqueue(new Callback() {
@Override public void onFailure(Call call, IOException e) {

failureListener.responseFailed(e);

}

@Override public void onResponse(Call call, Response response) throws IOException {

FullResponseStructure fullResponseStructure=new FullResponseStructure();
fullResponseStructure.body=response.body().string();
fullResponseStructure.headers=response.headers();

listener.responseRecieved(fullResponseStructure);


}
});

}

public static void sendProRequest(String url, ContentValues values, final FullResponseListener listener,final ResponseFailureListener failureListener,Headers headers){

RequestBody requestBody=setupRequestBody(values);
Expand Down Expand Up @@ -457,6 +518,33 @@ public static void getFullData(String url, final FullResponseListener listener){

}

public static void getFullData(String url, final FullResponseListener listener,Headers headers){


Request request=new Request.Builder()
.url(url)
.headers(headers)
.build();

okHttpClient.newCall(request).enqueue(new Callback() {
@Override public void onFailure(Call call, IOException e) {


}

@Override public void onResponse(Call call, Response response) throws IOException {

FullResponseStructure fullResponseStructure=new FullResponseStructure();
fullResponseStructure.body=response.body().string();
fullResponseStructure.headers=response.headers();

listener.responseRecieved(fullResponseStructure);

}
});

}

public static void getFullData(String url, final FullResponseListener listener,final ResponseFailureListener failureListener){


Expand Down Expand Up @@ -484,6 +572,34 @@ public static void getFullData(String url, final FullResponseListener listener,f

}

public static void getFullData(String url, final FullResponseListener listener,final ResponseFailureListener failureListener,Headers headers){


Request request=new Request.Builder()
.url(url)
.headers(headers)
.build();

okHttpClient.newCall(request).enqueue(new Callback() {
@Override public void onFailure(Call call, IOException e) {

failureListener.responseFailed(e);

}

@Override public void onResponse(Call call, Response response) throws IOException {

FullResponseStructure fullResponseStructure=new FullResponseStructure();
fullResponseStructure.body=response.body().string();
fullResponseStructure.headers=response.headers();

listener.responseRecieved(fullResponseStructure);

}
});

}

//Interfaces

public interface ResponseSuccessListener{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ public void responseFailed(IOException exception) {
},SecondActivity.class,getApplicationContext());


Gonnect.FullResponseListener fullResponseListener=new Gonnect.FullResponseListener() {
@Override
public void responseRecieved(FullResponseStructure frs) {

}
};


}
Expand Down

0 comments on commit cd1c6e1

Please sign in to comment.