Revert "Merge pull request #1018 from SimonMTaye/dev"

This reverts commit 5dd7ec15e8, reversing
changes made to 66618824e2.
main
Hemanth S 2020-12-05 03:10:23 +05:30
parent 5dd7ec15e8
commit 03df684c7e
2 changed files with 4 additions and 22 deletions

View File

@ -32,8 +32,6 @@ import code.name.monkey.retromusic.util.PreferenceUtil
interface GenreRepository { interface GenreRepository {
fun genres(): List<Genre> fun genres(): List<Genre>
fun genres(query: String): List<Genre>
fun songs(genreId: Long): List<Song> fun songs(genreId: Long): List<Song>
} }
@ -46,9 +44,6 @@ class RealGenreRepository(
return getGenresFromCursor(makeGenreCursor()) return getGenresFromCursor(makeGenreCursor())
} }
override fun genres(query: String): List<Genre> {
return getGenresFromCursor(makeGenreCursor(arrayOf("%$query%")))
}
override fun songs(genreId: Long): List<Song> { override fun songs(genreId: Long): List<Song> {
// The genres table only stores songs that have a genre specified, // The genres table only stores songs that have a genre specified,
// so we need to get songs without a genre a different way. // so we need to get songs without a genre a different way.
@ -166,19 +161,4 @@ class RealGenreRepository(
return null return null
} }
} }
private fun makeGenreCursor(selectionValues: Array<String>?): Cursor? {
val selection = MediaStore.Audio.GenresColumns.NAME + " LIKE ?"
val projection = arrayOf(Genres._ID, Genres.NAME)
return try {
contentResolver.query(
Genres.EXTERNAL_CONTENT_URI,
projection,
selection,
selectionValues,
PreferenceUtil.genreSortOrder
)
} catch (e: SecurityException) {
return null
}
}
} }

View File

@ -45,8 +45,10 @@ class RealSearchRepository(
results.add(context.resources.getString(R.string.albums)) results.add(context.resources.getString(R.string.albums))
results.addAll(albums) results.addAll(albums)
} }
val genres: List<Genre> = genreRepository.genres().filter { genre ->
val genres = genreRepository.genres(searchString) genre.name.toLowerCase(Locale.getDefault())
.contains(searchString.toLowerCase(Locale.getDefault()))
}
if (genres.isNotEmpty()) { if (genres.isNotEmpty()) {
results.add(context.resources.getString(R.string.genres)) results.add(context.resources.getString(R.string.genres))
results.addAll(genres) results.addAll(genres)