-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
farla/src/main/java/com/f4pl0/farla/FarlaDeleteRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |