aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-08-20 22:48:34 -0700
committerScott Jackson <daneren2005@gmail.com>2014-08-20 22:48:34 -0700
commit5a639da5d71f6dbe8a5609f103c6d19ff621f7a0 (patch)
tree6bdfae017ae21b765e11acf5a40382dcad251d77
parente15815adf11aa5ffc2243b008c4fe372e54e42ff (diff)
downloaddsub-5a639da5d71f6dbe8a5609f103c6d19ff621f7a0.tar.gz
dsub-5a639da5d71f6dbe8a5609f103c6d19ff621f7a0.tar.bz2
dsub-5a639da5d71f6dbe8a5609f103c6d19ff621f7a0.zip
Fixes to more of the bookmark playing
-rw-r--r--res/menu/select_bookmark_context.xml8
-rw-r--r--src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java42
-rw-r--r--src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java1
-rw-r--r--src/github/daneren2005/dsub/fragments/SubsonicFragment.java94
-rw-r--r--src/github/daneren2005/dsub/service/DownloadService.java4
5 files changed, 100 insertions, 49 deletions
diff --git a/res/menu/select_bookmark_context.xml b/res/menu/select_bookmark_context.xml
index 7e3117f8..2b1b83fd 100644
--- a/res/menu/select_bookmark_context.xml
+++ b/res/menu/select_bookmark_context.xml
@@ -5,10 +5,14 @@
<item
android:id="@+id/bookmark_menu_info"
android:title="@string/common.info"/>
+
+ <item
+ android:id="@+id/song_menu_show_album"
+ android:title="@string/download.menu_show_album"/>
<item
- android:id="@+id/album_menu_show_artist"
- android:title="menu.show_artist"/>
+ android:id="@+id/song_menu_show_artist"
+ android:title="@string/menu.show_artist"/>
<item
android:id="@+id/song_menu_download"
diff --git a/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java b/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java
index dfaf2d4d..0e22efe4 100644
--- a/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java
@@ -63,10 +63,10 @@ public class SelectBookmarkFragment extends SelectListFragment<MusicDirectory.En
switch(menuItem.getItemId()) {
case R.id.bookmark_menu_info:
displayBookmarkInfo(bookmark);
- break;
+ return true;
case R.id.bookmark_menu_delete:
- deleteBookmark(bookmark);
- break;
+ deleteBookmark(bookmark, adapter);
+ return true;
}
if(onContextItemSelected(menuItem, bookmark)) {
@@ -107,7 +107,7 @@ public class SelectBookmarkFragment extends SelectListFragment<MusicDirectory.En
new SilentBackgroundTask<Void>(context) {
@Override
protected Void doInBackground() throws Throwable {
- downloadService.download(Arrays.asList(bookmark), false, true, false, false, bookmark.getBookmark().getPosition());
+ downloadService.download(Arrays.asList(bookmark), false, true, false, false, 0, bookmark.getBookmark().getPosition());
return null;
}
@@ -132,38 +132,4 @@ public class SelectBookmarkFragment extends SelectListFragment<MusicDirectory.En
Util.info(context, R.string.bookmark_details_title, msg, false);
}
- private void deleteBookmark(final MusicDirectory.Entry entry) {
- Util.confirmDialog(context, R.string.bookmark_delete_title, entry.getTitle(), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- new LoadingTask<Void>(context, false) {
- @Override
- protected Void doInBackground() throws Throwable {
- MusicService musicService = MusicServiceFactory.getMusicService(context);
- musicService.deleteBookmark(entry.getId(), Util.getParentFromEntry(context, entry), context, null);
- return null;
- }
-
- @Override
- protected void done(Void result) {
- adapter.remove(entry);
- adapter.notifyDataSetChanged();
- Util.toast(context, context.getResources().getString(R.string.bookmark_deleted, entry.getTitle()));
- }
-
- @Override
- protected void error(Throwable error) {
- String msg;
- if (error instanceof OfflineException || error instanceof ServerTooOldException) {
- msg = getErrorMessage(error);
- } else {
- msg = context.getResources().getString(R.string.bookmark_deleted_error, entry.getTitle()) + " " + getErrorMessage(error);
- }
-
- Util.toast(context, msg, false);
- }
- }.execute();
- }
- });
- }
}
diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
index fbd87ec7..50b03d1e 100644
--- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
@@ -849,6 +849,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
if(!append && !save && autoplay && !playNext && !shuffle) {
// Call playNow which goes through and tries to use bookmark information
playNow(songs);
+ return;
}
LoadingTask<Void> onValid = new LoadingTask<Void>(context) {
diff --git a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
index be4a76eb..216f526c 100644
--- a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
@@ -39,6 +39,7 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AbsListView;
+import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
@@ -324,7 +325,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
displaySongInfo(entry);
break;
case R.id.album_menu_show_artist:
- showArtist((Entry) selectedItem);
+ showAlbumArtist((Entry) selectedItem);
break;
case R.id.album_menu_share:
createShare(songs);
@@ -365,6 +366,15 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
case R.id.song_menu_share:
createShare(songs);
break;
+ case R.id.song_menu_show_album:
+ showAlbum((Entry) selectedItem);
+ break;
+ case R.id.song_menu_show_artist:
+ showArtist((Entry) selectedItem);
+ break;
+ case R.id.bookmark_menu_delete:
+ deleteBookmark(entry, null);
+ break;
default:
return false;
}
@@ -1242,7 +1252,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
}
}
- public void showArtist(Entry entry) {
+ public void showAlbumArtist(Entry entry) {
SubsonicFragment fragment = new SelectDirectoryFragment();
Bundle args = new Bundle();
if(Util.isTagBrowsing(context)) {
@@ -1256,6 +1266,37 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
replaceFragment(fragment, true);
}
+ public void showArtist(Entry entry) {
+ SubsonicFragment fragment = new SelectDirectoryFragment();
+ Bundle args = new Bundle();
+ if(Util.isTagBrowsing(context)) {
+ args.putString(Constants.INTENT_EXTRA_NAME_ID, entry.getArtistId());
+ } else {
+ if(entry.getGrandParent() == null) {
+ args.putString(Constants.INTENT_EXTRA_NAME_CHILD_ID, entry.getParent());
+ } else {
+ args.putString(Constants.INTENT_EXTRA_NAME_ID, entry.getGrandParent());
+ }
+ }
+ args.putString(Constants.INTENT_EXTRA_NAME_NAME, entry.getArtist());
+ args.putBoolean(Constants.INTENT_EXTRA_NAME_ARTIST, true);
+ fragment.setArguments(args);
+
+ replaceFragment(fragment, true);
+ }
+ public void showAlbum(Entry entry) {
+ SubsonicFragment fragment = new SelectDirectoryFragment();
+ Bundle args = new Bundle();
+ if(Util.isTagBrowsing(context)) {
+ args.putString(Constants.INTENT_EXTRA_NAME_ID, entry.getAlbumId());
+ } else {
+ args.putString(Constants.INTENT_EXTRA_NAME_ID, entry.getParent());
+ }
+ args.putString(Constants.INTENT_EXTRA_NAME_NAME, entry.getAlbum());
+ fragment.setArguments(args);
+
+ replaceFragment(fragment, true);
+ }
public void createShare(final List<Entry> entries) {
new LoadingTask<List<Share>>(context, true) {
@@ -1313,7 +1354,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
.setPositiveButton(R.string.bookmark_action_resume, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
- playNow(entries, song, position);
+ playNow(songs, song, position);
}
})
.setNegativeButton(R.string.bookmark_action_start_over, new DialogInterface.OnClickListener() {
@@ -1342,7 +1383,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
}
}.execute();
- playNow(entries, 0);
+ playNow(songs, 0);
}
});
AlertDialog dialog = builder.create();
@@ -1367,16 +1408,55 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
}
}
protected void playNow(List<Entry> entries, int position) {
- playNow(entries, 0, position);
+ playNow(entries, entries.get(0), position);
}
protected void playNow(List<Entry> entries, Entry song, int position) {
DownloadService downloadService = getDownloadService();
- if(downloadService() == null) {
+ if(downloadService == null) {
return;
}
downloadService.clear();
- downloadService.download(songs, false, true, true, false, entries.indexOf(song), position);
+ downloadService.download(entries, false, true, true, false, entries.indexOf(song), position);
Util.startActivityWithoutTransition(context, DownloadActivity.class);
}
+
+ protected void deleteBookmark(final MusicDirectory.Entry entry, final ArrayAdapter adapter) {
+ Util.confirmDialog(context, R.string.bookmark_delete_title, entry.getTitle(), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ new LoadingTask<Void>(context, false) {
+ @Override
+ protected Void doInBackground() throws Throwable {
+ MusicService musicService = MusicServiceFactory.getMusicService(context);
+ musicService.deleteBookmark(entry.getId(), Util.getParentFromEntry(context, entry), context, null);
+
+ entry.setBookmark(null);
+ return null;
+ }
+
+ @Override
+ protected void done(Void result) {
+ if(adapter != null) {
+ adapter.remove(entry);
+ adapter.notifyDataSetChanged();
+ }
+ Util.toast(context, context.getResources().getString(R.string.bookmark_deleted, entry.getTitle()));
+ }
+
+ @Override
+ protected void error(Throwable error) {
+ String msg;
+ if (error instanceof OfflineException || error instanceof ServerTooOldException) {
+ msg = getErrorMessage(error);
+ } else {
+ msg = context.getResources().getString(R.string.bookmark_deleted_error, entry.getTitle()) + " " + getErrorMessage(error);
+ }
+
+ Util.toast(context, msg, false);
+ }
+ }.execute();
+ }
+ });
+ }
}
diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java
index a813e724..15777c8e 100644
--- a/src/github/daneren2005/dsub/service/DownloadService.java
+++ b/src/github/daneren2005/dsub/service/DownloadService.java
@@ -297,7 +297,7 @@ public class DownloadService extends Service {
public synchronized void download(List<MusicDirectory.Entry> songs, boolean save, boolean autoplay, boolean playNext, boolean shuffle) {
download(songs, save, autoplay, playNext, shuffle, 0, 0);
}
- public synchronized void download(List<MusicDirectory.Entry> songs, boolean save, boolean autoplay, boolean playNext, boolean shuffle, int index, int position) {
+ public synchronized void download(List<MusicDirectory.Entry> songs, boolean save, boolean autoplay, boolean playNext, boolean shuffle, int start, int position) {
setShufflePlayEnabled(false);
int offset = 1;
@@ -336,7 +336,7 @@ public class DownloadService extends Service {
}
if (autoplay) {
- play(index, true, position);
+ play(start, true, position);
} else {
if (currentPlaying == null) {
currentPlaying = downloadList.get(0);