aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2012-12-26 18:27:59 -0800
committerScott Jackson <daneren2005@gmail.com>2012-12-26 18:27:59 -0800
commit06d1f1bab1e91ad992ebb67860586dc916157acd (patch)
treeebc7c6be7d59dd001738eea3dec1cf30f8741040
parentccab5b04036cff6e6b9cae5d70a45b0abfcd0dc2 (diff)
parent5f7df3f6300c0d0f0d7573c5614f7b84e081754a (diff)
downloaddsub-06d1f1bab1e91ad992ebb67860586dc916157acd.tar.gz
dsub-06d1f1bab1e91ad992ebb67860586dc916157acd.tar.bz2
dsub-06d1f1bab1e91ad992ebb67860586dc916157acd.zip
Merge branch 'master' of https://github.com/daneren2005/Subsonic.git
-rw-r--r--subsonic-android/res/xml/settings.xml2
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java2
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/activity/SubsonicTabActivity.java4
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/view/ArtistAdapter.java44
4 files changed, 49 insertions, 3 deletions
diff --git a/subsonic-android/res/xml/settings.xml b/subsonic-android/res/xml/settings.xml
index 07d7a64f..ebb19e03 100644
--- a/subsonic-android/res/xml/settings.xml
+++ b/subsonic-android/res/xml/settings.xml
@@ -170,7 +170,7 @@
<EditTextPreference
android:title="@string/settings.cache_size"
android:key="cacheSize"
- android:defaultValue="500"
+ android:defaultValue="2000"
android:digits="0123456789"/>
<EditTextPreference
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java
index 9ca1744f..0cf380dd 100644
--- a/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java
+++ b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java
@@ -284,7 +284,9 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
toggleStarred(entry);
break;
case R.id.song_menu_play_now:
+ getDownloadService().clear();
getDownloadService().download(songs, false, true, true, false);
+ Util.startActivityWithoutTransition(SelectAlbumActivity.this, DownloadActivity.class);
break;
case R.id.song_menu_play_next:
getDownloadService().download(songs, false, false, true, false);
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicTabActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicTabActivity.java
index 19e01045..705c460d 100644
--- a/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicTabActivity.java
+++ b/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicTabActivity.java
@@ -361,7 +361,9 @@ public class SubsonicTabActivity extends SherlockActivity {
warnIfNetworkOrStorageUnavailable();
if(!background) {
downloadService.download(songs, save, autoplay, false, shuffle);
- Util.startActivityWithoutTransition(SubsonicTabActivity.this, DownloadActivity.class);
+ if(!append) {
+ Util.startActivityWithoutTransition(SubsonicTabActivity.this, DownloadActivity.class);
+ }
}
else {
downloadService.downloadBackground(songs, save);
diff --git a/subsonic-android/src/github/daneren2005/dsub/view/ArtistAdapter.java b/subsonic-android/src/github/daneren2005/dsub/view/ArtistAdapter.java
index 12956a14..0edb03c5 100644
--- a/subsonic-android/src/github/daneren2005/dsub/view/ArtistAdapter.java
+++ b/subsonic-android/src/github/daneren2005/dsub/view/ArtistAdapter.java
@@ -23,19 +23,40 @@ import java.util.List;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
+import android.widget.SectionIndexer;
import github.daneren2005.dsub.activity.SubsonicTabActivity;
import github.daneren2005.dsub.domain.Artist;
+import java.util.ArrayList;
+import java.util.LinkedHashSet;
+import java.util.Set;
/**
* @author Sindre Mehus
*/
-public class ArtistAdapter extends ArrayAdapter<Artist> {
+public class ArtistAdapter extends ArrayAdapter<Artist> implements SectionIndexer {
private final SubsonicTabActivity activity;
+
+ // Both arrays are indexed by section ID.
+ private final Object[] sections;
+ private final Integer[] positions;
public ArtistAdapter(SubsonicTabActivity activity, List<Artist> artists) {
super(activity, R.layout.artist_list_item, artists);
this.activity = activity;
+
+ Set<String> sectionSet = new LinkedHashSet<String>(30);
+ List<Integer> positionList = new ArrayList<Integer>(30);
+ for (int i = 0; i < artists.size(); i++) {
+ Artist artist = artists.get(i);
+ String index = artist.getIndex();
+ if (!sectionSet.contains(index)) {
+ sectionSet.add(index);
+ positionList.add(i);
+ }
+ }
+ sections = sectionSet.toArray(new Object[sectionSet.size()]);
+ positions = positionList.toArray(new Integer[positionList.size()]);
}
@Override
@@ -50,4 +71,25 @@ public class ArtistAdapter extends ArrayAdapter<Artist> {
view.setArtist(entry);
return view;
}
+
+ @Override
+ public Object[] getSections() {
+ return sections;
+ }
+
+ @Override
+ public int getPositionForSection(int section) {
+ section = Math.min(section, positions.length - 1);
+ return positions[section];
+ }
+
+ @Override
+ public int getSectionForPosition(int pos) {
+ for (int i = 0; i < sections.length - 1; i++) {
+ if (pos < positions[i + 1]) {
+ return i;
+ }
+ }
+ return sections.length - 1;
+ }
}