diff --git a/app/src/main/java/org/marlik/innovelopers/gonnect/Gonnect.java b/app/src/main/java/org/marlik/innovelopers/gonnect/Gonnect.java index 9975aa0..8fe672c 100755 --- a/app/src/main/java/org/marlik/innovelopers/gonnect/Gonnect.java +++ b/app/src/main/java/org/marlik/innovelopers/gonnect/Gonnect.java @@ -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); @@ -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); @@ -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){ @@ -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{ diff --git a/app/src/main/java/org/marlik/innovelopers/gonnect/MainActivity.java b/app/src/main/java/org/marlik/innovelopers/gonnect/MainActivity.java index 3b15333..40d9da9 100644 --- a/app/src/main/java/org/marlik/innovelopers/gonnect/MainActivity.java +++ b/app/src/main/java/org/marlik/innovelopers/gonnect/MainActivity.java @@ -24,6 +24,12 @@ public void responseFailed(IOException exception) { },SecondActivity.class,getApplicationContext()); + Gonnect.FullResponseListener fullResponseListener=new Gonnect.FullResponseListener() { + @Override + public void responseRecieved(FullResponseStructure frs) { + + } + }; }