aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java2
-rw-r--r--src/github/daneren2005/dsub/service/DownloadService.java2
-rw-r--r--src/github/daneren2005/dsub/service/RESTMusicService.java30
-rw-r--r--src/github/daneren2005/dsub/util/FileUtil.java25
-rw-r--r--src/github/daneren2005/dsub/view/HeaderGridView.java4
5 files changed, 46 insertions, 17 deletions
diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
index b8a1006b..515a6cd4 100644
--- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
@@ -730,7 +730,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
// Needs to be added here, GB crashes if you to try to remove the header view before adapter is set
if(addAlbumHeader && entryAdapter == null) {
- if(entries.size() > 0) {
+ if(entries.size() > 0 || playlistId != null || podcastId != null) {
entryList.addHeaderView(albumList);
} else {
ViewGroup rootGroup = (ViewGroup) rootView.findViewById(R.id.select_album_layout);
diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java
index 5ab58bf6..24c710dd 100644
--- a/src/github/daneren2005/dsub/service/DownloadService.java
+++ b/src/github/daneren2005/dsub/service/DownloadService.java
@@ -233,9 +233,9 @@ public class DownloadService extends Service {
mediaRouter = new MediaRouteManager(this);
instance = this;
- lifecycleSupport.onCreate();
shufflePlayBuffer = new ShufflePlayBuffer(this);
artistRadioBuffer = new ArtistRadioBuffer(this);
+ lifecycleSupport.onCreate();
}
@Override
diff --git a/src/github/daneren2005/dsub/service/RESTMusicService.java b/src/github/daneren2005/dsub/service/RESTMusicService.java
index 715d07da..341b1158 100644
--- a/src/github/daneren2005/dsub/service/RESTMusicService.java
+++ b/src/github/daneren2005/dsub/service/RESTMusicService.java
@@ -594,9 +594,22 @@ public class RESTMusicService implements MusicService {
@Override
public MusicDirectory getStarredList(Context context, ProgressListener progressListener) throws Exception {
- Reader reader = getReader(context, progressListener, Util.isTagBrowsing(context, getInstance(context)) ? "getStarred2" : "getStarred", null);
+ List<String> names = new ArrayList<String>();
+ List<Object> values = new ArrayList<Object>();
+
+ // Add folder if it was set and is non null
+ int instance = getInstance(context);
+ if(Util.getAlbumListsPerFolder(context, instance)) {
+ String folderId = Util.getSelectedMusicFolderId(context, instance);
+ if(folderId != null) {
+ names.add("musicFolderId");
+ values.add(folderId);
+ }
+ }
+
+ Reader reader = getReader(context, progressListener, Util.isTagBrowsing(context, instance) ? "getStarred2" : "getStarred", null, names, values);
try {
- return new StarredListParser(context, getInstance(context)).parse(reader, progressListener);
+ return new StarredListParser(context, instance).parse(reader, progressListener);
} finally {
Util.close(reader);
}
@@ -1103,10 +1116,19 @@ public class RESTMusicService implements MusicService {
parameterNames.add("offset");
parameterValues.add(offset);
- Reader reader = getReader(context, progressListener, "getSongsByGenre", params, parameterNames, parameterValues);
+ // Add folder if it was set and is non null
+ int instance = getInstance(context);
+ if(Util.getAlbumListsPerFolder(context, instance)) {
+ String folderId = Util.getSelectedMusicFolderId(context, instance);
+ if(folderId != null) {
+ parameterNames.add("musicFolderId");
+ parameterValues.add(folderId);
+ }
+ }
+ Reader reader = getReader(context, progressListener, "getSongsByGenre", params, parameterNames, parameterValues);
try {
- return new RandomSongsParser(context, getInstance(context)).parse(reader, progressListener);
+ return new RandomSongsParser(context, instance).parse(reader, progressListener);
} finally {
Util.close(reader);
}
diff --git a/src/github/daneren2005/dsub/util/FileUtil.java b/src/github/daneren2005/dsub/util/FileUtil.java
index fbfa6af0..8bd53c0c 100644
--- a/src/github/daneren2005/dsub/util/FileUtil.java
+++ b/src/github/daneren2005/dsub/util/FileUtil.java
@@ -501,17 +501,24 @@ public class FileUtil {
}
public static void deleteEmptyDir(File dir) {
- File[] children = dir.listFiles();
+ try {
+ File[] children = dir.listFiles();
+ if(children == null) {
+ return;
+ }
- // No songs left in the folder
- if(children.length == 1 && children[0].getPath().equals(FileUtil.getAlbumArtFile(dir).getPath())) {
- Util.delete(children[0]);
- children = dir.listFiles();
- }
+ // No songs left in the folder
+ if (children.length == 1 && children[0].getPath().equals(FileUtil.getAlbumArtFile(dir).getPath())) {
+ Util.delete(children[0]);
+ children = dir.listFiles();
+ }
- // Delete empty directory
- if (children.length == 0) {
- Util.delete(dir);
+ // Delete empty directory
+ if (children.length == 0) {
+ Util.delete(dir);
+ }
+ } catch(Exception e) {
+ Log.w(TAG, "Error while trying to delete empty dir", e);
}
}
diff --git a/src/github/daneren2005/dsub/view/HeaderGridView.java b/src/github/daneren2005/dsub/view/HeaderGridView.java
index 51d08ebf..c8e51764 100644
--- a/src/github/daneren2005/dsub/view/HeaderGridView.java
+++ b/src/github/daneren2005/dsub/view/HeaderGridView.java
@@ -36,7 +36,7 @@ import java.util.ArrayList;
* See {@link HeaderGridView#addFooterView(View, Object, boolean)}
*/
public class HeaderGridView extends GridView {
-
+ private static final String TAG = HeaderGridView.class.getSimpleName();
public static boolean DEBUG = false;
/**
@@ -316,7 +316,7 @@ public class HeaderGridView extends GridView {
int numColumns = getNumColumnsCompatible();
// adapter has not been set or has no views in it;
- if (adapter == null || adapter.getCount() <= numColumns * (mHeaderViewInfos.size() + mFooterViewInfos.size())) {
+ if (adapter == null || adapter.getCount() <= numColumns * (mHeaderViewInfos.size() + mFooterViewInfos.size()) || numColumns == -1) {
return -1;
}
int mColumnWidth = getColumnWidthCompatible();