aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/github/daneren2005/dsub/activity/SubsonicActivity.java1
-rw-r--r--src/github/daneren2005/dsub/fragments/AdminFragment.java5
-rw-r--r--src/github/daneren2005/dsub/service/CachedMusicService.java11
-rw-r--r--src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java3
-rw-r--r--src/github/daneren2005/dsub/service/RESTMusicService.java40
-rw-r--r--src/github/daneren2005/dsub/service/parser/UserParser.java4
6 files changed, 21 insertions, 43 deletions
diff --git a/src/github/daneren2005/dsub/activity/SubsonicActivity.java b/src/github/daneren2005/dsub/activity/SubsonicActivity.java
index b5a8568f..0c1a2c9a 100644
--- a/src/github/daneren2005/dsub/activity/SubsonicActivity.java
+++ b/src/github/daneren2005/dsub/activity/SubsonicActivity.java
@@ -457,6 +457,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
}
if(drawerList.getChildAt(lastSelectedPosition) == null) {
+ lastSelectedView = null;
drawerAdapter.setSelectedPosition(lastSelectedPosition);
} else {
lastSelectedView = (TextView) drawerList.getChildAt(lastSelectedPosition).findViewById(R.id.drawer_name);
diff --git a/src/github/daneren2005/dsub/fragments/AdminFragment.java b/src/github/daneren2005/dsub/fragments/AdminFragment.java
index 08a78fd6..021e80d1 100644
--- a/src/github/daneren2005/dsub/fragments/AdminFragment.java
+++ b/src/github/daneren2005/dsub/fragments/AdminFragment.java
@@ -126,7 +126,10 @@ public class AdminFragment extends SelectListFragment<User> {
file.delete();
List<User> users = new ArrayList<User>();
- users.add(musicService.getUser(refresh, UserUtil.getCurrentUsername(context), context, listener));
+ User user = musicService.getUser(refresh, UserUtil.getCurrentUsername(context), context, listener);
+ if(user != null) {
+ users.add(user);
+ }
UserUtil.refreshCurrentUser(context, false);
return users;
diff --git a/src/github/daneren2005/dsub/service/CachedMusicService.java b/src/github/daneren2005/dsub/service/CachedMusicService.java
index 4f722d5c..611e438e 100644
--- a/src/github/daneren2005/dsub/service/CachedMusicService.java
+++ b/src/github/daneren2005/dsub/service/CachedMusicService.java
@@ -131,7 +131,16 @@ public class CachedMusicService implements MusicService {
}
Indexes result = cachedIndexes.get();
if (result == null) {
- result = musicService.getIndexes(musicFolderId, refresh, context, progressListener);
+ String name = Util.isTagBrowsing(context, musicService.getInstance(context)) ? "artists" : "indexes";
+ name = getCacheName(context, name, musicFolderId);
+ if(!refresh) {
+ result = FileUtil.deserialize(context, name, Indexes.class);
+ }
+
+ if(result == null) {
+ result = musicService.getIndexes(musicFolderId, refresh, context, progressListener);
+ FileUtil.serialize(context, result, name);
+ }
cachedIndexes.set(result);
}
return result;
diff --git a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
index 04a2535c..40bb5871 100644
--- a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
+++ b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
@@ -163,8 +163,9 @@ public class DownloadServiceLifecycleSupport {
if(DownloadService.START_PLAY.equals(action)) {
if(intent.getBooleanExtra(Constants.INTENT_EXTRA_NAME_SHUFFLE, false)) {
downloadService.setShufflePlayEnabled(true);
+ } else {
+ downloadService.start();
}
- downloadService.play();
} else if(DownloadService.CANCEL_DOWNLOADS.equals(action)) {
downloadService.clearBackground();
} else if(intent.getExtras() != null) {
diff --git a/src/github/daneren2005/dsub/service/RESTMusicService.java b/src/github/daneren2005/dsub/service/RESTMusicService.java
index 295711e2..51a8a2a6 100644
--- a/src/github/daneren2005/dsub/service/RESTMusicService.java
+++ b/src/github/daneren2005/dsub/service/RESTMusicService.java
@@ -223,58 +223,22 @@ public class RESTMusicService implements MusicService {
@Override
public Indexes getIndexes(String musicFolderId, boolean refresh, Context context, ProgressListener progressListener) throws Exception {
- Indexes cachedIndexes = readCachedIndexes(context, musicFolderId);
- if (cachedIndexes != null && !refresh) {
- return cachedIndexes;
- }
-
- long lastModified = (cachedIndexes == null || refresh) ? 0L : cachedIndexes.getLastModified();
-
List<String> parameterNames = new ArrayList<String>();
List<Object> parameterValues = new ArrayList<Object>();
- if(lastModified != 0L) {
- parameterNames.add("ifModifiedSince");
- parameterValues.add(lastModified);
- }
-
- if (musicFolderId != null) {
+ if (musicFolderId != null) {
parameterNames.add("musicFolderId");
parameterValues.add(musicFolderId);
}
Reader reader = getReader(context, progressListener, Util.isTagBrowsing(context, getInstance(context)) ? "getArtists" : "getIndexes", null, parameterNames, parameterValues);
try {
- Indexes indexes = new IndexesParser(context, getInstance(context)).parse(reader, progressListener);
- if (indexes != null) {
- writeCachedIndexes(context, indexes, musicFolderId);
- return indexes;
- }
- if(cachedIndexes != null) {
- return cachedIndexes;
- } else {
- return new Indexes(0, new ArrayList<Artist>(), new ArrayList<Artist>());
- }
+ return new IndexesParser(context, getInstance(context)).parse(reader, progressListener);
} finally {
Util.close(reader);
}
}
- private Indexes readCachedIndexes(Context context, String musicFolderId) {
- String filename = getCachedIndexesFilename(context, musicFolderId);
- return FileUtil.deserialize(context, filename, Indexes.class);
- }
-
- private void writeCachedIndexes(Context context, Indexes indexes, String musicFolderId) {
- String filename = getCachedIndexesFilename(context, musicFolderId);
- FileUtil.serialize(context, indexes, filename);
- }
-
- private String getCachedIndexesFilename(Context context, String musicFolderId) {
- String s = getRestUrl(context, null) + musicFolderId;
- return (Util.isTagBrowsing(context, getInstance(context)) ? "artists-" : "indexes-") + Math.abs(s.hashCode()) + ".ser";
- }
-
@Override
public MusicDirectory getMusicDirectory(String id, String name, boolean refresh, Context context, ProgressListener progressListener) throws Exception {
SharedPreferences prefs = Util.getPreferences(context);
diff --git a/src/github/daneren2005/dsub/service/parser/UserParser.java b/src/github/daneren2005/dsub/service/parser/UserParser.java
index 931bc4a5..c8b56080 100644
--- a/src/github/daneren2005/dsub/service/parser/UserParser.java
+++ b/src/github/daneren2005/dsub/service/parser/UserParser.java
@@ -65,9 +65,9 @@ public class UserParser extends AbstractParser {
}
private void parseSetting(User user, String name) {
- Boolean value = getBoolean(name);
+ String value = get(name);
if(value != null) {
- user.addSetting(name, getBoolean(name));
+ user.addSetting(name, "true".equals(value));
}
}
}