diff options
author | Scott Jackson <daneren2005@gmail.com> | 2014-09-05 14:39:23 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2014-09-05 14:39:23 -0700 |
commit | 085b9af697e6584291bd943de18bb82838b8630b (patch) | |
tree | 55b15a1265b159d3644ba447700915087ea37de8 /src | |
parent | c9ed6303711f9799e61eb4455bbbbf21405d91d4 (diff) | |
download | dsub-085b9af697e6584291bd943de18bb82838b8630b.tar.gz dsub-085b9af697e6584291bd943de18bb82838b8630b.tar.bz2 dsub-085b9af697e6584291bd943de18bb82838b8630b.zip |
Update rating/bookmarks immediately, revert later if error
Diffstat (limited to 'src')
-rw-r--r-- | src/github/daneren2005/dsub/fragments/SubsonicFragment.java | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java index fcef44fb..62484761 100644 --- a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java +++ b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java @@ -1403,18 +1403,22 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR .setNegativeButton(R.string.bookmark_action_start_over, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
+ final Bookmark oldBookmark = song.getBookmark();
+ song.setBookmark(null);
+
new SilentBackgroundTask<Void>(context) {
@Override
protected Void doInBackground() throws Throwable {
MusicService musicService = MusicServiceFactory.getMusicService(context);
musicService.deleteBookmark(song, context, null);
- song.setBookmark(null);
return null;
}
@Override
protected void error(Throwable error) {
+ song.setBookmark(oldBookmark);
+
String msg;
if (error instanceof OfflineException || error instanceof ServerTooOldException) {
msg = getErrorMessage(error);
@@ -1480,11 +1484,13 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR Util.confirmDialog(context, R.string.bookmark_delete_title, entry.getTitle(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
+ final Bookmark oldBookmark = entry.getBookmark();
+ entry.setBookmark(null);
+
new LoadingTask<Void>(context, false) {
@Override
protected Void doInBackground() throws Throwable {
MusicService musicService = MusicServiceFactory.getMusicService(context);
- entry.setBookmark(null);
musicService.deleteBookmark(entry, context, null);
return null;
@@ -1501,6 +1507,8 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR @Override
protected void error(Throwable error) {
+ entry.setBookmark(oldBookmark);
+
String msg;
if (error instanceof OfflineException || error instanceof ServerTooOldException) {
msg = getErrorMessage(error);
@@ -1537,14 +1545,15 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR }
protected void setRating(final Entry entry, final int rating) {
+ final int oldRating = entry.getRating();
+ entry.setRating(rating);
+
new SilentBackgroundTask<Void>(context) {
@Override
protected Void doInBackground() throws Throwable {
MusicService musicService = MusicServiceFactory.getMusicService(context);
musicService.setRating(entry, rating, context, null);
- entry.setRating(rating);
-
Entry findEntry = UpdateView.findEntry(entry);
if(findEntry != null) {
findEntry.setRating(rating);
@@ -1559,6 +1568,8 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR @Override
protected void error(Throwable error) {
+ entry.setRating(oldRating);
+
String msg;
if (error instanceof OfflineException || error instanceof ServerTooOldException) {
msg = getErrorMessage(error);
|