- // Get the bookmark URL form the `Cursor` and display it in `bookmarkUrlTextView`.
- String bookmarkUrlString = cursor.getString(cursor.getColumnIndex(BookmarksDatabaseHelper.BOOKMARK_URL));
- TextView bookmarkUrlTextView = view.findViewById(R.id.bookmarks_databaseview_bookmark_url);
- bookmarkUrlTextView.setText(bookmarkUrlString);
+ @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);
+ }