@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 1) { if (data.getCharSequenceExtra(SyncDialog.RESULT_FROM_DIALOG) .toString() .equalsIgnoreCase("ya")) { JSONObject outer = new JSONObject(); JSONArray arrItems = new JSONArray(); try { outer.put("user_id", Contents.getLogInfo().getUserid()); for (int i = 0; i < m_orders.size(); i++) { pemesananDTO penjualan = m_orders.get(i); arrItems.put(penjualan.toJSON()); } outer.put("po", arrItems); } catch (JSONException e) { System.out.println(e); } dialog = ProgressDialog.show(ListPemesanan.this, "", "Mengirim data. Mohon tunggu...", true); HttpRequest.instance() .request( dialog, ListPemesanan.this, Contents.urlServer + "po/syncpo", outer.toString(), 0); } } }
public String toJSON() { JSONObject outer = new JSONObject(); JSONArray arrItems = new JSONArray(); try { outer.put(USER_ID, this.getUserId()); outer.put(KEYWORD, this.getKeyword()); outer.put(CHANNEL_ID, this.getChannelId()); outer.put(FRONTLINER_CODE, this.getFrontlinerCode()); outer.put(CLAIM_PROGRAM, this.getClaimProgram()); for (int i = 0; i < this.getItems().size(); i++) { // JSONObject item = new JSONObject(); // item.put("item_code",this.getItems().get(i)); arrItems.put(this.getItems().get(i)); } outer.put(ITEMS, arrItems); } catch (JSONException e) { System.out.println(e); } return outer.toString(); }