Exemplo n.º 1
0
  private boolean updateNotes() {
    ArrayList<AppNote> changed = mDbHelper.fetchNotes(NotesDbAdapter.CHANGED_NOTES_SELECTION);
    boolean allUpdated = true;

    for (AppNote appNote : changed) {
      try {
        link.update(appNote.getNote());
        mDbHelper.updateNote(appNote.getId(), appNote.getNote(), true);
      } catch (LinkItemNotFound e) {
        e.printStackTrace();
        try {
          link.add(appNote.getNote());
          mDbHelper.updateNote(appNote.getId(), appNote.getNote(), true);
        } catch (LibOperaLinkException e1) {
          e1.printStackTrace();
          allUpdated = false;
        }
      } catch (LinkAccessDeniedException e) {
        e.printStackTrace();
        isConnected = false;
        allUpdated = false;
      } catch (LibOperaLinkException e) {
        e.printStackTrace();
        allUpdated = false;
      }
    }

    return allUpdated;
  }
Exemplo n.º 2
0
 /**
  * Change notes at the server
  *
  * @return true if succeeded
  */
 private boolean uploadNewNotes() {
   ArrayList<AppNote> newNotes = mDbHelper.fetchNotes(NotesDbAdapter.NEW_NOTES_SELECTION);
   boolean allUpdated = true;
   try {
     for (AppNote appNote : newNotes) {
       link.add(appNote.getNote());
       mDbHelper.updateNote(appNote.getId(), appNote.getNote(), true);
     }
   } catch (LinkAccessDeniedException e) {
     e.printStackTrace();
     allUpdated = false;
     isConnected = false;
   } catch (LibOperaLinkException e) {
     e.printStackTrace();
     allUpdated = false;
   }
   return allUpdated;
 }