Skip to content

Commit

Permalink
Add DELETE Request
Browse files Browse the repository at this point in the history
  • Loading branch information
F4pl0 committed Sep 7, 2019
1 parent a732188 commit e57450c
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions farla/src/main/java/com/f4pl0/farla/FarlaDeleteRequest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package com.f4pl0.farla;

import android.content.Context;

import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;

public class FarlaDeleteRequest {

Context context;
RequestQueue requestQueue;
String URL = "";
onDeleteRequestListener listener;

public FarlaDeleteRequest(Context context) {
this.context = context;
requestQueue = Volley.newRequestQueue(context);
}

public interface onDeleteRequestListener{
void onSuccess(String response);
void onFailure(int error);
}

public FarlaDeleteRequest setURL(String URL){
this.URL = URL;
return this;
}

public FarlaDeleteRequest setListener(onDeleteRequestListener listener){
this.listener = listener;
return this;
}

public void execute(){
StringRequest deleteRequest = new StringRequest(Request.Method.DELETE, URL,
new Response.Listener<String>()
{
@Override
public void onResponse(String response) {
listener.onSuccess(response);
}
},
new Response.ErrorListener()
{
@Override
public void onErrorResponse(VolleyError error) {

}
}
);
requestQueue.add(deleteRequest);
}
}

0 comments on commit e57450c

Please sign in to comment.