Esempio n. 1
0
  public View getPendingOrders() {
    if (!user_id.equals("")) {
      try {
        _list.clear();
        _order_id.clear();

        MultipartEntity entity = new MultipartEntity();
        entity.addPart("user_id", new StringBody(user_id));

        String response = Interaction.postGetData(AppUrls.pendingOrders, entity);
        if (response.contains("success")) {
          JSONObject jsonObject = new JSONObject(response);
          JSONArray jsonArray = jsonObject.getJSONArray("orders");
          for (int i = 0; i < jsonArray.length(); i++) {
            /*
               {
                   "order_id": "1",
                   "bill_id": "1",
                   "user_device_id": "1",
                   "type": "1",
                   "source": "1",
                   "first_name": "Jophi",
                   "last_name": "Joe",
                   "address1": "addddd",
                   "address2": "addd",
                   "city": "Birmingham",
                   "state": "MI",
                   "zip": "48009",
                   "mobile": "999999999"
               }
            */

            JSONObject current = jsonArray.getJSONObject(i);
            String details = current.getString("first_name") + "\n" + current.getString("mobile");
            _list.add(details);
            _order_id.add(current.getString("order_id"));
          }
        }

      } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
      } catch (JSONException e) {
        e.printStackTrace();
      }
      ArrayAdapter<String> simpleAdapter =
          new ArrayAdapter<String>(_activity, android.R.layout.simple_list_item_1, _list);
      _listView.setAdapter(simpleAdapter);
      return _listView;
    } else {
      _notify.setText("Problem with loading , please logout then login");
      return _notify;
    }
  }
Esempio n. 2
0
    @Override
    protected String doInBackground(String... params) {
      String orderId = params[0];

      if (!user_id.equals("") && !orderId.equals("")) {
        try {
          // user_id
          // order_id

          MultipartEntity entity = new MultipartEntity();
          entity.addPart("user_id", new StringBody(user_id));
          entity.addPart("order_id", new StringBody(orderId));

          String response = Interaction.postGetData(AppUrls.getOrdersItems, entity);
          System.out.println(response);
        } catch (Exception e) {

        }
      }

      return "some";
    }