コード例 #1
0
  public void updateTaskAction() {
    taskDummy =
        new TaskObject(
            getId(),
            getTaskTitle(),
            getDescription(),
            getLocation(),
            getProximity(),
            TimeFromPickers,
            getIntervalIndexFromSpinner(),
            getIsDone(),
            getImportant());
    myDataBase.open();
    myDataBase.updateTask(taskDummy);
    TaskList.getTasksList().set(positionOftaskToEdit, taskDummy);

    if (taskDummy.getIfTaskHasProximity() != 0) {
      Log.i(
          getClass().getSimpleName(),
          "Got Task To set proximity at position"
              + positionOftaskToEdit
              + " with id: "
              + taskDummy.getTaskId());
      myGPSManager.setProximityAlert(
          positionOftaskToEdit, getLocationLatitude(), getLocationLongitude());
    }

    myDataBase.close();
  }
コード例 #2
0
  public void addANewTask() {
    myDataBase.open();
    taskDummy =
        new TaskObject(
            getId(),
            getTaskTitle(),
            getDescription(),
            getLocation(),
            getProximity(),
            TimeFromPickers,
            getIntervalIndexFromSpinner(),
            MyConstants.NOTDONE,
            MyConstants.NOTIMPORTANT);

    taskDummy.setTaskId((myDataBase.insertTask(taskDummy)));
    Log.i(getClass().getSimpleName(), "Task Created: id: " + taskDummy.getTaskId());
    TaskList.addToList(taskDummy);

    if (taskDummy.getIfTaskHasProximity() == MyConstants.HASPROXIMITY) {
      myGPSManager.setProximityAlert(
          MyConstants.INDEXOFFIRSTTASK, getLocationLatitude(), getLocationLongitude());
    }

    Handler handle = new Handler();
    handle.post(
        new Runnable() {
          public void run() {
            final MediaPlayer mediaplayer;
            // delete from database and tasklist
            mediaplayer = MediaPlayer.create(CreateTaskActivity.this, R.raw.plustask);
            mediaplayer.setVolume(1, 1);
            mediaplayer.start();
          }
        });

    myDataBase.close();
  }