Exemple #1
0
  public void completeTodo(long resourceId, int action) {
    try {
      Resource r = Resource.fromDatabase(this, resourceId);
      VCalendar todoCalendarResource = (VCalendar) VComponent.createComponentFromResource(r);
      todoCalendarResource.setEditable();
      VTodo task = (VTodo) todoCalendarResource.getMasterChild();
      task.setCompleted(AcalDateTime.getInstance());
      task.setPercentComplete(100);
      todoCalendarResource.updateTimeZones();

      ResourceManager.getInstance(this)
          .sendRequest(
              new RRResourceEditedRequest(
                  new ResourceResponseListener<Long>() {
                    @Override
                    public void resourceResponse(ResourceResponse<Long> response) {}
                  },
                  r.getCollectionId(),
                  resourceId,
                  todoCalendarResource,
                  RRResourceEditedRequest.ACTION_UPDATE));

    } catch (Exception e) {
      if (e.getMessage() != null) Log.d(TAG, e.getMessage());
      if (Constants.LOG_DEBUG) Log.println(Constants.LOGD, TAG, Log.getStackTraceString(e));
      Toast.makeText(this, getString(R.string.ErrorCompletingTask), Toast.LENGTH_LONG).show();
    }
  }
Exemple #2
0
  /**
   * ************************************************** Public Methods *
   * **************************************************
   */
  public void deleteTodo(long resourceId, int action) {
    try {
      Resource r = Resource.fromDatabase(this, resourceId);

      ResourceManager.getInstance(this)
          .sendRequest(
              new RRResourceEditedRequest(
                  new ResourceResponseListener<Long>() {
                    @Override
                    public void resourceResponse(ResourceResponse<Long> response) {}
                  },
                  r.getCollectionId(),
                  resourceId,
                  VComponent.createComponentFromResource(r),
                  RRResourceEditedRequest.ACTION_DELETE));
    } catch (Exception e) {
      if (e.getMessage() != null) Log.d(TAG, e.getMessage());
      if (Constants.LOG_DEBUG) Log.println(Constants.LOGD, TAG, Log.getStackTraceString(e));
      Toast.makeText(this, getString(R.string.ErrorDeletingTask), Toast.LENGTH_LONG).show();
    }
  }