aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-09-01 09:14:28 -0700
committerScott Jackson <daneren2005@gmail.com>2014-09-01 09:14:28 -0700
commit1a68637693e5a1483c64d8f55d10522ab7e169b3 (patch)
tree045e7b92c9b1d85f79cc9a5327d464fa77f3ec34
parent9481c877f3bcc35c21129466c0e5f3fa75a67899 (diff)
downloaddsub-1a68637693e5a1483c64d8f55d10522ab7e169b3.tar.gz
dsub-1a68637693e5a1483c64d8f55d10522ab7e169b3.tar.bz2
dsub-1a68637693e5a1483c64d8f55d10522ab7e169b3.zip
Fix scrobbling defaulting to false when no preference
-rw-r--r--src/github/daneren2005/dsub/util/UserUtil.java10
-rw-r--r--src/github/daneren2005/dsub/util/Util.java2
2 files changed, 9 insertions, 3 deletions
diff --git a/src/github/daneren2005/dsub/util/UserUtil.java b/src/github/daneren2005/dsub/util/UserUtil.java
index 5821a9dc..19e8b918 100644
--- a/src/github/daneren2005/dsub/util/UserUtil.java
+++ b/src/github/daneren2005/dsub/util/UserUtil.java
@@ -133,10 +133,16 @@ public final class UserUtil {
public static boolean canJukebox() {
return isCurrentRole(User.JUKEBOX);
}
+ public static boolean canScrobble() {
+ return isCurrentRole(User.SCROBBLING, true);
+ }
public static boolean isCurrentRole(String role) {
+ return isCurrentRole(role, false);
+ }
+ public static boolean isCurrentRole(String role, boolean defaultValue) {
if(currentUser == null) {
- return false;
+ return defaultValue;
}
for(User.Setting setting: currentUser.getSettings()) {
@@ -145,7 +151,7 @@ public final class UserUtil {
}
}
- return false;
+ return defaultValue;
}
public static void confirmCredentials(final Activity context, final Runnable onSuccess) {
diff --git a/src/github/daneren2005/dsub/util/Util.java b/src/github/daneren2005/dsub/util/Util.java
index c1d026d4..2e4872c8 100644
--- a/src/github/daneren2005/dsub/util/Util.java
+++ b/src/github/daneren2005/dsub/util/Util.java
@@ -157,7 +157,7 @@ public final class Util {
public static boolean isScrobblingEnabled(Context context) {
SharedPreferences prefs = getPreferences(context);
- return prefs.getBoolean(Constants.PREFERENCES_KEY_SCROBBLE, true) && (isOffline(context) || UserUtil.isCurrentRole(User.SCROBBLING));
+ return prefs.getBoolean(Constants.PREFERENCES_KEY_SCROBBLE, true) && (isOffline(context) || UserUtil.canScrobble());
}
public static void setActiveServer(Context context, int instance) {