Simplified callback functions for the Volley Library.
- You don't have to initialize StringRequest every time.
- No cache memory is collected.
- Optimized RetryPolicy and Timeout. (Avoid retrying twice)
Add it to your root build.gradle at the end of repositories
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add the dependency
implementation 'com.github.RabbitRk:VolleySimplified:1.0.0'
VolleyAdapter vAdapter = new VolleyAdapter(this);
// or just use the instance of the class like
new VolleyAdapter(this).//...
HashMap<String, String> map = new HashMap<>();
map.put("id", "test1");
map.put("name", "test2");
Function name may be insertData but you are going to manipulate the data in the serverside, so don't worry about that. It is for our own classification of the functions.
new VolleyAdapter(context).insertData(HashMap<String, String>, URL, new ServerCallback())
new VolleyAdapter(this).insertData(map, Config.URL, new ServerCallback() {
@Override
public void onSuccess(String result) {
## result can be converted in to the JSONarray
## using JSONObject we can parse the data from the JSONarray
}
@Override
public void onError(String result) {
}
});
Getting data from the particular URL
new VolleyAdapter(context).getData(URL, new ServerCallback())
new VolleyAdapter(this).getData(Config.URL, new ServerCallback() {
@Override
public void onSuccess(String result) {
## result can be converted in to the JSONarray
## using JSONObject we can parse the data from the JSONarray
}
@Override
public void onError(String result) {
}
});
Sending data to the URL and get the data back.
new VolleyAdapter(context).getData(HashMap<String, String>, URL, new ServerCallback())
//Overloaded getdata method can be used to get the data by sending
//quering values in the Hashmap
new VolleyAdapter(this).getData(map, Config.URL, new ServerCallback() {
@Override
public void onSuccess(String result) {
//result can be converted in to the JSONarray
//using JSONObject we can parse the data from the JSONarray
}
@Override
public void onError(String result) {
}
});
- Balaji Rk - (https://github.com/RabbitRk)
This project is licensed under the MIT License - see the LICENSE.md file for details