diff options
author | daneren2005 <daneren2005@gmail.com> | 2013-11-12 16:25:22 -0800 |
---|---|---|
committer | daneren2005 <daneren2005@gmail.com> | 2013-11-12 16:25:22 -0800 |
commit | 65a3d4a4dcfe870990ad146aca860e99b94f0624 (patch) | |
tree | abf0368383a484ea699ff2142185b7a32394945f /src | |
parent | 83c3c7931ac2a6f6feb00a07858d4062fe35ea3a (diff) | |
download | dsub-65a3d4a4dcfe870990ad146aca860e99b94f0624.tar.gz dsub-65a3d4a4dcfe870990ad146aca860e99b94f0624.tar.bz2 dsub-65a3d4a4dcfe870990ad146aca860e99b94f0624.zip |
Prompt user for comment when creating a bookmark
Diffstat (limited to 'src')
-rw-r--r-- | src/github/daneren2005/dsub/fragments/DownloadFragment.java | 68 |
1 files changed, 49 insertions, 19 deletions
diff --git a/src/github/daneren2005/dsub/fragments/DownloadFragment.java b/src/github/daneren2005/dsub/fragments/DownloadFragment.java index 232eda85..c4597e78 100644 --- a/src/github/daneren2005/dsub/fragments/DownloadFragment.java +++ b/src/github/daneren2005/dsub/fragments/DownloadFragment.java @@ -385,25 +385,7 @@ public class DownloadFragment extends SubsonicFragment implements OnGestureListe bookmarkButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
- new SilentBackgroundTask<Void>(context) {
- @Override
- protected Void doInBackground() throws Throwable {
- DownloadFile currentDownload = getDownloadService().getCurrentPlaying();
- if (currentDownload != null) {
- MusicDirectory.Entry currentSong = currentDownload.getSong();
- MusicService musicService = MusicServiceFactory.getMusicService(context);
- musicService.createBookmark(currentSong.getId(), getDownloadService().getPlayerPosition(), "", context, null);
- }
-
- return null;
- }
-
- @Override
- protected void done(Void result) {
- Util.toast(context, R.string.download_save_bookmark);
- setControlsVisible(true);
- }
- }.execute();
+ createBookmark();
}
});
@@ -1163,6 +1145,54 @@ public class DownloadFragment extends SubsonicFragment implements OnGestureListe }
}.execute();
}
+
+ private void createBookmark() {
+ DownloadService downloadService = getDownloadService();
+ if(downloadService == null) {
+ return;
+ }
+
+ DownloadFile currentDownload = downloadService.getCurrentPlaying();
+ if(currentDownload == null) {
+ return;
+ }
+
+ View dialogView = context.getLayoutInflater().inflate(R.layout.create_bookmark, null);
+ final EditText commentBox = (EditText)dialogView.findViewById(R.id.comment_text);
+
+ AlertDialog.Builder builder = new AlertDialog.Builder(context);
+ builder.setTitle(R.string.download_save_bookmark_title)
+ .setView(dialogView)
+ .setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int id) {
+ String comment = commentBox.getText().toString();
+
+ createBookmark(currentDownload, comment);
+ }
+ })
+ .setNegativeButton(R.string.common_cancel, null);
+ AlertDialog dialog = builder.create();
+ dialog.show();
+ }
+ private void createBookmark(DownloadFile currentDownload, String comment) {
+ new SilentBackgroundTask<Void>(context) {
+ @Override
+ protected Void doInBackground() throws Throwable {
+ MusicDirectory.Entry currentSong = currentDownload.getSong();
+ MusicService musicService = MusicServiceFactory.getMusicService(context);
+ musicService.createBookmark(currentSong.getId(), getDownloadService().getPlayerPosition(), comment, context, null);
+
+ return null;
+ }
+
+ @Override
+ protected void done(Void result) {
+ Util.toast(context, R.string.download_save_bookmark);
+ setControlsVisible(true);
+ }
+ }.execute();
+ }
private class SongListAdapter extends ArrayAdapter<DownloadFile> {
public SongListAdapter(List<DownloadFile> entries) {
|