diff options
author | Scott Jackson <daneren2005@gmail.com> | 2013-09-25 20:20:23 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2013-09-25 20:20:23 -0700 |
commit | d39fb705ae4d403585c901bc4bd0c0a6ef3c1a37 (patch) | |
tree | 2f1a627ee8b32fbbee3b23f6b3bd8ded63ac46b2 /src/github/daneren2005 | |
parent | b77e275ac82edc1477c45eb12c50e8a3d381339f (diff) | |
download | dsub-d39fb705ae4d403585c901bc4bd0c0a6ef3c1a37.tar.gz dsub-d39fb705ae4d403585c901bc4bd0c0a6ef3c1a37.tar.bz2 dsub-d39fb705ae4d403585c901bc4bd0c0a6ef3c1a37.zip |
Closes #149 Add root folder for songs stored at root
Diffstat (limited to 'src/github/daneren2005')
4 files changed, 43 insertions, 6 deletions
diff --git a/src/github/daneren2005/dsub/domain/Indexes.java b/src/github/daneren2005/dsub/domain/Indexes.java index 671821a5..67eb33bc 100644 --- a/src/github/daneren2005/dsub/domain/Indexes.java +++ b/src/github/daneren2005/dsub/domain/Indexes.java @@ -18,6 +18,7 @@ */ package github.daneren2005.dsub.domain; +import java.util.ArrayList; import java.util.List; import java.io.Serializable; @@ -29,6 +30,7 @@ public class Indexes implements Serializable { private long lastModified; private List<Artist> shortcuts; private List<Artist> artists; + private List<MusicDirectory.Entry> entries; public Indexes() { @@ -37,7 +39,21 @@ public class Indexes implements Serializable { this.lastModified = lastModified; this.shortcuts = shortcuts; this.artists = artists; + this.entries = new ArrayList<MusicDirectory.Entry>(); } + public Indexes(long lastModified, List<Artist> shortcuts, List<Artist> artists, List<MusicDirectory.Entry> entries) { + this.lastModified = lastModified; + this.shortcuts = shortcuts; + this.artists = artists; + this.entries = entries; + if(!entries.isEmpty()) { + Artist root = new Artist(); + root.setId("root"); + root.setName("Root"); + root.setIndex("#"); + artists.add(root); + } + } public long getLastModified() { return lastModified; @@ -50,4 +66,8 @@ public class Indexes implements Serializable { public List<Artist> getArtists() { return artists; } + + public List<MusicDirectory.Entry> getEntries() { + return entries; + } }
\ No newline at end of file diff --git a/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java b/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java index b11f6fe7..e382163d 100644 --- a/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java @@ -17,6 +17,7 @@ import android.widget.TextView; import github.daneren2005.dsub.R;
import github.daneren2005.dsub.domain.Artist;
import github.daneren2005.dsub.domain.Indexes;
+import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.domain.MusicFolder;
import github.daneren2005.dsub.service.MusicService;
import github.daneren2005.dsub.service.MusicServiceFactory;
@@ -40,6 +41,7 @@ public class SelectArtistFragment extends SubsonicFragment implements AdapterVie private View folderButton;
private TextView folderName;
private List<MusicFolder> musicFolders = null;
+ private List<MusicDirectory.Entry> entries;
private List<Artist> artists;
@Override
@@ -162,6 +164,10 @@ public class SelectArtistFragment extends SubsonicFragment implements AdapterVie Bundle args = new Bundle();
args.putString(Constants.INTENT_EXTRA_NAME_ID, artist.getId());
args.putString(Constants.INTENT_EXTRA_NAME_NAME, artist.getName());
+ if("root".equals(artist.getId())) {
+ Log.d(TAG, "root");
+ args.putSerializable(Constants.FRAGMENT_LIST, (Serializable) entries);
+ }
fragment.setArguments(args);
replaceFragment(fragment, R.id.select_artist_layout);
@@ -200,6 +206,7 @@ public class SelectArtistFragment extends SubsonicFragment implements AdapterVie artists.addAll(result.getShortcuts());
artists.addAll(result.getArtists());
artistList.setAdapter(new ArtistAdapter(context, artists));
+ entries = result.getEntries();
setMusicFolders();
artistList.setVisibility(View.VISIBLE);
diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java index 2d095c6e..fbf47899 100644 --- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java @@ -130,6 +130,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter albumListType = args.getString(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_TYPE);
albumListExtra = args.getString(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_EXTRA);
albumListSize = args.getInt(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_SIZE, 0);
+ entries = (List<MusicDirectory.Entry>) args.getSerializable(Constants.FRAGMENT_LIST);
}
if(entries == null) {
@@ -322,7 +323,9 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter @Override
protected void refresh(boolean refresh) {
- load(refresh);
+ if(!"root".equals(id)) {
+ load(refresh);
+ }
}
@Override
@@ -444,7 +447,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter }
}
- if (songCount > 0) {
+ if (songCount > 0 && !"root".equals(id)) {
if(showHeader) {
View header = createHeader(entries);
if(header != null) {
@@ -453,7 +456,9 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter }
} else {
showHeader = false;
- hideButtons = true;
+ if(!"root".equals(id)) {
+ hideButtons = true;
+ }
}
emptyView.setVisibility(entries.isEmpty() ? View.VISIBLE : View.GONE);
diff --git a/src/github/daneren2005/dsub/service/parser/IndexesParser.java b/src/github/daneren2005/dsub/service/parser/IndexesParser.java index 6196411d..bf5bd8b1 100644 --- a/src/github/daneren2005/dsub/service/parser/IndexesParser.java +++ b/src/github/daneren2005/dsub/service/parser/IndexesParser.java @@ -29,6 +29,7 @@ import android.content.SharedPreferences; import github.daneren2005.dsub.R; import github.daneren2005.dsub.domain.Artist; import github.daneren2005.dsub.domain.Indexes; +import github.daneren2005.dsub.domain.MusicDirectory; import github.daneren2005.dsub.util.ProgressListener; import android.util.Log; import github.daneren2005.dsub.util.Constants; @@ -37,7 +38,7 @@ import github.daneren2005.dsub.util.Util; /** * @author Sindre Mehus */ -public class IndexesParser extends AbstractParser { +public class IndexesParser extends MusicDirectoryEntryParser { private static final String TAG = IndexesParser.class.getSimpleName(); private Context context; @@ -55,6 +56,7 @@ public class IndexesParser extends AbstractParser { List<Artist> artists = new ArrayList<Artist>(); List<Artist> shortcuts = new ArrayList<Artist>(); + List<MusicDirectory.Entry> entries = new ArrayList<MusicDirectory.Entry>(); Long lastModified = null; int eventType; String index = "#"; @@ -91,7 +93,10 @@ public class IndexesParser extends AbstractParser { shortcut.setIndex("*"); shortcut.setStarred(get("starred") != null); shortcuts.add(shortcut); - } else if ("error".equals(name)) { + } else if("child".equals(name)) { + MusicDirectory.Entry entry = parseEntry(""); + entries.add(entry); + } else if ("error".equals(name)) { handleError(); } } @@ -115,6 +120,6 @@ public class IndexesParser extends AbstractParser { String msg = getContext().getResources().getString(R.string.parser_artist_count, artists.size()); updateProgress(progressListener, msg); - return new Indexes(lastModified == null ? 0L : lastModified, shortcuts, artists); + return new Indexes(lastModified == null ? 0L : lastModified, shortcuts, artists, entries); } }
\ No newline at end of file |