aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-08-31 10:48:17 -0700
committerScott Jackson <daneren2005@gmail.com>2014-08-31 10:48:17 -0700
commit330e7edcb3611bf6b737cf89a6196b8ea4903927 (patch)
tree728d9d863c2b45961ce1039d29c5a06444cc1138 /src
parent26efb16082d610d653f391980d271131f64df124 (diff)
downloaddsub-330e7edcb3611bf6b737cf89a6196b8ea4903927.tar.gz
dsub-330e7edcb3611bf6b737cf89a6196b8ea4903927.tar.bz2
dsub-330e7edcb3611bf6b737cf89a6196b8ea4903927.zip
Add toggle logic for when trying to remove rating
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/fragments/NowPlayingFragment.java50
-rw-r--r--src/github/daneren2005/dsub/fragments/SubsonicFragment.java2
2 files changed, 39 insertions, 13 deletions
diff --git a/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java b/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java
index c087df5a..5dc550f7 100644
--- a/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java
+++ b/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java
@@ -375,14 +375,27 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
@Override
public void onClick(View view) {
Entry entry = getDownloadService().getCurrentPlaying().getSong();
- setRating(entry, 1);
- rateBadButton.setImageResource(R.drawable.ic_action_rating_bad_selected);
- // Make sure good rating is blank
- if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
- rateGoodButton.setImageResource(R.drawable.ic_action_rating_good_dark);
+ // If rating == 1, already set so unset
+ if(entry.getRating() == 1) {
+ setRating(entry, 0);
+
+ if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
+ rateBadButton.setImageResource(R.drawable.ic_action_rating_bad_dark);
+ } else {
+ rateBadButton.setImageResource(Util.getAttribute(context, R.attr.rating_bad));
+ }
} else {
- rateGoodButton.setImageResource(Util.getAttribute(context, R.attr.rating_good));
+ // Otherwise set rating to 1
+ setRating(entry, 1);
+ rateBadButton.setImageResource(R.drawable.ic_action_rating_bad_selected);
+
+ // Make sure good rating is blank
+ if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
+ rateGoodButton.setImageResource(R.drawable.ic_action_rating_good_dark);
+ } else {
+ rateGoodButton.setImageResource(Util.getAttribute(context, R.attr.rating_good));
+ }
}
}
});
@@ -390,14 +403,27 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
@Override
public void onClick(View view) {
Entry entry = getDownloadService().getCurrentPlaying().getSong();
- setRating(entry, 5);
- rateGoodButton.setImageResource(R.drawable.ic_action_rating_good_selected);
- // Make sure bad rating is blank
- if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
- rateBadButton.setImageResource(R.drawable.ic_action_rating_bad_dark);
+ // If rating == 5, already set so unset
+ if(entry.getRating() == 5) {
+ setRating(entry, 0);
+
+ if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
+ rateGoodButton.setImageResource(R.drawable.ic_action_rating_good_dark);
+ } else {
+ rateGoodButton.setImageResource(Util.getAttribute(context, R.attr.rating_good));
+ }
} else {
- rateBadButton.setImageResource(Util.getAttribute(context, R.attr.rating_bad));
+ // Otherwise set rating to maximum
+ setRating(entry, 5);
+ rateGoodButton.setImageResource(R.drawable.ic_action_rating_good_selected);
+
+ // Make sure bad rating is blank
+ if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
+ rateBadButton.setImageResource(R.drawable.ic_action_rating_bad_dark);
+ } else {
+ rateBadButton.setImageResource(Util.getAttribute(context, R.attr.rating_bad));
+ }
}
}
});
diff --git a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
index b6c67642..1cf58bfe 100644
--- a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
@@ -1508,7 +1508,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR
@Override
protected void done(Void result) {
- Util.toast(context, getResources().getString(R.string.rating_set_rating, entry.getTitle()));
+ Util.toast(context, getResources().getString(rating > 0 ? R.string.rating_set_rating : R.string.rating_remove_rating, entry.getTitle()));
}
@Override