예제 #1
0
  private void showNoteInPane(int position) {
    if (rightPane == null) return;

    if (position == -1) position = 0;

    title.setText("");
    content.setText("");

    // save index and top position

    int index = getListView().getFirstVisiblePosition();
    View v = getListView().getChildAt(0);
    int top = (v == null) ? 0 : v.getTop();

    updateNotesList(query, position);

    // restore

    getListView().setSelectionFromTop(index, top);

    if (position >= adapter.getCount()) position = 0;

    Cursor item = (Cursor) adapter.getItem(position);
    if (item == null || item.getCount() == 0) {
      TLog.d(TAG, "Index {0} not found in list", position);
      return;
    }
    TLog.d(TAG, "Getting note {0}", position);

    long noteId = item.getInt(item.getColumnIndexOrThrow(Note.ID));
    uri = Uri.parse(CONTENT_URI + "/" + noteId);

    note = NoteManager.getNote(this, uri);
    TLog.v(TAG, "Note guid: {0}", note.getGuid());

    if (note != null) {
      TLog.d(TAG, "note {0} found", position);
      noteContent =
          new NoteContentBuilder()
              .setCaller(noteContentHandler)
              .setInputSource(note.getXmlContent())
              .setTitle(note.getTitle())
              .build();
      lastIndex = position;
    } else {
      TLog.d(TAG, "The note {0} doesn't exist", uri);
      final boolean proposeShortcutRemoval;
      final boolean calledFromShortcut =
          getIntent().getBooleanExtra(CALLED_FROM_SHORTCUT_EXTRA, false);
      final String shortcutName = getIntent().getStringExtra(SHORTCUT_NAME);
      proposeShortcutRemoval = calledFromShortcut && uri != null && shortcutName != null;

      if (proposeShortcutRemoval) {
        dialogString = shortcutName;
        showDialog(DIALOG_NOT_FOUND_SHORTCUT);
      } else showDialog(DIALOG_NOT_FOUND);
    }
  }
예제 #2
0
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    TLog.d(TAG, "onActivityResult called with result {0}", resultCode);

    // returning from file picker
    if (data != null && data.hasExtra(FilePickerActivity.EXTRA_FILE_PATH)) {
      // Get the file path
      File f = new File(data.getStringExtra(FilePickerActivity.EXTRA_FILE_PATH));
      Uri noteUri = Uri.fromFile(f);
      Intent intent = new Intent(this, Receive.class);
      intent.setData(noteUri);
      startActivity(intent);
    } else { // returning from sync conflict
      SyncService currentService = SyncManager.getInstance().getCurrentService();
      currentService.resolvedConflict(requestCode);
    }
  }