Search in sources :

Example 1 with ASFRequestListener

use of com.github.asifmujteba.easyvolley.ASFRequestListener in project EasyVolley by asifmujteba.

the class ServerController method getWomenClothingProducts.

public void getWomenClothingProducts(Object subscriber, final OnServerResponseListener<ArrayList<Product>> listener) {
    EasyVolley.withGlobalQueue().load(URLWomenClothing).addParam("p1", "something").asJsonObject().setSubscriber(subscriber).setCallback(new ASFRequestListener<JsonObject>() {

        @Override
        public void onSuccess(JsonObject response) {
            JsonArray results = response.get("metadata").getAsJsonObject().getAsJsonArray("results");
            ArrayList<Product> products = Product.parseJsonArray(results);
            if (listener != null) {
                listener.onSuccess(products);
            }
        }

        @Override
        public void onFailure(Exception e) {
            if (listener != null) {
                listener.onError(e);
            }
        }
    }).start();
}
Also used : JsonArray(com.google.gson.JsonArray) JsonObject(com.google.gson.JsonObject) Product(com.github.asifmujteba.easyvolleysample.Models.Product) ASFRequestListener(com.github.asifmujteba.easyvolley.ASFRequestListener)

Aggregations

ASFRequestListener (com.github.asifmujteba.easyvolley.ASFRequestListener)1 Product (com.github.asifmujteba.easyvolleysample.Models.Product)1 JsonArray (com.google.gson.JsonArray)1 JsonObject (com.google.gson.JsonObject)1