From 7c29438f0ab44d1d7bad478334635758b93b0d3c Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Mon, 14 Apr 2014 18:24:35 -0700 Subject: #310 Add option to have play now play everything after that spot --- .../dsub/fragments/SelectDirectoryFragment.java | 16 ++++++++++++++++ src/github/daneren2005/dsub/util/Constants.java | 1 + 2 files changed, 17 insertions(+) (limited to 'src') diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java index edfff31e..c8937ea7 100644 --- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java @@ -20,11 +20,13 @@ import android.widget.ListView; import android.widget.TextView; import github.daneren2005.dsub.R; import github.daneren2005.dsub.domain.MusicDirectory; +import github.daneren2005.dsub.domain.MusicFolder; import github.daneren2005.dsub.domain.Share; import github.daneren2005.dsub.util.ImageLoader; import github.daneren2005.dsub.view.EntryAdapter; import java.io.Serializable; +import java.util.Iterator; import java.util.List; import com.mobeta.android.dslv.*; import github.daneren2005.dsub.activity.DownloadActivity; @@ -297,6 +299,20 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo(); Object selectedItem = entries.get(showHeader ? (info.position - 1) : info.position); + + if(Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_PLAY_NOW_AFTER, false) && menuItem.getItemId() == R.id.song_menu_play_now) { + List songs = new ArrayList(); + Iterator it = entries.listIterator(info.position - 1); + while(it.hasNext()) { + songs.add((MusicDirectory.Entry) it.next()); + } + + getDownloadService().clear(); + getDownloadService().download(songs, false, true, true, false); + Util.startActivityWithoutTransition(context, DownloadActivity.class); + + return true; + } if(onContextItemSelected(menuItem, selectedItem)) { return true; diff --git a/src/github/daneren2005/dsub/util/Constants.java b/src/github/daneren2005/dsub/util/Constants.java index 0eef1c94..874579a5 100644 --- a/src/github/daneren2005/dsub/util/Constants.java +++ b/src/github/daneren2005/dsub/util/Constants.java @@ -138,6 +138,7 @@ public final class Constants { public static final String PREFERENCES_KEY_BROWSE_TAGS = "browseTags"; public static final String PREFERENCES_KEY_OPEN_TO_LIBRARY = "openToLibrary"; public static final String PREFERENCES_KEY_OVERRIDE_SYSTEM_LANGUAGE = "overrideSystemLanguage"; + public static final String PREFERENCES_KEY_PLAY_NOW_AFTER = "playNowAfter"; public static final String OFFLINE_SCROBBLE_COUNT = "scrobbleCount"; public static final String OFFLINE_SCROBBLE_ID = "scrobbleID"; -- cgit v1.2.3