- // Get the display order from the `Cursor` and display it in `bookmarkDisplayOrderTextView`.
- int bookmarkDisplayOrder = cursor.getInt(cursor.getColumnIndex(BookmarksDatabaseHelper.DISPLAY_ORDER));
- TextView bookmarkDisplayOrderTextView = view.findViewById(R.id.bookmarks_databaseview_display_order);
- bookmarkDisplayOrderTextView.setText(String.valueOf(bookmarkDisplayOrder));
-
- // Get the parent folder from the `Cursor` and display it in `bookmarkParentFolder`.
- String bookmarkParentFolder = cursor.getString(cursor.getColumnIndex(BookmarksDatabaseHelper.PARENT_FOLDER));
- ImageView parentFolderImageView = view.findViewById(R.id.bookmarks_databaseview_parent_folder_icon);
- TextView bookmarkParentFolderTextView = view.findViewById(R.id.bookmarks_databaseview_parent_folder);
-
- // Make the folder name gray if it is the home folder.
- if (bookmarkParentFolder.isEmpty()) {
- parentFolderImageView.setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.folder_gray));
- bookmarkParentFolderTextView.setText(R.string.home_folder);
- bookmarkParentFolderTextView.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.gray_500));
- } else {
- parentFolderImageView.setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.folder_dark_blue));
- bookmarkParentFolderTextView.setText(bookmarkParentFolder);
+ @Override
+ public void bindView(View view, Context context, Cursor cursor) {
+ boolean isFolder = (cursor.getInt(cursor.getColumnIndexOrThrow(BookmarksDatabaseHelper.IS_FOLDER)) == 1);
+
+ // Get the database ID from the `Cursor` and display it in `bookmarkDatabaseIdTextView`.
+ int bookmarkDatabaseId = cursor.getInt(cursor.getColumnIndexOrThrow(BookmarksDatabaseHelper.ID));
+ TextView bookmarkDatabaseIdTextView = view.findViewById(R.id.bookmarks_databaseview_database_id);
+ bookmarkDatabaseIdTextView.setText(String.valueOf(bookmarkDatabaseId));
+
+ // Get the favorite icon byte array from the `Cursor`.
+ byte[] favoriteIconByteArray = cursor.getBlob(cursor.getColumnIndexOrThrow(BookmarksDatabaseHelper.FAVORITE_ICON));
+ // Convert the byte array to a `Bitmap` beginning at the beginning at the first byte and ending at the last.
+ Bitmap favoriteIconBitmap = BitmapFactory.decodeByteArray(favoriteIconByteArray, 0, favoriteIconByteArray.length);
+ // Display the bitmap in `bookmarkFavoriteIcon`.
+ ImageView bookmarkFavoriteIcon = view.findViewById(R.id.bookmarks_databaseview_favorite_icon);
+ bookmarkFavoriteIcon.setImageBitmap(favoriteIconBitmap);
+
+ // Get the bookmark name from the `Cursor` and display it in `bookmarkNameTextView`.
+ String bookmarkNameString = cursor.getString(cursor.getColumnIndexOrThrow(BookmarksDatabaseHelper.BOOKMARK_NAME));
+ TextView bookmarkNameTextView = view.findViewById(R.id.bookmarks_databaseview_bookmark_name);
+ bookmarkNameTextView.setText(bookmarkNameString);
+
+ // Make the font bold for folders.
+ if (isFolder) {
+ // The first argument is `null` prevent changing of the font.
+ bookmarkNameTextView.setTypeface(null, Typeface.BOLD);
+ } else { // Reset the font to default.
+ bookmarkNameTextView.setTypeface(Typeface.DEFAULT);
+ }