Ejemplo n.º 1
0
 protected void startGoogleObserver() {
   service = new Tasks(transport, accessProtectedResource, new JacksonFactory());
   service.setKey(ClientCredentials.KEY);
   service.setApplicationName(getString(R.string.app_name));
   accountManager = new GoogleAccountManager(this);
   loadAccount(false);
 }
Ejemplo n.º 2
0
 private void handleActionRemove(ArrayList<String> tasks_ids)
     throws UserRecoverableAuthIOException, IOException {
   Tasks.TasksOperations tasks = client.tasks();
   for (String task_id : tasks_ids) {
     tasks.delete(list_id, task_id).execute();
   }
   handleActionList();
 }
Ejemplo n.º 3
0
  private void handleActionList() throws UserRecoverableAuthIOException, IOException {
    List<Task> list = client.tasks().list(list_id).execute().getItems();

    if (list != null) {
      ArrayList<String> ids = new ArrayList<String>();
      ArrayList<String> titles = new ArrayList<String>();
      for (Task task : list) {
        ids.add(task.getId());
        titles.add(task.getTitle());
      }

      Intent broadcast = new Intent(Utils.ACTION_LIST_TASKS);
      broadcast.putStringArrayListExtra(Utils.EXTRA_IDS, ids);
      broadcast.putStringArrayListExtra(Utils.EXTRA_TITLES, titles);
      LocalBroadcastManager.getInstance(this).sendBroadcast(broadcast);
    }
  }
Ejemplo n.º 4
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);
  }
Ejemplo n.º 5
0
 @Override
 protected List<String> doInBackground(Void... arg0) {
   try {
     List<String> result = new ArrayList<String>();
     com.google.api.services.tasks.Tasks.TasksOperations.List listRequest =
         service.tasks().list("@default");
     listRequest.setFields("items/title");
     List<Task> tasks = listRequest.execute().getItems();
     if (tasks != null) {
       for (Task task : tasks) {
         result.add(task.getTitle());
       }
     } else {
       result.add("No tasks.");
     }
     return result;
   } catch (IOException e) {
     tasksSample.handleGoogleException(e);
     return Collections.singletonList(e.getMessage());
   } finally {
     tasksSample.onRequestCompleted();
   }
 }