@Override public void handleMessage(Message msg) { if (msg.what == Status.SUCCESS) { Bundle data = msg.getData(); // cek apakah anak ini yang mau di update datanya... String idMonitoring = data.getString("idMonitoring"); // ................................................. LogMonakFileManager.debug("handler di invoke"); if (daftarMonitoring.dataMonitorings != null && daftarMonitoring.dataMonitorings.size() > 0) { boolean all = false; if (idMonitoring.equals(daftarMonitoring.anak.getIdAnak())) { all = true; } LogMonakFileManager.debug("dapat dataMonitoring dengan idMonitoring : " + idMonitoring); for (DataMonitoring dataMonitoring : daftarMonitoring.dataMonitorings) { LogMonakFileManager.debug( "dapat for dengan id datamonitoring for : " + dataMonitoring.getIdMonitoring()); if (all) { dataMonitoring.setAktif(data.getBoolean("aktif")); continue; } if (dataMonitoring.getIdMonitoring().equals(idMonitoring)) { dataMonitoring.setAktif(data.getBoolean("aktif")); } } daftarMonitoring.daftarMonitoringAdapter.notifyDataSetChanged(); } } }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { DataMonitoring dataMonitoring = null; if (resultCode == RESULT_OK) { Bundle bundle = data.getExtras(); dataMonitoring = EntityBundleMaker.getDataMonitoringFromBundle(bundle); dataMonitoring = databaseManager.getDataMonitoringByIdMonitoring( dataMonitoring.getIdMonitoring(), false, false); switch (requestCode) { case Operation.ADD: { break; } case Operation.EDIT: { for (DataMonitoring forDataMonitoring : dataMonitorings) { if (forDataMonitoring.getIdMonitoring().equals(dataMonitoring.getIdMonitoring())) { dataMonitorings.remove(forDataMonitoring); break; } } break; } } dataMonitorings.add(dataMonitoring); daftarMonitoringAdapter.notifyDataSetChanged(); } }
public void deleteSave(Bundle bundle) { DataMonitoring dataMonitoring = EntityBundleMaker.getDataMonitoringFromBundle(bundle); dataMonitoring = databaseManager.getDataMonitoringByIdMonitoring( dataMonitoring.getIdMonitoring(), true, true); if (dataMonitoring == null) { return; } databaseManager.deleteDataMonitoring(dataMonitoring); for (DataMonitoring dataMonitoringFor : dataMonitorings) { if (dataMonitoringFor.getIdMonitoring().equals(dataMonitoring.getIdMonitoring())) { dataMonitorings.remove(dataMonitoringFor); break; } } daftarMonitoringAdapter.notifyDataSetChanged(); }
private void stopMonitoring(DataMonitoring dataMonitoring) { SenderStopMonitoring sender = new SenderStopMonitoring(this); dataMonitoring = databaseManager.getDataMonitoringByIdMonitoring( dataMonitoring.getIdMonitoring(), true, true); sender.sendStopMonitoring(dataMonitoring); Toast.makeText( this, "monitoring:" + dataMonitoring.getKeterangan() + " akan dinonaktifkan", Toast.LENGTH_SHORT) .show(); }