예제 #1
0
 /**
  * Getting All notes
  *
  * @param checkNavigation Tells if navigation status (notes, archived) must be kept in
  *     consideration or if all notes have to be retrieved
  * @return Notes list
  */
 public List<Note> getAllNotes(Boolean checkNavigation) {
   String whereCondition = "";
   if (checkNavigation) {
     int navigation = Navigation.getNavigation();
     switch (navigation) {
       case Navigation.NOTES:
         return getNotesActive();
       case Navigation.ARCHIVE:
         return getNotesArchived();
       case Navigation.REMINDERS:
         return getNotesWithReminder(
             prefs.getBoolean(Constants.PREF_FILTER_PAST_REMINDERS, false));
       case Navigation.TRASH:
         return getNotesTrashed();
       case Navigation.UNCATEGORIZED:
         return getNotesUncategorized();
       case Navigation.CATEGORY:
         return getNotesByCategory(Navigation.getCategory());
       default:
         return getNotes(whereCondition, true);
     }
   } else {
     return getNotes(whereCondition, true);
   }
 }
예제 #2
0
 /**
  * Gets notes matching pattern with title or content text
  *
  * @param pattern String to match with
  * @return Notes list
  */
 public List<Note> getNotesByPattern(String pattern) {
   int navigation = Navigation.getNavigation();
   String whereCondition =
       " WHERE "
           + KEY_TRASHED
           + (navigation == Navigation.TRASH ? " IS 1" : " IS NOT 1")
           + (navigation == Navigation.ARCHIVE ? " AND " + KEY_ARCHIVED + " IS 1" : "")
           + (navigation == Navigation.CATEGORY
               ? " AND " + KEY_CATEGORY + " = " + Navigation.getCategory()
               : "")
           + (navigation == Navigation.UNCATEGORIZED
               ? " AND (" + KEY_CATEGORY + " IS NULL OR " + KEY_CATEGORY_ID + " == 0) "
               : "")
           + (Navigation.checkNavigation(Navigation.REMINDERS)
               ? " AND " + KEY_REMINDER + " IS NOT NULL"
               : "")
           + " AND ("
           + " ( "
           + KEY_LOCKED
           + " IS NOT 1 AND ("
           + KEY_TITLE
           + " LIKE '%"
           + pattern
           + "%' "
           + " OR "
           + KEY_CONTENT
           + " LIKE '%"
           + pattern
           + "%' ))"
           + " OR ( "
           + KEY_LOCKED
           + " = 1 AND "
           + KEY_TITLE
           + " LIKE '%"
           + pattern
           + "%' )"
           + ")";
   return getNotes(whereCondition, true);
 }