diff options
author | daneren2005 <daneren2005@gmail.com> | 2013-11-26 16:03:27 -0800 |
---|---|---|
committer | daneren2005 <daneren2005@gmail.com> | 2013-11-26 16:03:27 -0800 |
commit | 24a6132bf5f852bf822e272676ceb6072f8ce248 (patch) | |
tree | 83eddee8d7cbf9ad027abcd31e3554c5ef1fd855 /src/github | |
parent | a4f873173a05745abf14b9ccdb4c2d44ab9410eb (diff) | |
download | dsub-24a6132bf5f852bf822e272676ceb6072f8ce248.tar.gz dsub-24a6132bf5f852bf822e272676ceb6072f8ce248.tar.bz2 dsub-24a6132bf5f852bf822e272676ceb6072f8ce248.zip |
#164 Match exact searches before defaulting to closest song
Diffstat (limited to 'src/github')
-rw-r--r-- | src/github/daneren2005/dsub/fragments/SearchFragment.java | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/github/daneren2005/dsub/fragments/SearchFragment.java b/src/github/daneren2005/dsub/fragments/SearchFragment.java index 81d2f29f..8eca35c0 100644 --- a/src/github/daneren2005/dsub/fragments/SearchFragment.java +++ b/src/github/daneren2005/dsub/fragments/SearchFragment.java @@ -352,10 +352,18 @@ public class SearchFragment extends SubsonicFragment { }
private void autoplay(String query) {
- if (!searchResult.getSongs().isEmpty()) {
- onSongSelected(searchResult.getSongs().get(0), false, false, true, false);
- } else if (!searchResult.getAlbums().isEmpty()) {
- onAlbumSelected(searchResult.getAlbums().get(0), true);
+ Artist artist = searchResult.getArtists().isEmpty() ? null : searchResult.getArtists().get(0);
+ MusicDirectory.Entry album = searchResult.getAlbums().isEmpty() ? null : searchResult.getAlbums().get(0);
+ MusicDirectory.Entry song = searchResult.getSongs().isEmpty() ? null : searchResult.getSongs().get(0);
+
+ if(artist != null && query.equals(artist.getName()) {
+ onArtistSelected(artist, true);
+ } else if(album != null && query.equals(album.getTitle()) {
+ onAlbumSelected(album, true);
+ } else if(song != null) {
+ onSongSelected(song, false, false, true, false);
+ } else if(album != null) {
+ onAlbumSelected(album, true);
}
}
}
|