コード例 #1
0
  @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();
    }
  }
コード例 #2
0
  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();
  }