From 65a3d4a4dcfe870990ad146aca860e99b94f0624 Mon Sep 17 00:00:00 2001 From: daneren2005 Date: Tue, 12 Nov 2013 16:25:22 -0800 Subject: Prompt user for comment when creating a bookmark --- .../dsub/fragments/DownloadFragment.java | 68 ++++++++++++++++------ 1 file changed, 49 insertions(+), 19 deletions(-) (limited to 'src') 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(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(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 { public SongListAdapter(List entries) { -- cgit v1.2.3