aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-07-02 20:13:50 -0700
committerScott Jackson <daneren2005@gmail.com>2014-07-02 20:13:50 -0700
commitb7430917ae32ce49e46aff4e35f2aa8a7b19e27f (patch)
treee60319b8c1fa78934600cff14b38c98fd90a357c
parentcf9de6ebdc40a76ca8f47ccf2f25c3100cc33934 (diff)
downloaddsub-b7430917ae32ce49e46aff4e35f2aa8a7b19e27f.tar.gz
dsub-b7430917ae32ce49e46aff4e35f2aa8a7b19e27f.tar.bz2
dsub-b7430917ae32ce49e46aff4e35f2aa8a7b19e27f.zip
#362 Scroll to song when clicking in search results
-rw-r--r--src/github/daneren2005/dsub/activity/QueryReceiverActivity.java8
-rw-r--r--src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java1
-rw-r--r--src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java12
-rw-r--r--src/github/daneren2005/dsub/provider/DSubSearchProvider.java2
-rw-r--r--src/github/daneren2005/dsub/util/Constants.java1
5 files changed, 22 insertions, 2 deletions
diff --git a/src/github/daneren2005/dsub/activity/QueryReceiverActivity.java b/src/github/daneren2005/dsub/activity/QueryReceiverActivity.java
index 4678bbc5..eefb9c56 100644
--- a/src/github/daneren2005/dsub/activity/QueryReceiverActivity.java
+++ b/src/github/daneren2005/dsub/activity/QueryReceiverActivity.java
@@ -24,6 +24,7 @@ import android.app.SearchManager;
import android.content.Intent;
import android.os.Bundle;
import android.provider.SearchRecentSuggestions;
+import android.util.Log;
import github.daneren2005.dsub.fragments.SubsonicFragment;
import github.daneren2005.dsub.util.Constants;
@@ -37,7 +38,9 @@ import github.daneren2005.dsub.provider.DSubSearchProvider;
*/
public class QueryReceiverActivity extends Activity {
- @Override
+ private static final String TAG = QueryReceiverActivity.class.getSimpleName();
+
+ @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -68,6 +71,9 @@ public class QueryReceiverActivity extends Activity {
if(albumId.indexOf("ar-") == 0) {
intent.putExtra(Constants.INTENT_EXTRA_NAME_ARTIST, true);
albumId = albumId.replace("ar-", "");
+ } else if(albumId.indexOf("so-") == 0) {
+ intent.putExtra(Constants.INTENT_EXTRA_SEARCH_SONG, name);
+ albumId = albumId.replace("so-", "");
}
intent.putExtra(Constants.INTENT_EXTRA_NAME_ID, albumId);
if (name != null) {
diff --git a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java
index aa977c2c..9845411a 100644
--- a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java
+++ b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java
@@ -282,6 +282,7 @@ public class SubsonicFragmentActivity extends SubsonicActivity {
Bundle args = new Bundle();
args.putString(Constants.INTENT_EXTRA_NAME_ID, getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_ID));
args.putString(Constants.INTENT_EXTRA_NAME_NAME, getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_NAME));
+ args.putString(Constants.INTENT_EXTRA_SEARCH_SONG, getIntent().getStringExtra(Constants.INTENT_EXTRA_SEARCH_SONG));
if(getIntent().hasExtra(Constants.INTENT_EXTRA_NAME_ARTIST)) {
args.putBoolean(Constants.INTENT_EXTRA_NAME_ARTIST, true);
}
diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
index 79d5fc4d..d40f8fad 100644
--- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
@@ -80,6 +80,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
boolean restoredInstance = false;
boolean lookupParent = false;
boolean largeAlbums = false;
+ String lookupEntry;
public SelectDirectoryFragment() {
super();
@@ -121,6 +122,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
albumListSize = args.getInt(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_SIZE, 0);
refreshListing = args.getBoolean(Constants.INTENT_EXTRA_REFRESH_LISTINGS);
artist = args.getBoolean(Constants.INTENT_EXTRA_NAME_ARTIST, false);
+ lookupEntry = args.getString(Constants.INTENT_EXTRA_SEARCH_SONG);
String childId = args.getString(Constants.INTENT_EXTRA_NAME_CHILD_ID);
if(childId != null) {
@@ -699,6 +701,16 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
}
context.supportInvalidateOptionsMenu();
+ if(lookupEntry != null) {
+ for(int i = 0; i < entries.size(); i++) {
+ if(lookupEntry.equals(entries.get(i).getTitle())) {
+ entryList.setSelection(i + entryList.getHeaderViewsCount());
+ lookupEntry = null;
+ break;
+ }
+ }
+ }
+
Bundle args = getArguments();
boolean playAll = args.getBoolean(Constants.INTENT_EXTRA_NAME_AUTOPLAY, false);
if (playAll && !restoredInstance) {
diff --git a/src/github/daneren2005/dsub/provider/DSubSearchProvider.java b/src/github/daneren2005/dsub/provider/DSubSearchProvider.java
index 4fd4b218..6c23a5d0 100644
--- a/src/github/daneren2005/dsub/provider/DSubSearchProvider.java
+++ b/src/github/daneren2005/dsub/provider/DSubSearchProvider.java
@@ -83,7 +83,7 @@ public class DSubSearchProvider extends ContentProvider {
}
for (MusicDirectory.Entry song : searchResult.getSongs()) {
String icon = RESOURCE_PREFIX + R.drawable.ic_action_song;
- cursor.addRow(new Object[]{song.getId().hashCode(), song.getTitle(), song.getArtist(), song.getParent(), song.getTitle(), icon});
+ cursor.addRow(new Object[]{song.getId().hashCode(), song.getTitle(), song.getArtist(), "so-" + song.getParent(), song.getTitle(), icon});
}
return cursor;
}
diff --git a/src/github/daneren2005/dsub/util/Constants.java b/src/github/daneren2005/dsub/util/Constants.java
index ec686529..f566c78c 100644
--- a/src/github/daneren2005/dsub/util/Constants.java
+++ b/src/github/daneren2005/dsub/util/Constants.java
@@ -61,6 +61,7 @@ public final class Constants {
public static final String INTENT_EXTRA_NAME_SHARE = "subsonic.share";
public static final String INTENT_EXTRA_FRAGMENT_TYPE = "fragmentType";
public static final String INTENT_EXTRA_REFRESH_LISTINGS = "refreshListings";
+ public static final String INTENT_EXTRA_SEARCH_SONG = "searchSong";
// Preferences keys.
public static final String PREFERENCES_KEY_SERVER_KEY = "server";