Skip to content

Commit

Permalink
Fix songs filtering when file name visualization is selected
Browse files Browse the repository at this point in the history
Related to #439

Signed-off-by: enricocid <[email protected]>
  • Loading branch information
enricocid committed Jul 16, 2022
1 parent 085e0e7 commit 3167fc6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions project/app/src/main/java/com/iven/musicplayergo/utils/Lists.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,19 @@ object Lists {
fun processQueryForMusic(query: String?, musicList: List<Music>?): List<Music>? {
// In real app you'd have it instantiated just once
val filteredSongs = mutableListOf<Music>()

val isShowDisplayName =
GoPreferences.getPrefsInstance().songsVisualization== GoConstants.FN
return try {
// Case insensitive search
musicList?.iterator()?.let { iterate ->
while (iterate.hasNext()) {
val filteredSong = iterate.next()
if (filteredSong.title?.lowercase()!!.contains(query?.lowercase()!!)) {
val toFilter = if (isShowDisplayName) {
filteredSong.displayName
} else {
filteredSong.title
}
if (toFilter?.lowercase()!!.contains(query?.lowercase()!!)) {
filteredSongs.add(filteredSong)
}
}
Expand Down

0 comments on commit 3167fc6

Please sign in to comment.