Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Fixed
- Fixed search results resetting to the full song list after deleting a track while searching ([#85])

## [1.8.1] - 2026-02-14
### Changed
Expand Down Expand Up @@ -115,6 +117,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#47]: https://github.com/FossifyOrg/Music-Player/issues/47
[#65]: https://github.com/FossifyOrg/Music-Player/issues/65
[#69]: https://github.com/FossifyOrg/Music-Player/issues/69
[#85]: https://github.com/FossifyOrg/Music-Player/issues/85
[#97]: https://github.com/FossifyOrg/Music-Player/issues/97
[#179]: https://github.com/FossifyOrg/Music-Player/issues/179
[#206]: https://github.com/FossifyOrg/Music-Player/issues/206
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import org.fossify.musicplayer.models.sortSafely
// Artists -> Albums -> Tracks
class TracksFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet) {
private var tracks = ArrayList<Track>()
private var lastSearchQuery = ""
private val binding by viewBinding(FragmentTracksBinding::bind)

override fun setupFragment(activity: BaseSimpleActivity) {
Expand Down Expand Up @@ -70,6 +71,12 @@ class TracksFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
} else {
(adapter as TracksAdapter).updateItems(tracks)
}

// re-apply the active search filter so it isn't lost after a refresh
// (e.g. when deleting a track while searching)
if (lastSearchQuery.isNotEmpty()) {
onSearchQueryChanged(lastSearchQuery)
}
}
}
}
Expand All @@ -79,6 +86,7 @@ class TracksFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
}

override fun onSearchQueryChanged(text: String) {
lastSearchQuery = text
val normalizedText = text.normalizeString()
val filtered = ArrayList(
tracks.filter { track ->
Expand All @@ -93,6 +101,7 @@ class TracksFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
}

override fun onSearchClosed() {
lastSearchQuery = ""
getAdapter()?.updateItems(tracks)
binding.tracksPlaceholder.beGoneIf(tracks.isNotEmpty())
}
Expand Down
Loading