Пример #1
0
  public static String GenarateOrder(
      String prodId,
      String nameofProduct,
      String price,
      String prodQty,
      String prodShippingCharges,
      String prodTotalPrice,
      String name,
      String contactNo,
      String email,
      String address,
      String area,
      String city,
      String pincode)
      throws Exception {

    method = "orderGenaration";
    format = "json";
    productId = prodId;
    productName = nameofProduct;
    Productprice = price;
    productQty = prodQty;
    productShippingCharges = prodShippingCharges;
    productTotalPrice = prodTotalPrice;
    custName = name;
    custContactNo = contactNo;
    custEmail = email;
    custAddress = address;
    custArea = area;
    custCity = city;
    custPincode = pincode;

    final String URL = URLInstance.getUrl();
    JSONObject params = new JSONObject();
    try {
      params.put("method", method);
      params.put("format", format);
      params.put("productId", productId);
      params.put("quantity", productQty);
      params.put("shippingCharges", productShippingCharges);
      params.put("productTotalPrice", productTotalPrice);
      params.put("customer_name", custName);
      params.put("customer_contact", custContactNo);
      params.put("customer_email", custEmail);
      params.put("address", custAddress);
      params.put("area", custArea);
      params.put("city", custCity);
      params.put("pincode", custPincode);
    } catch (Exception e) {

    }
    JsonObjectRequest orderRequest =
        new JsonObjectRequest(
            Request.Method.POST,
            URL,
            params,
            new Response.Listener<JSONObject>() {
              @Override
              public void onResponse(JSONObject response) {
                try {
                  JSONObject obj = response.getJSONObject("saveOrdersDetailsResponse");
                  OrderResponse = obj.getString("OrderGenerateResponse");
                  orderNo = obj.getString("orderId");
                  returnResponse(OrderResponse);

                } catch (JSONException e) {
                  e.printStackTrace();
                }
              }
            },
            new Response.ErrorListener() {
              @Override
              public void onErrorResponse(VolleyError error) {
                VolleyLog.e("Error: ", error.getMessage());
                Intent gotoTimeOutError = new Intent(context, TimeOut_DialogeBox.class);
                context.startActivity(gotoTimeOutError);
              }
            });
    orderRequest.setRetryPolicy(
        new DefaultRetryPolicy(
            0, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
    AppController.getInstance().addToRequestQueue(orderRequest);
    return oerderGenerateResponse;
  }
Пример #2
0
 public static List wishListPetFetchList(
     final List<WishListPetListItem> wishListPet, final RecyclerView.Adapter adapter, String url) {
   JsonObjectRequest wishListPetFetchRequest =
       new JsonObjectRequest(
           Request.Method.GET,
           url,
           null,
           new Response.Listener<JSONObject>() {
             @Override
             public void onResponse(JSONObject response) {
               try {
                 JSONArray jsonArray = response.getJSONArray("showPetWishListResponse");
                 if (jsonArray.length() == 0) {
                   Intent gotoEmptyList = new Intent(context, NullRespone_DialogeBox.class);
                   context.startActivity(gotoEmptyList);
                 } else {
                   for (int i = 0; i < jsonArray.length(); i++) {
                     try {
                       JSONObject obj = jsonArray.getJSONObject(i);
                       WishListPetListItem wishListPetListItem = new WishListPetListItem();
                       wishListPetListItem.setId(obj.getInt("id"));
                       wishListPetListItem.setFirstImagePath(obj.getString("first_image_path"));
                       if (!obj.getString("second_image_path").isEmpty()
                           && obj.getString("second_image_path") != null) {
                         wishListPetListItem.setSecondImagePath(
                             obj.getString("second_image_path"));
                       }
                       if (!obj.getString("third_image_path").isEmpty()
                           && obj.getString("third_image_path") != null) {
                         wishListPetListItem.setThirdImagePath(obj.getString("third_image_path"));
                       }
                       if (!obj.getString("pet_adoption").equals("")) {
                         wishListPetListItem.setListingType(
                             replaceSpecialChars(obj.getString("pet_adoption")));
                       } else if (!obj.getString("pet_price").equals("")) {
                         wishListPetListItem.setListingType(
                             replaceSpecialChars(obj.getString("pet_price")));
                       }
                       wishListPetListItem.setPetCategory(
                           replaceSpecialChars(obj.getString("pet_category")));
                       wishListPetListItem.setPetBreed(
                           replaceSpecialChars(obj.getString("pet_breed")));
                       wishListPetListItem.setPetAgeInMonth(obj.getString("pet_age_inMonth"));
                       wishListPetListItem.setPetAgeInYear(obj.getString("pet_age_inYear"));
                       wishListPetListItem.setPetGender(
                           replaceSpecialChars(obj.getString("pet_gender")));
                       wishListPetListItem.setPetDescription(
                           replaceSpecialChars(obj.getString("pet_description")));
                       wishListPetListItem.setPetPostDate(obj.getString("post_date"));
                       // wishListPetListItem.setPetPostOwnerEmail(replaceSpecialChars(obj.getString("email")));
                       wishListPetListItem.setAlternateNo(obj.getString("alternateNo"));
                       wishListPetListItem.setName(obj.getString("name"));
                       // adding pet to pets array
                       wishListPet.add(wishListPetListItem);
                       adapter.notifyDataSetChanged();
                     } catch (JSONException e) {
                       e.printStackTrace();
                     }
                   }
                 }
               } catch (JSONException e) {
                 e.printStackTrace();
               }
             }
           },
           new Response.ErrorListener() {
             @Override
             public void onErrorResponse(VolleyError error) {
               VolleyLog.d(TAG, "Error: " + error.getMessage());
               Intent gotoTimeOutError = new Intent(context, TimeOut_DialogeBox.class);
               context.startActivity(gotoTimeOutError);
             }
           });
   AppController.getInstance().addToRequestQueue(wishListPetFetchRequest);
   return wishListPet;
 }