Android Volley
This is an unofficial mirror for android volley library and is forked from mcxiaoke/android-volley, the source code will synchronize periodically with the official volley repository. Purpose of forking and publishing this library was to give OkHttp and Gson Serialization/Deserialization out of the box. This will reduce down any boilerplate code you would otherwise have to write to embed and use these.
Status
Volley is already published to Maven Central.
Usage
for Maven
<dependency>
<groupId>com.himanshuvirmani</groupId>
<artifactId>volley-okhttp-gson-library</artifactId>
<version>1.0.2</version>
</dependency>
for Gradle
repositories {
mavenCentral()
}
dependencies {
compile 'com.himanshuvirmani:volley-okhttp-gson-library:1.0.2'
}
### code sample
Create a singleton request queue for network requests via volley.
``` java
RequestQueue mRequestQueue = Volley.newRequestQueue(context.getApplicationContext());
To create a request
public void getPostById(Response.Listener<Post> listener, Response.ErrorListener errorListener,
int id) {
mRequestQueue.add(new GetPostsById(listener, errorListener, id));
}
Create a request Class that extends GsonRequest<RequestPayload,ResponsePojo>
public class GetPostsById extends GsonRequest<Void, Post> {
public GetPostsById(Response.Listener<Post> listener, Response.ErrorListener errorListener,
int id) {
super(Method.GET,
ApiConfig.BASE_URL + ApiConfig.GET_POST_BY_ID.replace("<ID>", String.valueOf(id)), listener,
errorListener);
}
}
For complete code sample check Android Base Template Code
Attention
For any Gson or OkHttp issue/suggestions please write back to me at [email protected] or open an issue here. Apart from that this project is just a mirror of volley, if you have found any bugs or need some features, please create an issue at AOSP Issue Tracker.