diff options
author | Scott Jackson <daneren2005@gmail.com> | 2013-06-09 22:04:26 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2013-06-09 22:04:26 -0700 |
commit | 3659a8bd2f40e4ba906fa73bfa7d75c29dc5990b (patch) | |
tree | e82196bca1c79dad1d4b2f0158670ceb61fa9868 /subsonic-android/src | |
parent | 41a0bdc592bd9d81efc958f59db57e0ce7498a5f (diff) | |
download | dsub-3659a8bd2f40e4ba906fa73bfa7d75c29dc5990b.tar.gz dsub-3659a8bd2f40e4ba906fa73bfa7d75c29dc5990b.tar.bz2 dsub-3659a8bd2f40e4ba906fa73bfa7d75c29dc5990b.zip |
Abstracted out version checking
Diffstat (limited to 'subsonic-android/src')
3 files changed, 16 insertions, 12 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicFragment.java index 44dc4325..77479424 100644 --- a/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicFragment.java +++ b/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicFragment.java @@ -387,11 +387,9 @@ public class SubsonicFragment extends SherlockFragment { final String oldStartYear = prefs.getString(Constants.PREFERENCES_KEY_SHUFFLE_START_YEAR, "");
final String oldEndYear = prefs.getString(Constants.PREFERENCES_KEY_SHUFFLE_END_YEAR, "");
final String oldGenre = prefs.getString(Constants.PREFERENCES_KEY_SHUFFLE_GENRE, "");
-
- Version version = Util.getServerRestVersion(context);
- Version genreVersion = new Version("1.9.0");
+
boolean _useCombo = false;
- if(version != null && version.compareTo(genreVersion) >= 0) {
+ if(Util.checkServerVersion(context, "1.9.0")) {
genreBox.setVisibility(View.GONE);
genreCombo.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
@@ -697,10 +695,8 @@ public class SubsonicFragment extends SherlockFragment { String playlistName = (getDownloadService() != null) ? getDownloadService().getSuggestedPlaylistName() : null;
if (playlistName != null) {
playlistNameView.setText(playlistName);
- Version version = Util.getServerRestVersion(context);
- Version updatePlaylistVersion = new Version("1.8.0");
try {
- if(version.compareTo(updatePlaylistVersion) >= 0 && Integer.parseInt(getDownloadService().getSuggestedPlaylistId()) != -1) {
+ if(Util.checkServerVersion(context, "1.8.0") && Integer.parseInt(getDownloadService().getSuggestedPlaylistId()) != -1) {
overwriteCheckBox.setChecked(true);
overwriteCheckBox.setVisibility(View.VISIBLE);
}
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/parser/MusicDirectoryParser.java b/subsonic-android/src/github/daneren2005/dsub/service/parser/MusicDirectoryParser.java index 038518c6..17b09805 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/parser/MusicDirectoryParser.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/parser/MusicDirectoryParser.java @@ -71,9 +71,7 @@ public class MusicDirectoryParser extends MusicDirectoryEntryParser { updateProgress(progressListener, R.string.parser_reading_done); // Only apply sorting on server version 4.7 and greater, where disc is supported - Version version = Util.getServerRestVersion(context); - Version discVersion = new Version("1.8.0"); - if(version.compareTo(discVersion) >= 0) { + if(Util.checkServerVersion(context, "1.8.0")) { dir.sortChildren(); } diff --git a/subsonic-android/src/github/daneren2005/dsub/util/Util.java b/subsonic-android/src/github/daneren2005/dsub/util/Util.java index bef836b5..650d071d 100644 --- a/subsonic-android/src/github/daneren2005/dsub/util/Util.java +++ b/subsonic-android/src/github/daneren2005/dsub/util/Util.java @@ -148,8 +148,8 @@ public final class Util { public static boolean isScrobblingEnabled(Context context) { if (isOffline(context)) { - return false; - } + return false; + } SharedPreferences prefs = getPreferences(context); return prefs.getBoolean(Constants.PREFERENCES_KEY_SCROBBLE, false); } @@ -167,6 +167,16 @@ public final class Util { return prefs.getInt(Constants.PREFERENCES_KEY_SERVER_INSTANCE, 1); } + public static boolean checkServerVersion(Context context, String requiredVersion) { + Version version = Util.getServerRestVersion(context); + Version required = new Version(requiredVersion); + if(version != null && version.compareTo(required) >= 0) { + return true; + } else { + return false; + } + } + public static int getServerCount(Context context) { SharedPreferences prefs = getPreferences(context); return prefs.getInt(Constants.PREFERENCES_KEY_SERVER_COUNT, 1); |