diff options
author | Scott Jackson <daneren2005@gmail.com> | 2012-08-08 19:53:03 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2012-08-08 19:53:03 -0700 |
commit | 50fa6554ddcf7e8e7c4147405b4ef4680d5fb5d2 (patch) | |
tree | e0938e135ddd26870b0bd9b3528a7cde3b9c8fb7 /subsonic-android | |
parent | 0e9c559392edad38d4fae4ae4e6499b14d0f430a (diff) | |
download | dsub-50fa6554ddcf7e8e7c4147405b4ef4680d5fb5d2.tar.gz dsub-50fa6554ddcf7e8e7c4147405b4ef4680d5fb5d2.tar.bz2 dsub-50fa6554ddcf7e8e7c4147405b4ef4680d5fb5d2.zip |
Fixed offline search to look for songs everywhere but root level
Diffstat (limited to 'subsonic-android')
-rw-r--r-- | subsonic-android/src/github/daneren2005/subphonic/service/OfflineMusicService.java | 55 |
1 files changed, 35 insertions, 20 deletions
diff --git a/subsonic-android/src/github/daneren2005/subphonic/service/OfflineMusicService.java b/subsonic-android/src/github/daneren2005/subphonic/service/OfflineMusicService.java index 8ee17a27..56d18414 100644 --- a/subsonic-android/src/github/daneren2005/subphonic/service/OfflineMusicService.java +++ b/subsonic-android/src/github/daneren2005/subphonic/service/OfflineMusicService.java @@ -163,32 +163,47 @@ public class OfflineMusicService extends RESTMusicService { artists.add(artist); } - for(File albumFile : FileUtil.listMusicFiles(artistFile)) { - if(albumFile.isDirectory()) { - String albumName = getName(albumFile); - if(matchCriteria(criteria, albumName)) { - MusicDirectory.Entry album = createEntry(context, albumFile, albumName); - album.setArtist(artistName); - albums.add(album); - } - - for(File songFile : FileUtil.listMusicFiles(albumFile)) { - String songName = getName(songFile); - if(matchCriteria(criteria, songName)) { - MusicDirectory.Entry song = createEntry(context, albumFile, songName); - song.setArtist(artistName); - song.setAlbum(albumName); - songs.add(song); - } - } - } - } + recursiveAlbumSearch(artistName, artistFile, criteria, context, albums, songs); } } return new SearchResult(artists, albums, songs); } + private void recursiveAlbumSearch(String artistName, File file, SearchCritera criteria, Context context, List<MusicDirectory.Entry> albums, List<MusicDirectory.Entry> songs) { + for(File albumFile : FileUtil.listMusicFiles(file)) { + if(albumFile.isDirectory()) { + String albumName = getName(albumFile); + if(matchCriteria(criteria, albumName)) { + MusicDirectory.Entry album = createEntry(context, albumFile, albumName); + album.setArtist(artistName); + albums.add(album); + } + + for(File songFile : FileUtil.listMusicFiles(albumFile)) { + String songName = getName(songFile); + if(songFile.isDirectory()) { + recursiveAlbumSearch(artistName, songFile, criteria, context, albums, songs); + } + else if(matchCriteria(criteria, songName)){ + MusicDirectory.Entry song = createEntry(context, albumFile, songName); + song.setArtist(artistName); + song.setAlbum(albumName); + songs.add(song); + } + } + } + else { + String songName = getName(albumFile); + if(matchCriteria(criteria, songName)) { + MusicDirectory.Entry song = createEntry(context, albumFile, songName); + song.setArtist(artistName); + song.setAlbum(songName); + songs.add(song); + } + } + } + } private boolean matchCriteria(SearchCritera criteria, String name) { String query = criteria.getQuery().toLowerCase(); String[] parts = query.split(" "); |