- @Override
- public void bindView(View view, Context context, Cursor cursor) {
- boolean isFolder = (cursor.getInt(cursor.getColumnIndex(BookmarksDatabaseHelper.IS_FOLDER)) == 1);
-
- // Get the database ID from the `Cursor` and display it in `bookmarkDatabaseIdTextView`.
- int bookmarkDatabaseId = cursor.getInt(cursor.getColumnIndex(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.getColumnIndex(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.getColumnIndex(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);
+ // Hide the URL if the bookmark is a folder.
+ if (isFolder) {
+ bookmarkUrlTextView.setVisibility(View.GONE);
+ } else {
+ bookmarkUrlTextView.setVisibility(View.VISIBLE);
+ }
+
+ // Get the display order from the `Cursor` and display it in `bookmarkDisplayOrderTextView`.
+ int bookmarkDisplayOrder = cursor.getInt(cursor.getColumnIndexOrThrow(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.getColumnIndexOrThrow(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);
+
+ // Get the current theme status.
+ int currentThemeStatus = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
+
+ // Set the text color according to the theme.
+ if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES) {
+ // This color is a little darker than the default night mode text. But the effect is rather nice.
+ bookmarkParentFolderTextView.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.gray_300));
+ } else {
+ bookmarkParentFolderTextView.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.black));
+ }
+ }