com.android.volley.Response.Listener Java Examples

The following examples show how to use com.android.volley.Response.Listener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ShipfForMeService.java    From tgen with Apache License 2.0 6 votes vote down vote up
public static RpcRequest UserDeleteShipForMeOrder(final int orderId, final Listener<Void> listener) {
    RpcRequest req = new RpcRequest(Request.Method.POST, TRpc.getWebApiUrl() + "ShipfForMe/UserDeleteShipForMeOrder",
        new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {if (listener != null) {
                    listener.onResponse(null);
                }
            }
        }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            listener.onResponse(null);
        }
    }) {
        @Override
        public byte[] getBody() {
            HashMap<String, Object> msg = new HashMap<String, Object>();
            msg.put("orderId", orderId);

            return gson.toJson(msg).getBytes(Charset.forName("UTF-8"));
        }
    };
    TRpc.getQueue().add(req);
    return req;
}
 
Example #2
Source File: ShipfForMeService.java    From tgen with Apache License 2.0 6 votes vote down vote up
public static RpcRequest UserSaveShipForMeOrderPrice(final String orderIds, final double price, final Listener<Void> listener) {
    RpcRequest req = new RpcRequest(Request.Method.POST, TRpc.getWebApiUrl() + "ShipfForMe/UserSaveShipForMeOrderPrice",
        new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {if (listener != null) {
                    listener.onResponse(null);
                }
            }
        }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            listener.onResponse(null);
        }
    }) {
        @Override
        public byte[] getBody() {
            HashMap<String, Object> msg = new HashMap<String, Object>();
            msg.put("orderIds", orderIds);
            msg.put("price", price);

            return gson.toJson(msg).getBytes(Charset.forName("UTF-8"));
        }
    };
    TRpc.getQueue().add(req);
    return req;
}
 
Example #3
Source File: PackageService.java    From tgen with Apache License 2.0 5 votes vote down vote up
public static RpcRequest GetAcknowledgePackages(final Listener<ArrayList<TPackage>> listener) {
    RpcRequest req = new RpcRequest(Request.Method.POST, TRpc.getJsonRpcUrl(),
        new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                try {
                    ArrayList<TPackage> result;
                    result = BaseModule.fromJSONArray(response, TPackage.class);

                    listener.onResponse(result);
                } catch (Exception ex) {
                     
                    // Log.d("ex", ex.toString());
                    // Log.d("jsonObject", response);
                     
                    listener.onResponse(null);
                }
            }
        }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            listener.onResponse(null);
        }
    }) {
        @Override
        public byte[] getBody() {
            final ArrayList<Object> params = new ArrayList<>();

            HashMap<String, Object> msg = new HashMap<>();
            msg.put("id", getMsgID());
            msg.put("method", "Package.GetAcknowledgePackages");
            msg.put("params", params);

            return gson.toJson(msg).getBytes(Charset.forName("UTF-8"));
        }
    };
    TRpc.getQueue().add(req);
    return req;
}
 
Example #4
Source File: PackageService.java    From tgen with Apache License 2.0 5 votes vote down vote up
public static RpcRequest GetPendingDeliveryPackages(final Listener<ArrayList<TPendingDeliveryPackage>> listener) {
    RpcRequest req = new RpcRequest(Request.Method.POST, TRpc.getJsonRpcUrl(),
        new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                try {
                    ArrayList<TPendingDeliveryPackage> result;
                    result = BaseModule.fromJSONArray(response, TPendingDeliveryPackage.class);

                    listener.onResponse(result);
                } catch (Exception ex) {
                     
                    // Log.d("ex", ex.toString());
                    // Log.d("jsonObject", response);
                     
                    listener.onResponse(null);
                }
            }
        }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            listener.onResponse(null);
        }
    }) {
        @Override
        public byte[] getBody() {
            final ArrayList<Object> params = new ArrayList<>();

            HashMap<String, Object> msg = new HashMap<>();
            msg.put("id", getMsgID());
            msg.put("method", "Package.GetPendingDeliveryPackages");
            msg.put("params", params);

            return gson.toJson(msg).getBytes(Charset.forName("UTF-8"));
        }
    };
    TRpc.getQueue().add(req);
    return req;
}
 
Example #5
Source File: ShipfForMeService.java    From tgen with Apache License 2.0 5 votes vote down vote up
public static RpcRequest UserGetShipForMeAddressByRegion(final String originCode, final Listener<ArrayList<TShipformeAddress>> listener) {
    RpcRequest req = new RpcRequest(Request.Method.POST, TRpc.getJsonRpcUrl(),
        new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                try {
                    ArrayList<TShipformeAddress> result;
                    result = BaseModule.fromJSONArray(response, TShipformeAddress.class);

                    listener.onResponse(result);
                } catch (Exception ex) {
                     
                    // Log.d("ex", ex.toString());
                    // Log.d("jsonObject", response);
                     
                    listener.onResponse(null);
                }
            }
        }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            listener.onResponse(null);
        }
    }) {
        @Override
        public byte[] getBody() {
            final ArrayList<Object> params = new ArrayList<>();
            params.add(originCode);

            HashMap<String, Object> msg = new HashMap<>();
            msg.put("id", getMsgID());
            msg.put("method", "ShipfForMe.UserGetShipForMeAddressByRegion");
            msg.put("params", params);

            return gson.toJson(msg).getBytes(Charset.forName("UTF-8"));
        }
    };
    TRpc.getQueue().add(req);
    return req;
}
 
Example #6
Source File: ShipfForMeService.java    From tgen with Apache License 2.0 5 votes vote down vote up
public static RpcRequest UserGetShipForMeHomeSummary(final Listener<TShipForMeOrderHomeSummary> listener) {
    RpcRequest req = new RpcRequest(Request.Method.POST, TRpc.getJsonRpcUrl(),
        new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                try {
                    TShipForMeOrderHomeSummary result;
                    result = BaseModule.fromJSON(response, TShipForMeOrderHomeSummary.class);

                    listener.onResponse(result);
                } catch (Exception ex) {
                     
                    // Log.d("ex", ex.toString());
                    // Log.d("jsonObject", response);
                     
                    listener.onResponse(null);
                }
            }
        }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            listener.onResponse(null);
        }
    }) {
        @Override
        public byte[] getBody() {
            final ArrayList<Object> params = new ArrayList<>();

            HashMap<String, Object> msg = new HashMap<>();
            msg.put("id", getMsgID());
            msg.put("method", "ShipfForMe.UserGetShipForMeHomeSummary");
            msg.put("params", params);

            return gson.toJson(msg).getBytes(Charset.forName("UTF-8"));
        }
    };
    TRpc.getQueue().add(req);
    return req;
}
 
Example #7
Source File: ShipfForMeService.java    From tgen with Apache License 2.0 5 votes vote down vote up
public static RpcRequest UserSendToTelephone(final String phoneNumber, final Listener<Boolean> listener) {
    RpcRequest req = new RpcRequest(Request.Method.POST, TRpc.getWebApiUrl() + "ShipfForMe/UserSendToTelephone",
        new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                try {
                    Boolean result;
                    result = BaseModule.doFromJSON(response, Boolean.class);

                    listener.onResponse(result);
                } catch (Exception ex) {
                     
                    // Log.d("ex", ex.toString());
                    // Log.d("jsonObject", response);
                     
                    listener.onResponse(null);
                }
            }
        }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            listener.onResponse(null);
        }
    }) {
        @Override
        public byte[] getBody() {
            HashMap<String, Object> msg = new HashMap<String, Object>();
            msg.put("phoneNumber", phoneNumber);

            return gson.toJson(msg).getBytes(Charset.forName("UTF-8"));
        }
    };
    TRpc.getQueue().add(req);
    return req;
}
 
Example #8
Source File: PaymentService.java    From tgen with Apache License 2.0 5 votes vote down vote up
public static RpcRequest GetCreditCardFee(final Listener<TCreditCardInfo> listener) {
    RpcRequest req = new RpcRequest(Request.Method.POST, TRpc.getWebApiUrl() + "Payment/GetCreditCardFee",
        new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                try {
                    TCreditCardInfo result;
                    result = BaseModule.doFromJSON(response, TCreditCardInfo.class);

                    listener.onResponse(result);
                } catch (Exception ex) {
                     
                    // Log.d("ex", ex.toString());
                    // Log.d("jsonObject", response);
                     
                    listener.onResponse(null);
                }
            }
        }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            listener.onResponse(null);
        }
    }) {
        @Override
        public byte[] getBody() {
            return "".getBytes(Charset.forName("UTF-8"));
        }
    };
    TRpc.getQueue().add(req);
    return req;
}
 
Example #9
Source File: ShipfForMeService.java    From tgen with Apache License 2.0 5 votes vote down vote up
public static RpcRequest UserGetShipForMeSummary(final String originCode, final Listener<TShipForMeOrderSummary> listener) {
    RpcRequest req = new RpcRequest(Request.Method.POST, TRpc.getJsonRpcUrl(),
        new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                try {
                    TShipForMeOrderSummary result;
                    result = BaseModule.fromJSON(response, TShipForMeOrderSummary.class);

                    listener.onResponse(result);
                } catch (Exception ex) {
                     
                    // Log.d("ex", ex.toString());
                    // Log.d("jsonObject", response);
                     
                    listener.onResponse(null);
                }
            }
        }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            listener.onResponse(null);
        }
    }) {
        @Override
        public byte[] getBody() {
            final ArrayList<Object> params = new ArrayList<>();
            params.add(originCode);

            HashMap<String, Object> msg = new HashMap<>();
            msg.put("id", getMsgID());
            msg.put("method", "ShipfForMe.UserGetShipForMeSummary");
            msg.put("params", params);

            return gson.toJson(msg).getBytes(Charset.forName("UTF-8"));
        }
    };
    TRpc.getQueue().add(req);
    return req;
}
 
Example #10
Source File: ShipfForMeService.java    From tgen with Apache License 2.0 5 votes vote down vote up
public static RpcRequest UserSaveShipForMeOrderPrice(final String orderIds, final double price, final Listener<Void> listener) {
    RpcRequest req = new RpcRequest(Request.Method.POST, TRpc.getJsonRpcUrl(),
        new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {if (listener != null) {
                    listener.onResponse(null);
                }
            }
        }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            listener.onResponse(null);
        }
    }) {
        @Override
        public byte[] getBody() {
            final ArrayList<Object> params = new ArrayList<>();
            params.add(orderIds);
            params.add(price);

            HashMap<String, Object> msg = new HashMap<>();
            msg.put("id", getMsgID());
            msg.put("method", "ShipfForMe.UserSaveShipForMeOrderPrice");
            msg.put("params", params);

            return gson.toJson(msg).getBytes(Charset.forName("UTF-8"));
        }
    };
    TRpc.getQueue().add(req);
    return req;
}
 
Example #11
Source File: ShipfForMeService.java    From tgen with Apache License 2.0 5 votes vote down vote up
public static RpcRequest UserSendToTelephone(final String phoneNumber, final Listener<Boolean> listener) {
    RpcRequest req = new RpcRequest(Request.Method.POST, TRpc.getJsonRpcUrl(),
        new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                try {
                    Boolean result;
                    result = BaseModule.fromJSON(response, Boolean.class);

                    listener.onResponse(result);
                } catch (Exception ex) {
                     
                    // Log.d("ex", ex.toString());
                    // Log.d("jsonObject", response);
                     
                    listener.onResponse(null);
                }
            }
        }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            listener.onResponse(null);
        }
    }) {
        @Override
        public byte[] getBody() {
            final ArrayList<Object> params = new ArrayList<>();
            params.add(phoneNumber);

            HashMap<String, Object> msg = new HashMap<>();
            msg.put("id", getMsgID());
            msg.put("method", "ShipfForMe.UserSendToTelephone");
            msg.put("params", params);

            return gson.toJson(msg).getBytes(Charset.forName("UTF-8"));
        }
    };
    TRpc.getQueue().add(req);
    return req;
}
 
Example #12
Source File: PackageService.java    From tgen with Apache License 2.0 5 votes vote down vote up
public static RpcRequest GetPendingDeliveryPackages(final Listener<ArrayList<TPendingDeliveryPackage>> listener) {
    RpcRequest req = new RpcRequest(Request.Method.POST, TRpc.getWebApiUrl() + "Package/GetPendingDeliveryPackages",
        new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                try {
                    ArrayList<TPendingDeliveryPackage> result;
                    result = BaseModule.doFromJSONArray(response, TPendingDeliveryPackage.class);

                    listener.onResponse(result);
                } catch (Exception ex) {
                     
                    // Log.d("ex", ex.toString());
                    // Log.d("jsonObject", response);
                     
                    listener.onResponse(null);
                }
            }
        }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            listener.onResponse(null);
        }
    }) {
        @Override
        public byte[] getBody() {
            return "".getBytes(Charset.forName("UTF-8"));
        }
    };
    TRpc.getQueue().add(req);
    return req;
}
 
Example #13
Source File: PaymentService.java    From tgen with Apache License 2.0 5 votes vote down vote up
public static RpcRequest GetPaymentSummary(final Listener<TPaymentSummary> listener) {
    RpcRequest req = new RpcRequest(Request.Method.POST, TRpc.getWebApiUrl() + "Payment/GetPaymentSummary",
        new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                try {
                    TPaymentSummary result;
                    result = BaseModule.doFromJSON(response, TPaymentSummary.class);

                    listener.onResponse(result);
                } catch (Exception ex) {
                     
                    // Log.d("ex", ex.toString());
                    // Log.d("jsonObject", response);
                     
                    listener.onResponse(null);
                }
            }
        }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            listener.onResponse(null);
        }
    }) {
        @Override
        public byte[] getBody() {
            return "".getBytes(Charset.forName("UTF-8"));
        }
    };
    TRpc.getQueue().add(req);
    return req;
}
 
Example #14
Source File: ShipfForMeService.java    From tgen with Apache License 2.0 5 votes vote down vote up
public static RpcRequest UserDeleteShipForMeOrder(final int orderId, final Listener<Void> listener) {
    RpcRequest req = new RpcRequest(Request.Method.POST, TRpc.getJsonRpcUrl(),
        new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {if (listener != null) {
                    listener.onResponse(null);
                }
            }
        }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            listener.onResponse(null);
        }
    }) {
        @Override
        public byte[] getBody() {
            final ArrayList<Object> params = new ArrayList<>();
            params.add(orderId);

            HashMap<String, Object> msg = new HashMap<>();
            msg.put("id", getMsgID());
            msg.put("method", "ShipfForMe.UserDeleteShipForMeOrder");
            msg.put("params", params);

            return gson.toJson(msg).getBytes(Charset.forName("UTF-8"));
        }
    };
    TRpc.getQueue().add(req);
    return req;
}
 
Example #15
Source File: OrderService.java    From tgen with Apache License 2.0 5 votes vote down vote up
public static RpcRequest GetOrderSummary(final String originCode, final Listener<TOrderSummary> listener) {
    RpcRequest req = new RpcRequest(Request.Method.POST, TRpc.getWebApiUrl() + "Order/GetOrderSummary",
        new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                try {
                    TOrderSummary result;
                    result = BaseModule.doFromJSON(response, TOrderSummary.class);

                    listener.onResponse(result);
                } catch (Exception ex) {
                     
                    // Log.d("ex", ex.toString());
                    // Log.d("jsonObject", response);
                     
                    listener.onResponse(null);
                }
            }
        }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            listener.onResponse(null);
        }
    }) {
        @Override
        public byte[] getBody() {
            HashMap<String, Object> msg = new HashMap<String, Object>();
            msg.put("originCode", originCode);

            return gson.toJson(msg).getBytes(Charset.forName("UTF-8"));
        }
    };
    TRpc.getQueue().add(req);
    return req;
}
 
Example #16
Source File: PackageService.java    From tgen with Apache License 2.0 5 votes vote down vote up
public static RpcRequest GetInvoiceByPackageId(final int packageId, final Listener<TInvoice> listener) {
    RpcRequest req = new RpcRequest(Request.Method.POST, TRpc.getJsonRpcUrl(),
        new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                try {
                    TInvoice result;
                    result = BaseModule.fromJSON(response, TInvoice.class);

                    listener.onResponse(result);
                } catch (Exception ex) {
                     
                    // Log.d("ex", ex.toString());
                    // Log.d("jsonObject", response);
                     
                    listener.onResponse(null);
                }
            }
        }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            listener.onResponse(null);
        }
    }) {
        @Override
        public byte[] getBody() {
            final ArrayList<Object> params = new ArrayList<>();
            params.add(packageId);

            HashMap<String, Object> msg = new HashMap<>();
            msg.put("id", getMsgID());
            msg.put("method", "Package.GetInvoiceByPackageId");
            msg.put("params", params);

            return gson.toJson(msg).getBytes(Charset.forName("UTF-8"));
        }
    };
    TRpc.getQueue().add(req);
    return req;
}
 
Example #17
Source File: PackageService.java    From tgen with Apache License 2.0 5 votes vote down vote up
public static RpcRequest GetCompletedPackages(final Listener<ArrayList<TCompletedPackage>> listener) {
    RpcRequest req = new RpcRequest(Request.Method.POST, TRpc.getJsonRpcUrl(),
        new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                try {
                    ArrayList<TCompletedPackage> result;
                    result = BaseModule.fromJSONArray(response, TCompletedPackage.class);

                    listener.onResponse(result);
                } catch (Exception ex) {
                     
                    // Log.d("ex", ex.toString());
                    // Log.d("jsonObject", response);
                     
                    listener.onResponse(null);
                }
            }
        }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            listener.onResponse(null);
        }
    }) {
        @Override
        public byte[] getBody() {
            final ArrayList<Object> params = new ArrayList<>();

            HashMap<String, Object> msg = new HashMap<>();
            msg.put("id", getMsgID());
            msg.put("method", "Package.GetCompletedPackages");
            msg.put("params", params);

            return gson.toJson(msg).getBytes(Charset.forName("UTF-8"));
        }
    };
    TRpc.getQueue().add(req);
    return req;
}
 
Example #18
Source File: PackageService.java    From tgen with Apache License 2.0 5 votes vote down vote up
public static RpcRequest GetPackageListByStatus(final String status, final Listener<ArrayList<TPackage>> listener) {
    RpcRequest req = new RpcRequest(Request.Method.POST, TRpc.getJsonRpcUrl(),
        new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                try {
                    ArrayList<TPackage> result;
                    result = BaseModule.fromJSONArray(response, TPackage.class);

                    listener.onResponse(result);
                } catch (Exception ex) {
                     
                    // Log.d("ex", ex.toString());
                    // Log.d("jsonObject", response);
                     
                    listener.onResponse(null);
                }
            }
        }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            listener.onResponse(null);
        }
    }) {
        @Override
        public byte[] getBody() {
            final ArrayList<Object> params = new ArrayList<>();
            params.add(status);

            HashMap<String, Object> msg = new HashMap<>();
            msg.put("id", getMsgID());
            msg.put("method", "Package.GetPackageListByStatus");
            msg.put("params", params);

            return gson.toJson(msg).getBytes(Charset.forName("UTF-8"));
        }
    };
    TRpc.getQueue().add(req);
    return req;
}
 
Example #19
Source File: ShipfForMeService.java    From tgen with Apache License 2.0 5 votes vote down vote up
public static RpcRequest UserGetShipForMeOrderListByStatus(final String originCode, final String warehouseCode, final String status, final int offset, final int limit, final Listener<ArrayList<TShipForMeOrder>> listener) {
    RpcRequest req = new RpcRequest(Request.Method.POST, TRpc.getWebApiUrl() + "ShipfForMe/UserGetShipForMeOrderListByStatus",
        new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                try {
                    ArrayList<TShipForMeOrder> result;
                    result = BaseModule.doFromJSONArray(response, TShipForMeOrder.class);

                    listener.onResponse(result);
                } catch (Exception ex) {
                     
                    // Log.d("ex", ex.toString());
                    // Log.d("jsonObject", response);
                     
                    listener.onResponse(null);
                }
            }
        }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            listener.onResponse(null);
        }
    }) {
        @Override
        public byte[] getBody() {
            HashMap<String, Object> msg = new HashMap<String, Object>();
            msg.put("originCode", originCode);
            msg.put("warehouseCode", warehouseCode);
            msg.put("status", status);
            msg.put("offset", offset);
            msg.put("limit", limit);

            return gson.toJson(msg).getBytes(Charset.forName("UTF-8"));
        }
    };
    TRpc.getQueue().add(req);
    return req;
}
 
Example #20
Source File: PaymentService.java    From tgen with Apache License 2.0 5 votes vote down vote up
public static RpcRequest GetPaymentListByStatus(final String status, final int offset, final int limit, final Listener<ArrayList<TPaymentBillSummary>> listener) {
    RpcRequest req = new RpcRequest(Request.Method.POST, TRpc.getWebApiUrl() + "Payment/GetPaymentListByStatus",
        new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                try {
                    ArrayList<TPaymentBillSummary> result;
                    result = BaseModule.doFromJSONArray(response, TPaymentBillSummary.class);

                    listener.onResponse(result);
                } catch (Exception ex) {
                     
                    // Log.d("ex", ex.toString());
                    // Log.d("jsonObject", response);
                     
                    listener.onResponse(null);
                }
            }
        }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            listener.onResponse(null);
        }
    }) {
        @Override
        public byte[] getBody() {
            HashMap<String, Object> msg = new HashMap<String, Object>();
            msg.put("status", status);
            msg.put("offset", offset);
            msg.put("limit", limit);

            return gson.toJson(msg).getBytes(Charset.forName("UTF-8"));
        }
    };
    TRpc.getQueue().add(req);
    return req;
}
 
Example #21
Source File: OrderService.java    From tgen with Apache License 2.0 5 votes vote down vote up
public static RpcRequest UserChangeEZShipping(final boolean ezShipping, final Listener<TEzShipping> listener) {
    RpcRequest req = new RpcRequest(Request.Method.POST, TRpc.getJsonRpcUrl(),
        new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                try {
                    TEzShipping result;
                    result = BaseModule.fromJSON(response, TEzShipping.class);

                    listener.onResponse(result);
                } catch (Exception ex) {
                     
                    // Log.d("ex", ex.toString());
                    // Log.d("jsonObject", response);
                     
                    listener.onResponse(null);
                }
            }
        }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            listener.onResponse(null);
        }
    }) {
        @Override
        public byte[] getBody() {
            final ArrayList<Object> params = new ArrayList<>();
            params.add(ezShipping);

            HashMap<String, Object> msg = new HashMap<>();
            msg.put("id", getMsgID());
            msg.put("method", "Order.UserChangeEZShipping");
            msg.put("params", params);

            return gson.toJson(msg).getBytes(Charset.forName("UTF-8"));
        }
    };
    TRpc.getQueue().add(req);
    return req;
}
 
Example #22
Source File: OrderService.java    From tgen with Apache License 2.0 5 votes vote down vote up
public static RpcRequest UserAddToCartByOrderId(final int orderId, final Listener<Void> listener) {
    RpcRequest req = new RpcRequest(Request.Method.POST, TRpc.getJsonRpcUrl(),
        new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {if (listener != null) {
                    listener.onResponse(null);
                }
            }
        }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            listener.onResponse(null);
        }
    }) {
        @Override
        public byte[] getBody() {
            final ArrayList<Object> params = new ArrayList<>();
            params.add(orderId);

            HashMap<String, Object> msg = new HashMap<>();
            msg.put("id", getMsgID());
            msg.put("method", "Order.UserAddToCartByOrderId");
            msg.put("params", params);

            return gson.toJson(msg).getBytes(Charset.forName("UTF-8"));
        }
    };
    TRpc.getQueue().add(req);
    return req;
}
 
Example #23
Source File: OrderService.java    From tgen with Apache License 2.0 5 votes vote down vote up
public static RpcRequest UpdateOrder(final int orderId, final int shipmentTypeId, final String warehouseCode, final double internalShipmentFee, final boolean insured, final String productRemark, final Listener<Void> listener) {
    RpcRequest req = new RpcRequest(Request.Method.POST, TRpc.getJsonRpcUrl(),
        new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {if (listener != null) {
                    listener.onResponse(null);
                }
            }
        }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            listener.onResponse(null);
        }
    }) {
        @Override
        public byte[] getBody() {
            final ArrayList<Object> params = new ArrayList<>();
            params.add(orderId);
            params.add(shipmentTypeId);
            params.add(warehouseCode);
            params.add(internalShipmentFee);
            params.add(insured);
            params.add(productRemark);

            HashMap<String, Object> msg = new HashMap<>();
            msg.put("id", getMsgID());
            msg.put("method", "Order.UpdateOrder");
            msg.put("params", params);

            return gson.toJson(msg).getBytes(Charset.forName("UTF-8"));
        }
    };
    TRpc.getQueue().add(req);
    return req;
}
 
Example #24
Source File: OrderService.java    From tgen with Apache License 2.0 5 votes vote down vote up
public static RpcRequest ReplyOrderRemark(final int orderId, final int orderRemarkParentId, final String remark, final String pictures, final Listener<Void> listener) {
    RpcRequest req = new RpcRequest(Request.Method.POST, TRpc.getJsonRpcUrl(),
        new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {if (listener != null) {
                    listener.onResponse(null);
                }
            }
        }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            listener.onResponse(null);
        }
    }) {
        @Override
        public byte[] getBody() {
            final ArrayList<Object> params = new ArrayList<>();
            params.add(orderId);
            params.add(orderRemarkParentId);
            params.add(remark);
            params.add(pictures);

            HashMap<String, Object> msg = new HashMap<>();
            msg.put("id", getMsgID());
            msg.put("method", "Order.ReplyOrderRemark");
            msg.put("params", params);

            return gson.toJson(msg).getBytes(Charset.forName("UTF-8"));
        }
    };
    TRpc.getQueue().add(req);
    return req;
}
 
Example #25
Source File: OrderService.java    From tgen with Apache License 2.0 5 votes vote down vote up
public static RpcRequest ReplyOrderRemark(final int orderId, final int orderRemarkParentId, final String remark, final String pictures, final Listener<Void> listener) {
    RpcRequest req = new RpcRequest(Request.Method.POST, TRpc.getWebApiUrl() + "Order/ReplyOrderRemark",
        new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {if (listener != null) {
                    listener.onResponse(null);
                }
            }
        }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            listener.onResponse(null);
        }
    }) {
        @Override
        public byte[] getBody() {
            HashMap<String, Object> msg = new HashMap<String, Object>();
            msg.put("orderId", orderId);
            msg.put("orderRemarkParentId", orderRemarkParentId);
            msg.put("remark", remark);
            msg.put("pictures", pictures);

            return gson.toJson(msg).getBytes(Charset.forName("UTF-8"));
        }
    };
    TRpc.getQueue().add(req);
    return req;
}
 
Example #26
Source File: PaymentService.java    From tgen with Apache License 2.0 5 votes vote down vote up
public static RpcRequest UserRenewPrime(final Listener<TPrimePaymentResult> listener) {
    RpcRequest req = new RpcRequest(Request.Method.POST, TRpc.getWebApiUrl() + "Payment/UserRenewPrime",
        new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                try {
                    TPrimePaymentResult result;
                    result = BaseModule.doFromJSON(response, TPrimePaymentResult.class);

                    listener.onResponse(result);
                } catch (Exception ex) {
                     
                    // Log.d("ex", ex.toString());
                    // Log.d("jsonObject", response);
                     
                    listener.onResponse(null);
                }
            }
        }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            listener.onResponse(null);
        }
    }) {
        @Override
        public byte[] getBody() {
            return "".getBytes(Charset.forName("UTF-8"));
        }
    };
    TRpc.getQueue().add(req);
    return req;
}
 
Example #27
Source File: PackageService.java    From tgen with Apache License 2.0 5 votes vote down vote up
public static RpcRequest GetProductsByPackageId(final int packageId, final Listener<ArrayList<TProductComment>> listener) {
    RpcRequest req = new RpcRequest(Request.Method.POST, TRpc.getWebApiUrl() + "Package/GetProductsByPackageId",
        new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                try {
                    ArrayList<TProductComment> result;
                    result = BaseModule.doFromJSONArray(response, TProductComment.class);

                    listener.onResponse(result);
                } catch (Exception ex) {
                     
                    // Log.d("ex", ex.toString());
                    // Log.d("jsonObject", response);
                     
                    listener.onResponse(null);
                }
            }
        }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            listener.onResponse(null);
        }
    }) {
        @Override
        public byte[] getBody() {
            HashMap<String, Object> msg = new HashMap<String, Object>();
            msg.put("packageId", packageId);

            return gson.toJson(msg).getBytes(Charset.forName("UTF-8"));
        }
    };
    TRpc.getQueue().add(req);
    return req;
}
 
Example #28
Source File: PackageService.java    From tgen with Apache License 2.0 5 votes vote down vote up
public static RpcRequest GetAcknowledgePackages(final Listener<ArrayList<TPackage>> listener) {
    RpcRequest req = new RpcRequest(Request.Method.POST, TRpc.getWebApiUrl() + "Package/GetAcknowledgePackages",
        new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                try {
                    ArrayList<TPackage> result;
                    result = BaseModule.doFromJSONArray(response, TPackage.class);

                    listener.onResponse(result);
                } catch (Exception ex) {
                     
                    // Log.d("ex", ex.toString());
                    // Log.d("jsonObject", response);
                     
                    listener.onResponse(null);
                }
            }
        }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            listener.onResponse(null);
        }
    }) {
        @Override
        public byte[] getBody() {
            return "".getBytes(Charset.forName("UTF-8"));
        }
    };
    TRpc.getQueue().add(req);
    return req;
}
 
Example #29
Source File: PackageService.java    From tgen with Apache License 2.0 5 votes vote down vote up
public static RpcRequest SaveAcknowledge(final String packageIds, final String subject, final String content, final String level, final Listener<Void> listener) {
    RpcRequest req = new RpcRequest(Request.Method.POST, TRpc.getWebApiUrl() + "Package/SaveAcknowledge",
        new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {if (listener != null) {
                    listener.onResponse(null);
                }
            }
        }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            listener.onResponse(null);
        }
    }) {
        @Override
        public byte[] getBody() {
            HashMap<String, Object> msg = new HashMap<String, Object>();
            msg.put("packageIds", packageIds);
            msg.put("subject", subject);
            msg.put("content", content);
            msg.put("level", level);

            return gson.toJson(msg).getBytes(Charset.forName("UTF-8"));
        }
    };
    TRpc.getQueue().add(req);
    return req;
}
 
Example #30
Source File: OrderService.java    From tgen with Apache License 2.0 5 votes vote down vote up
public static RpcRequest UserGetEZShippingStatus(final Listener<TEzShipping> listener) {
    RpcRequest req = new RpcRequest(Request.Method.POST, TRpc.getWebApiUrl() + "Order/UserGetEZShippingStatus",
        new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                try {
                    TEzShipping result;
                    result = BaseModule.doFromJSON(response, TEzShipping.class);

                    listener.onResponse(result);
                } catch (Exception ex) {
                     
                    // Log.d("ex", ex.toString());
                    // Log.d("jsonObject", response);
                     
                    listener.onResponse(null);
                }
            }
        }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            listener.onResponse(null);
        }
    }) {
        @Override
        public byte[] getBody() {
            return "".getBytes(Charset.forName("UTF-8"));
        }
    };
    TRpc.getQueue().add(req);
    return req;
}