Example #1
0
  protected void loadNote() {
    noteList.clear();

    // Read
    dbAdapter.open();
    Cursor c = dbAdapter.getAllNotes();

    startManagingCursor(c);

    if (c.moveToFirst()) {
      do {
        Note note =
            new Note(
                c.getInt(c.getColumnIndex(DBAdapter.COL_ID)),
                c.getString(c.getColumnIndex(DBAdapter.COL_NOTE)),
                c.getString(c.getColumnIndex(DBAdapter.COL_LASTUPDATE)));
        noteList.add(note);
      } while (c.moveToNext());
    }

    stopManagingCursor(c);
    dbAdapter.close();

    listAdapter.notifyDataSetChanged();
  }
Example #2
0
  public void importPhoto(Intent imageReturnedIntent) {
    Uri imageURI = imageReturnedIntent.getData();
    String[] filePathColumn = {MediaStore.Images.Media.DATA};

    Cursor cursor = getContentResolver().query(imageURI, filePathColumn, null, null, null);
    cursor.moveToFirst();

    int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
    String filePath = cursor.getString(columnIndex);
    cursor.close();

    Bitmap selectedImage = BitmapFactory.decodeFile(filePath);

    // create a new note
    VisionAction processing = new OpDeskew(this, selectedImage);
    String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
    Note newNote = new Note(imageURI.toString(), imageURI, processing, date);

    // make thumbnail
    newNote.thumbnail =
        Bitmap.createScaledBitmap(selectedImage, (int) (0.80 * noteList.getWidth()), 64, false);

    // start processing
    cvExecutor.execute(newNote, processing);

    // add to list of notes
    notes.add(newNote);
    noteListAdapter.notifyDataSetChanged();
  }