From 24a6132bf5f852bf822e272676ceb6072f8ce248 Mon Sep 17 00:00:00 2001 From: daneren2005 Date: Tue, 26 Nov 2013 16:03:27 -0800 Subject: #164 Match exact searches before defaulting to closest song --- .../daneren2005/dsub/fragments/SearchFragment.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/github') 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); } } } -- cgit v1.2.3