Ejemplo n.º 1
0
 private void processOptions(LocalTask task) throws IOException {
   URLOptions urlOptions = new URLOptions();
   String[] parts;
   cache_unshorten = null;
   cache_titles = null;
   switch (task.getStatus()) {
     case ADDED:
     case READY:
       if (task.hasOption(Options.OPTION_UNSHORTEN)) {
         task.setStatus(Status.PROCESSING_UNSHORTEN).persist();
         String links = Utils.filterLinks(task.getTitle()).trim();
         parts = urlOptions.unshorten(links.split(" "));
         cache_unshorten = parts.clone();
         task.setTitle(Utils.replace(task.getTitle(), parts))
             .removeOption(Options.OPTION_UNSHORTEN);
       }
       if (task.hasOption(Options.OPTION_GETTITLES)) {
         task.setStatus(Status.PROCESSING_TITLE).persist();
         String links = Utils.filterLinks(task.getTitle()).trim();
         parts = urlOptions.getTitles(links.split(" "));
         cache_titles = parts.clone();
         task.setTitle(Utils.appendInBrackets(task.getTitle(), parts))
             .removeOption(Options.OPTION_GETTITLES);
       }
       task.setStatus(Status.READY);
       break;
     case PROCESSING_UNSHORTEN:
       parts = Utils.filterLinks(task.getTitle()).split(" ");
       parts = urlOptions.unshorten(parts);
       cache_unshorten = parts.clone();
       task.setTitle(Utils.replace(task.getTitle(), parts)).removeOption(Options.OPTION_UNSHORTEN);
       if (!task.hasOption(Options.OPTION_GETTITLES)) {
         task.setStatus(Status.READY);
         break;
       }
     case PROCESSING_TITLE:
       parts = Utils.filterLinks(task.getTitle()).split(" ");
       parts = urlOptions.getTitles(parts);
       cache_titles = parts.clone();
       task.setTitle(Utils.appendInBrackets(task.getTitle(), parts))
           .removeOption(Options.OPTION_GETTITLES)
           .setStatus(Status.READY);
       break;
   }
 }
Ejemplo n.º 2
0
  private void handleActionSend(LocalTask task) throws UserRecoverableAuthIOException, IOException {

    PersistCallback callback =
        new PersistCallback() {
          @Override
          public void run() {
            LocalBroadcastManager.getInstance(GoogleTasksService.this)
                .sendBroadcast(new Intent(Utils.ACTION_LIST_LOCAL_TASKS));
          }
        };

    task.setStatus(Status.SENDING).persist(callback);

    Utils.log("Sending task " + task.getTitle());

    Task new_task = new Task().setTitle(task.getTitle());
    client.tasks().insert(list_id, new_task).execute();

    task.setStatus(Status.SENT).persist(callback);
  }