@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 void journeyCheckout(JourneyDTO _selJourney) { final Calendar dd = Calendar.getInstance(); JourneyDTO jc; SimpleDateFormat da = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ENGLISH); _journeyDB = new DBJourneyCycle(this, Contents.getDBHelper().getDB()); _journey.setType("checkout"); _journeyDB.insert(_journey); jc = _journeyDB.selectByChannelIdandType(_journey.getChannelId(), "checkout"); _journey.setId(jc.getId()); if (jc != null) { _journeyDB.setChecked(jc.getId(), jc.getType(), jc.getParring_id()); _journeyDB.setCheckInDate(jc.getId(), String.valueOf(da.format(dd.getTime()))); Calendar now = Calendar.getInstance(); int hour = now.get(Calendar.HOUR_OF_DAY); int minute = (int) (now.get(Calendar.MINUTE) - Contents.track_interval); int sec = now.get(Calendar.SECOND); int day = now.get(Calendar.DAY_OF_MONTH); int month = now.get(Calendar.MONTH); int year = now.get(Calendar.YEAR); Date lastupdate = Contents.lastupdate; Date date_now = parseDate(year + "-" + month + "-" + day + " " + hour + ":" + (minute - 2) + ":" + sec); lastupdate = Contents.lastupdate; if (lastupdate != null) { if (date_now.before(lastupdate)) { _journey.setLatitude(Double.toString(Contents.lattitude)); _journey.setLongitude(Double.toString(Contents.longitude)); _journey.setAcc(Double.toString(Contents.acc)); } else { _journey.setLatitude("0"); _journey.setLongitude("0"); _journey.setAcc("0"); } } else { _journey.setLatitude("0"); _journey.setLongitude("0"); _journey.setAcc("0"); } _journeyDB.setlonglat( jc.getId(), _journey.getLongitude(), _journey.getLatitude(), _journey.getAcc()); if (isOnline()) { _journey.setUserId(Contents.getLogInfo().getUserId()); _journey.setKeyword(Contents.getLogInfo().getKeyword()); dialog = ProgressDialog.show(SGSMenu.this, "", "Mengirim data. Mohon tunggu...", true); HttpRequest.instance() .request( dialog, SGSMenu.this, Contents.URL_SERVER + "updatejourney", _journey.toJSONCheckin(), 0); } } }
public ArrayList<SellInItemDTO> selectTemp() { ArrayList<SellInItemDTO> list = new ArrayList<SellInItemDTO>(); Cursor cursor = this.db.query( TABLE_NAME, new String[] {"sellin_json,date,sell_in_date_time"}, "uploaded=? AND user_id=?", new String[] {"0", Contents.getLogInfo().getUserId()}, null, null, "id asc"); if (cursor.moveToFirst()) { do { SellInItemDTO jd = new SellInItemDTO(); jd.fromJSON(cursor.getString(0)); jd.setDate(cursor.getString(1)); jd.setSellInDateTime(cursor.getString(2)); list.add(jd); } while (cursor.moveToNext()); } if (cursor != null && !cursor.isClosed()) { cursor.close(); } return list; }
public ArrayList<SellInItemDTO> selectAll() { ArrayList<SellInItemDTO> list = new ArrayList<SellInItemDTO>(); final Calendar dd = Calendar.getInstance(); SimpleDateFormat da = new SimpleDateFormat("yyyy-MM-dd"); Cursor cursor = this.db.query( TABLE_NAME, new String[] {"sellin_json"}, "date like ? AND user_id=?", new String[] { String.valueOf(da.format(dd.getTime())) + "%", Contents.getLogInfo().getUserId() }, null, null, "id asc"); if (cursor.moveToFirst()) { do { SellInItemDTO jd = new SellInItemDTO(); jd.fromJSON(cursor.getString(0)); list.add(jd); } while (cursor.moveToNext()); } if (cursor != null && !cursor.isClosed()) { cursor.close(); } return list; }
public ArrayList<JourneyDTO> selectTodayCheckin() { final Calendar dd = Calendar.getInstance(); SimpleDateFormat da = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH); ArrayList<JourneyDTO> list = new ArrayList<JourneyDTO>(); Cursor cursor = this.db.query( TABLE_NAME, new String[] { "id, jc_id, channel_id, channel_name, channel_address," + "longitude, latitude , acc, date, " + "check_in_date, checked_in, user_id, territory_type, uploaded, " + "type, parring_id, sgo, remark, via, is_used, outlet_category, branding_id" }, "checked_in=? AND check_in_date like ? AND user_id=? AND type=?", new String[] { "1", String.valueOf(da.format(dd.getTime())) + "%", Contents.getLogInfo().getUserId(), "checkin" }, null, null, "jc_id asc"); if (cursor.moveToFirst()) { do { JourneyDTO jd = new JourneyDTO(); jd.setId(Long.parseLong(cursor.getString(0))); jd.setJourneyId(cursor.getString(1)); jd.setChannelId(cursor.getString(2)); jd.setChannelName(cursor.getString(3)); jd.setChannelAddress(cursor.getString(4)); jd.setLongitude(cursor.getString(5)); jd.setLatitude(cursor.getString(6)); jd.setAcc(cursor.getString(7)); jd.setDate(cursor.getString(8)); jd.setCheckInDate(cursor.getString(9)); jd.setCheck_in(cursor.getString(10)); jd.setUserId(cursor.getString(11)); jd.setTerritoryType(cursor.getString(12)); jd.setUpload(cursor.getString(13)); jd.setType(cursor.getString(14)); jd.setParring_id(cursor.getString(15)); jd.setSgo(cursor.getString(16)); jd.setRemark(cursor.getString(17)); jd.setVia(cursor.getString(18)); jd.setIsUsed(cursor.getString(19)); jd.setOutletCategory(cursor.getString(20)); jd.setBrandingId(cursor.getString(21)); list.add(jd); } while (cursor.moveToNext()); } if (cursor != null && !cursor.isClosed()) { cursor.close(); } return list; }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); _journey = (JourneyDTO) getIntent().getSerializableExtra("journey"); dbs = new DBMerchanCapture(MerchandiseCapture.this, Contents.getDBHelper().getDB()); dbs.deleteOld(); setContentView(R.layout.merchandisecapture); m_orders = new ArrayList<OrderMenu>(); dbpm = new DBPhotoMandatory(this, Contents.getDBHelper().getDB()); if (Contents.getLogInfo().getGroupId().equalsIgnoreCase("9")) { OrderMenu o1 = new OrderMenu(); o1.setMenuName("Foto Lokasi"); OrderMenu o2 = new OrderMenu(); o2.setMenuName("Foto Agen"); m_orders.add(o1); m_orders.add(o2); } else { OrderMenu o1 = new OrderMenu(); o1.setMenuName("Foto Outlet"); OrderMenu o2 = new OrderMenu(); o2.setMenuName("Foto Etalase"); OrderMenu o3 = new OrderMenu(); o3.setMenuName("Foto Branding"); OrderMenu o4 = new OrderMenu(); o4.setMenuName("Foto Event"); OrderMenu o5 = new OrderMenu(); o5.setMenuName("Foto POSM"); OrderMenu o6 = new OrderMenu(); o6.setMenuName("Foto Pemilik"); m_orders.add(o1); m_orders.add(o2); m_orders.add(o3); m_orders.add(o4); m_orders.add(o5); m_orders.add(o6); } this.m_adapter = new OrderAdapter(this, R.layout.menu_row, m_orders); setListAdapter(this.m_adapter); getListView().setOnItemClickListener(this); repeat = 15; is_gps_active = true; is_network_active = true; is_gps_enabled = false; is_network_enabled = false; }
public long insert(SellInItemDTO _sell) { final Calendar dd = Calendar.getInstance(); SimpleDateFormat da = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); _sell.setDate(String.valueOf(da.format(dd.getTime()))); this.insertStmt.bindString(1, _sell.toJSON()); this.insertStmt.bindString(2, "0"); this.insertStmt.bindString(3, Contents.getLogInfo().getUserId()); this.insertStmt.bindString(4, String.valueOf(da.format(dd.getTime()))); this.insertStmt.bindString(5, _sell.getSellInDateTime()); return this.insertStmt.executeInsert(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); itemDTO _group = (itemDTO) getIntent().getSerializableExtra("group"); setContentView(R.layout.prodcatalog); dbi = new DBItem(this, Contents.getDBHelper().getDB()); m_orders = dbi.selectByGroup( Contents.getLogInfo().getPartnerid(), _group.getItem_group().substring(0, _group.getItem_group().indexOf(" "))); this.m_adapter = new OrderAdapter(this, R.layout.item_row, m_orders); setListAdapter(this.m_adapter); }
public JourneyDTO selectByChannelIdandType(String channel_id, String type) { JourneyDTO jd = new JourneyDTO(); Cursor cursor = this.db.query( TABLE_NAME, new String[] { "id, jc_id, channel_id, channel_name, channel_address," + "longitude, latitude , acc, date, " + "check_in_date, checked_in, user_id, territory_type, uploaded, " + "type, parring_id, sgo, remark, via, is_used, outlet_category, branding_id" }, "channel_id=? AND user_id=? AND type=?", new String[] {channel_id, Contents.getLogInfo().getUserId(), type}, null, null, "jc_id asc"); if (cursor.moveToFirst()) { jd.setId(Long.parseLong(cursor.getString(0))); jd.setJourneyId(cursor.getString(1)); jd.setChannelId(cursor.getString(2)); jd.setChannelName(cursor.getString(3)); jd.setChannelAddress(cursor.getString(4)); jd.setLongitude(cursor.getString(5)); jd.setLatitude(cursor.getString(6)); jd.setAcc(cursor.getString(7)); jd.setDate(cursor.getString(8)); jd.setCheckInDate(cursor.getString(9)); jd.setCheck_in(cursor.getString(10)); jd.setUserId(cursor.getString(11)); jd.setTerritoryType(cursor.getString(12)); jd.setUpload(cursor.getString(13)); jd.setType(cursor.getString(14)); jd.setParring_id(cursor.getString(15)); jd.setSgo(cursor.getString(16)); jd.setRemark(cursor.getString(17)); jd.setVia(cursor.getString(18)); jd.setIsUsed(cursor.getString(19)); jd.setOutletCategory(cursor.getString(20)); jd.setBrandingId(cursor.getString(21)); } if (cursor != null && !cursor.isClosed()) { cursor.close(); } else { jd = null; } return jd; }
public ArrayList<JourneyDTO> selectTodayOri() { final Calendar dd = Calendar.getInstance(); SimpleDateFormat da = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH); ArrayList<JourneyDTO> list = new ArrayList<JourneyDTO>(); Cursor cursor = this.db.query( TABLE_NAME, new String[] { "jc_id, channel_id, channel_name, channel_address, " + "longitude, latitude, acc, date, " + "id, territory_type, type, parring_id, " + "sgo, remark , via, is_used" }, "date=? AND user_id=? AND type!='checkout'", new String[] { String.valueOf(da.format(dd.getTime())), Contents.getLogInfo().getUserId() }, null, null, "jc_id asc"); if (cursor.moveToFirst()) { do { JourneyDTO jd = new JourneyDTO(); jd.setJourneyId(cursor.getString(0)); jd.setChannelId(cursor.getString(1)); jd.setChannelName(cursor.getString(2)); jd.setChannelAddress(cursor.getString(3)); jd.setLongitude(cursor.getString(4)); jd.setLatitude(cursor.getString(5)); jd.setAcc(cursor.getString(6)); jd.setDate(cursor.getString(7)); jd.setId(Long.parseLong(cursor.getString(8))); jd.setTerritoryType(cursor.getString(9)); jd.setType(cursor.getString(10)); jd.setParring_id(cursor.getString(11)); jd.setSgo(cursor.getString(12)); jd.setRemark(cursor.getString(13)); jd.setVia(cursor.getString(14)); list.add(jd); } while (cursor.moveToNext()); } if (cursor != null && !cursor.isClosed()) { cursor.close(); } return list; }
public ArrayList<SellInItemDTO> selectICCID(String ICCID) { ArrayList<SellInItemDTO> list = new ArrayList<SellInItemDTO>(); final Calendar dd = Calendar.getInstance(); SimpleDateFormat da = new SimpleDateFormat("yyyy-MM-dd"); Cursor cursor = this.db.query( TABLE_NAME, new String[] {"sellin_json"}, "date like ? AND user_id=?", new String[] { String.valueOf(da.format(dd.getTime())) + "%", Contents.getLogInfo().getUserId() }, null, null, "id asc"); if (cursor.moveToFirst()) { do { SellInItemDTO jd = new SellInItemDTO(); jd.fromJSON(cursor.getString(0)); ArrayList<String> jdi = jd.getItems(); boolean valid = true; for (int i = 0; i < jdi.size(); i++) { if (jdi.get(i).equalsIgnoreCase(ICCID)) { valid = false; break; } } if (valid == false) { list.add(jd); } } while (cursor.moveToNext()); } if (cursor != null && !cursor.isClosed()) { cursor.close(); } return list; }
public ArrayList<String> selectTempId() { ArrayList<String> list = new ArrayList<String>(); Cursor cursor = this.db.query( TABLE_NAME, new String[] {"id"}, "uploaded=? AND user_id=?", new String[] {"0", Contents.getLogInfo().getUserId()}, null, null, "id asc"); if (cursor.moveToFirst()) { do { list.add(cursor.getString(0)); } while (cursor.moveToNext()); } if (cursor != null && !cursor.isClosed()) { cursor.close(); } return list; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.lte_coverage); dialog = new ProgressDialog(MapsLteCoverage.this); newarkBounds = new LatLngBounds(new LatLng(-11.878127, 94.662194), new LatLng(8.559047, 125.647806)); bitmapDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.lte_coverage_mobile); if (isOnline()) { dialog = ProgressDialog.show(MapsLteCoverage.this, "", "Loading. Please wait...", true); dialog.setCancelable(true); ImageView imageView = new ImageView(this); imageView.setTag(Contents.urlServerFoto + "file/images/icongis/lte_coverage2.png"); new DownloadImagesTask().execute(imageView); String url = Contents.urlServer + "bts/get_latlng_bounds_lte_coverage"; HttpRequest.instance() .request( dialog, MapsLteCoverage.this, url, "user_id=" + Contents.getLogInfo().getUserid(), 0); } else { if (dialog.isShowing()) dialog.dismiss(); Toast.makeText( getApplicationContext(), "Tidak Dapat Terhubung Ke Jaringan", Toast.LENGTH_SHORT) .show(); getMap(); getCoverage(); handleIntent(this.getIntent()); } }
public long insert(JourneyDTO _journey) { this.insertStmt.bindString(1, _journey.getJourneyId()); this.insertStmt.bindString(2, _journey.getChannelId()); this.insertStmt.bindString(3, _journey.getChannelName()); this.insertStmt.bindString(4, _journey.getChannelAddress()); this.insertStmt.bindString(5, _journey.getLongitude()); this.insertStmt.bindString(6, _journey.getLatitude()); this.insertStmt.bindString(7, _journey.getAcc()); this.insertStmt.bindString(8, _journey.getDate()); this.insertStmt.bindString(9, _journey.getDate()); this.insertStmt.bindString(10, "0"); this.insertStmt.bindString(11, Contents.getLogInfo().getUserId()); this.insertStmt.bindString(12, _journey.getTerritoryType()); this.insertStmt.bindString(13, "0"); this.insertStmt.bindString(14, _journey.getType()); this.insertStmt.bindString(15, _journey.getParring_id()); this.insertStmt.bindString(16, _journey.getSgo()); this.insertStmt.bindString(17, _journey.getRemark()); this.insertStmt.bindString(18, _journey.getVia()); this.insertStmt.bindString(19, "0"); this.insertStmt.bindString(20, _journey.getOutletCategory()); this.insertStmt.bindString(21, _journey.getBrandingId()); return this.insertStmt.executeInsert(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.poineload); tipepoinspinner = (Spinner) findViewById(R.id.tipe_poin); JumlahPoin = (EditText) findViewById(R.id.jumlah_poin); JumlahPoinSell = (TextView) findViewById(R.id.jumlahPoinSell); JumlahPoinActivation = (TextView) findViewById(R.id.jumlahPoinActivation); if (isOnline()) { dialog = ProgressDialog.show(PoinCash.this, "", "Mengirim data. Mohon tunggu...", true); dialog.setCancelable(true); String url = Contents.urlServer + "poin/get_poin"; HttpRequest.instance() .request(dialog, PoinCash.this, url, "user_id=" + Contents.getLogInfo().getUserid(), 1); } else { showMessage("Tidak Dapat Terhubung Ke Jaringan"); } List tipePoin = new ArrayList(); tipePoin.add("Sell Poin"); tipePoin.add("Activation Poin"); ArrayAdapter tipepoinAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, tipePoin); tipepoinAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); tipepoinspinner.setAdapter(tipepoinAdapter); // Spinner click listener tipepoinspinner.setOnItemSelectedListener( new OnItemSelectedListener() { public void onItemSelected(AdapterView parent, View view, int position, long id) { // On selecting a spinner item String item = parent.getItemAtPosition(position).toString(); // TipePoinSekarang = item; Log.d(tag, "Spinner yang dipilih : " + item); if (item.equals("Sell Poin")) { TipePoinSekarang = "1"; Log.d(tag, "Number spinner yang dipilih : " + TipePoinSekarang); } else { TipePoinSekarang = "2"; Log.d(tag, "Number spinner yang dipilih : " + TipePoinSekarang); } } public void onNothingSelected(AdapterView arg0) { // TODO Auto-generated method stub } }); Button bsubmit = (Button) findViewById(R.id.b_submit); bsubmit.setOnClickListener( new OnClickListener() { public void onClick(View arg0) { if (JumlahPoin.getText().toString().equals("")) { showMessage("Silakan Masukkan Jumlah Poin yang Akan Ditukar"); } else { if (isOnline()) { Log.d( tag, "jumlah poin edit text : " + Integer.parseInt(JumlahPoin.getText().toString())); Log.d( tag, "jumlah poin sell int : " + Integer.parseInt(JumlahPoinSell.getText().toString())); Log.d( tag, "jumlah poin activation int : " + Integer.parseInt(JumlahPoinActivation.getText().toString())); if (TipePoinSekarang == "1") { if (Integer.parseInt(JumlahPoin.getText().toString()) > Integer.parseInt(JumlahPoinSell.getText().toString())) { showMessage("Sell Poin anda tidak mencukupi"); } else { dialog = ProgressDialog.show( PoinCash.this, "", "Mengirim data. Mohon tunggu...", true); Log.d(tag, "Tipe poin sekarang : " + TipePoinSekarang); Log.d(tag, "Jumlah poin sekarang : " + JumlahPoin.getText().toString()); Log.d(tag, "User id sekarang : " + Contents.getLogInfo().getUserid()); Log.d(tag, "Partner id sekarang : " + Contents.getLogInfo().getPartnerid()); String url = Contents.urlServer + "poin/redeem_poin_cash"; // showMessage(itm.toJSONsave()); HttpRequest.instance() .request( dialog, PoinCash.this, url, "tipe_poin=" + TipePoinSekarang + "&jumlah_poin=" + JumlahPoin.getText().toString() + "&user_id=" + Contents.getLogInfo().getUserid() + "&partner_id=" + Contents.getLogInfo().getPartnerid(), 0); } } else { if (Integer.parseInt(JumlahPoin.getText().toString()) > Integer.parseInt(JumlahPoinActivation.getText().toString())) { showMessage("Activation Poin anda tidak mencukupi"); } else { dialog = ProgressDialog.show( PoinCash.this, "", "Mengirim data. Mohon tunggu...", true); Log.d(tag, "Tipe poin sekarang : " + TipePoinSekarang); Log.d(tag, "Jumlah poin sekarang : " + JumlahPoin.getText().toString()); Log.d(tag, "User id sekarang : " + Contents.getLogInfo().getUserid()); Log.d(tag, "Partner id sekarang : " + Contents.getLogInfo().getPartnerid()); String url = Contents.urlServer + "poin/redeem_poin_cash"; // showMessage(itm.toJSONsave()); HttpRequest.instance() .request( dialog, PoinCash.this, url, "tipe_poin=" + TipePoinSekarang + "&jumlah_poin=" + JumlahPoin.getText().toString() + "&user_id=" + Contents.getLogInfo().getUserid() + "&partner_id=" + Contents.getLogInfo().getPartnerid(), 0); } } } else { showMessage("Tidak Dapat Terhubung Ke Jaringan"); } } } }); }
@SuppressWarnings({"deprecation", "finally"}) @Override protected Boolean doInBackground(String... arg0) { Calendar dd = Calendar.getInstance(); try { URL URL = new URL(Contents.URL_SERVER + "addmerchancapture"); httpConn = (HttpURLConnection) URL.openConnection(); httpConn.setDoInput(true); httpConn.setDoOutput(true); httpConn.setUseCaches(false); httpConn.setAllowUserInteraction(true); httpConn.setReadTimeout(1000 * 60); httpConn.setConnectTimeout(1000 * 60); httpConn.setRequestMethod("POST"); httpConn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + boundary); dos = new DataOutputStream(httpConn.getOutputStream()); dos.writeBytes(twoHypens + boundary + CrLf); dos.writeBytes("Content-Disposition: form-data; name=\"user_id\"" + CrLf + CrLf); dos.writeBytes(Contents.getLogInfo().getUserId() + CrLf); dos.writeBytes(twoHypens + boundary + CrLf); dos.writeBytes("Content-Disposition: form-data; name=\"keyword\"" + CrLf + CrLf); dos.writeBytes(Contents.getLogInfo().getKeyword() + CrLf); dos.writeBytes(twoHypens + boundary + CrLf); dos.writeBytes("Content-Disposition: form-data; name=\"pic_type\"" + CrLf + CrLf); dos.writeBytes(_sinDTO.getPicType() + CrLf); dos.writeBytes(twoHypens + boundary + CrLf); dos.writeBytes("Content-Disposition: form-data; name=\"channel_id\"" + CrLf + CrLf); dos.writeBytes(_journey.getChannelId() + CrLf); dos.writeBytes(twoHypens + boundary + CrLf); dos.writeBytes("Content-Disposition: form-data; name=\"lon\"" + CrLf + CrLf); dos.writeBytes(lng + CrLf); dos.writeBytes(twoHypens + boundary + CrLf); dos.writeBytes("Content-Disposition: form-data; name=\"lat\"" + CrLf + CrLf); dos.writeBytes(lat + CrLf); dos.writeBytes(twoHypens + boundary + CrLf); dos.writeBytes("Content-Disposition: form-data; name=\"date\"" + CrLf + CrLf); dos.writeBytes("" + CrLf); dos.writeBytes(twoHypens + boundary + CrLf); dos.writeBytes( "Content-Disposition: form-data; name=\"uploadedfile\";filename=\"" + dd.getTimeInMillis() + ".jpg\"" + CrLf); dos.writeBytes("Content-Type: image/jpeg" + CrLf + CrLf); int index = 0; int size = 1024; do { System.out.println("write:" + index); if ((index + size) > imgData.length) { size = imgData.length - index; } dos.write(imgData, index, size); index += size; } while (index < imgData.length); dos.writeBytes(CrLf + twoHypens + boundary + twoHypens + CrLf); httpRespCode = httpConn.getResponseCode(); httpResponseMessage = httpConn.getResponseMessage(); dos.flush(); dos.close(); if (httpRespCode == HttpURLConnection.HTTP_OK) { try { dis = new DataInputStream(httpConn.getInputStream()); srvMessage = ""; while ((response = dis.readLine()) != null) { srvMessage = srvMessage + response; } JSONObject jsonObject = new JSONObject(srvMessage); if (jsonObject.getBoolean("success")) { imgData = null; succes = true; returnMessage = "Gambar berhasil di upload."; dbs.setUploaded(insertedId); } else { succes = true; returnMessage = jsonObject.getString("message"); if (Integer.parseInt(jsonObject.getString("error_code")) == 200) { DBLoginInfo dl = new DBLoginInfo(MerchandiseCapture.this, Contents.getDBHelper().getDB()); dl.deleteAll(); Intent mainData = new Intent(); mainData.setClass(MerchandiseCapture.this, LoginView.class); startActivity(mainData); } } dis.close(); } catch (IOException ie) { ie.printStackTrace(); succes = true; returnMessage = "Tidak dapat terhubung ke jaringan. Periksa koneksi jaringan anda"; } } else { succes = true; returnMessage = httpResponseMessage; } } catch (MalformedURLException me) { me.printStackTrace(); succes = true; returnMessage = "Tidak dapat terhubung ke jaringan. Periksa koneksi jaringan anda"; return false; } catch (IOException ie) { ie.printStackTrace(); succes = true; returnMessage = "Tidak dapat terhubung ke jaringan. Periksa koneksi jaringan anda"; return false; } finally { httpConn.disconnect(); return true; } }