- private fun addFolderToExceptFolders(databaseIdInt: Int) {
- // Get the name of the selected folder.
- val folderName = bookmarksDatabaseHelper.getFolderName(databaseIdInt)
-
- // Populate the list of folders not to get.
- if (exceptFolders.isEmpty()) {
- // Add the selected folder to the list of folders not to display.
- exceptFolders.append(DatabaseUtils.sqlEscapeString(folderName))
- } else {
- // Add the selected folder to the end of the list of folders not to display.
- exceptFolders.append(",")
- exceptFolders.append(DatabaseUtils.sqlEscapeString(folderName))
- }
-
- // Add the selected folder's subfolders to the list of folders not to display.
- addSubfoldersToExceptFolders(folderName)
- }
-
- private fun addSubfoldersToExceptFolders(folderName: String) {
- // Get a cursor with all the immediate subfolders.
- val subfoldersCursor = bookmarksDatabaseHelper.getSubfolders(folderName)
-
- // Add each subfolder to the list of folders not to display.
- for (i in 0 until subfoldersCursor.count) {
- // Move the subfolder cursor to the current item.
- subfoldersCursor.moveToPosition(i)
-
- // Get the name of the subfolder.
- val subfolderName = subfoldersCursor.getString(subfoldersCursor.getColumnIndex(BookmarksDatabaseHelper.BOOKMARK_NAME))
-
- // Add the subfolder to except folders.
- exceptFolders.append(",")
- exceptFolders.append(DatabaseUtils.sqlEscapeString(subfolderName))
-
- // Run the same tasks for any subfolders of the subfolder.
- addSubfoldersToExceptFolders(subfolderName)
- }
- }
-