diff --git a/app/src/main/java/code/name/monkey/retromusic/repository/GenreRepository.kt b/app/src/main/java/code/name/monkey/retromusic/repository/GenreRepository.kt index 933e6d2d..ca7c822a 100644 --- a/app/src/main/java/code/name/monkey/retromusic/repository/GenreRepository.kt +++ b/app/src/main/java/code/name/monkey/retromusic/repository/GenreRepository.kt @@ -32,8 +32,6 @@ import code.name.monkey.retromusic.util.PreferenceUtil interface GenreRepository { fun genres(): List - fun genres(query: String): List - fun songs(genreId: Long): List } @@ -46,9 +44,6 @@ class RealGenreRepository( return getGenresFromCursor(makeGenreCursor()) } - override fun genres(query: String): List { - return getGenresFromCursor(makeGenreCursor(arrayOf("%$query%"))) - } override fun songs(genreId: Long): List { // The genres table only stores songs that have a genre specified, // so we need to get songs without a genre a different way. @@ -166,19 +161,4 @@ class RealGenreRepository( return null } } - private fun makeGenreCursor(selectionValues: Array?): 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 - } - } } diff --git a/app/src/main/java/code/name/monkey/retromusic/repository/SearchRepository.kt b/app/src/main/java/code/name/monkey/retromusic/repository/SearchRepository.kt index c026fb9f..d8bb7b06 100644 --- a/app/src/main/java/code/name/monkey/retromusic/repository/SearchRepository.kt +++ b/app/src/main/java/code/name/monkey/retromusic/repository/SearchRepository.kt @@ -45,8 +45,10 @@ class RealSearchRepository( results.add(context.resources.getString(R.string.albums)) results.addAll(albums) } - - val genres = genreRepository.genres(searchString) + val genres: List = genreRepository.genres().filter { genre -> + genre.name.toLowerCase(Locale.getDefault()) + .contains(searchString.toLowerCase(Locale.getDefault())) + } if (genres.isNotEmpty()) { results.add(context.resources.getString(R.string.genres)) results.addAll(genres)