Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class UnifiedSearchCurrentDirItemViewHolder(
overlayManager
)

binding.favoriteAction.visibility = if (file.isFavorite) View.VISIBLE else View.GONE

binding.more.setOnClickListener {
action.openFile(file.decryptedRemotePath, true)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class UnifiedSearchItemViewHolder(
bindTextView(binding.title, entry.title)
bindTextView(binding.subline, entry.subline)
bindLocalFileIndicator(entry)
bindFavoriteIndicator(entry)

val entryType = entry.getType()
bindThumbnail(entry, entryType)
Expand All @@ -85,6 +86,11 @@ class UnifiedSearchItemViewHolder(
binding.localFileIndicator.setVisibleIf(showLocalFileIndicator)
}

private fun bindFavoriteIndicator(entry: SearchResultEntry) {
val file = storageManager.getFileByRemotePath(entry.remotePath())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see multiple DB read for same path

val file = storageManager.getFileByRemotePath(entry.remotePath())

Please only read beginning of the fun bind(entry: SearchResultEntry) once then use it below for others.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied

binding.favoriteAction.setVisibleIf(file?.isFavorite == true)
}

private fun bindThumbnail(entry: SearchResultEntry, entryType: SearchResultEntryType) {
val file = storageManager.getFileByRemotePath(entry.remotePath())
Glide.with(context).clear(binding.thumbnail)
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/res/layout/unified_search_current_directory_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@

</FrameLayout>

<ImageView
android:id="@+id/favorite_action"
android:layout_width="@dimen/list_item_favorite_action_layout_width"
android:layout_height="@dimen/list_item_favorite_action_layout_height"
android:contentDescription="@string/favorite"
android:scaleType="fitCenter"
android:src="@drawable/favorite"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@+id/thumbnail"
app:layout_constraintEnd_toEndOf="@+id/thumbnail"
app:layout_constraintStart_toEndOf="@+id/thumbnail"
app:layout_constraintTop_toTopOf="@+id/thumbnail"
tools:visibility="visible" />

<LinearLayout
android:id="@+id/titleContainer"
android:layout_width="0dp"
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/res/layout/unified_search_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@
android:src="@drawable/ic_synced"
android:visibility="gone" />

<ImageView
android:id="@+id/favorite_action"
android:layout_width="@dimen/list_item_favorite_action_layout_width"
android:layout_height="@dimen/list_item_favorite_action_layout_height"
android:layout_gravity="top|end"
android:layout_marginTop="@dimen/standard_half_padding"
android:layout_marginEnd="@dimen/standard_quarter_padding"
android:contentDescription="@string/favorite"
android:scaleType="fitCenter"
android:src="@drawable/favorite"
android:visibility="gone"
tools:visibility="visible" />

</FrameLayout>

<LinearLayout
Expand Down