diff options
Diffstat (limited to 'src')
8 files changed, 30 insertions, 30 deletions
diff --git a/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java b/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java index 5ea432e5..20d52423 100644 --- a/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java @@ -43,7 +43,7 @@ import java.text.Format; import java.text.SimpleDateFormat; import java.util.List; -public class SelectBookmarkFragment extends SelectListFragment<Bookmark> { +public class SelectBookmarkFragment extends SelectListFragment<MusicDirectory.Entry> { private static final String TAG = SelectBookmarkFragment.class.getSimpleName(); @Override @@ -57,7 +57,7 @@ public class SelectBookmarkFragment extends SelectListFragment<Bookmark> { @Override public boolean onContextItemSelected(MenuItem menuItem) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo(); - Bookmark bookmark = objects.get(info.position); + MusicDirectory.Entry bookmark = objects.get(info.position); switch(menuItem.getItemId()) { case R.id.bookmark_menu_info: @@ -68,7 +68,7 @@ public class SelectBookmarkFragment extends SelectListFragment<Bookmark> { break; } - if(onContextItemSelected(menuItem, bookmark.getEntry())) { + if(onContextItemSelected(menuItem, bookmark)) { return true; } @@ -81,13 +81,13 @@ public class SelectBookmarkFragment extends SelectListFragment<Bookmark> { } @Override - public ArrayAdapter getAdapter(List<Bookmark> bookmarks) { + public ArrayAdapter getAdapter(List<MusicDirectory.Entry> bookmarks) { return new BookmarkAdapter(context, bookmarks); } @Override - public List<Bookmark> getObjects(MusicService musicService, boolean refresh, ProgressListener listener) throws Exception { - return musicService.getBookmarks(refresh, context, listener); + public List<MusicDirectory.Entry> getObjects(MusicService musicService, boolean refresh, ProgressListener listener) throws Exception { + return musicService.getBookmarks(refresh, context, listener).getChildren(); } @Override @@ -102,7 +102,7 @@ public class SelectBookmarkFragment extends SelectListFragment<Bookmark> { return; } - final Bookmark bookmark = (Bookmark) parent.getItemAtPosition(position); + final MusicDirectory.Entry bookmark = (MusicDirectory.Entry) parent.getItemAtPosition(position); new SilentBackgroundTask<Void>(context) { @Override protected Void doInBackground() throws Throwable { @@ -117,7 +117,8 @@ public class SelectBookmarkFragment extends SelectListFragment<Bookmark> { }.execute(); } - private void displayBookmarkInfo(final Bookmark bookmark) { + private void displayBookmarkInfo(final MusicDirectory.Entry entry) { + Bookmark bookmark = entry.getBookmark(); Format formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String comment = bookmark.getComment(); if(comment == null) { @@ -125,13 +126,12 @@ public class SelectBookmarkFragment extends SelectListFragment<Bookmark> { } String msg = context.getResources().getString(R.string.bookmark_details, - bookmark.getEntry().getTitle(), Util.formatDuration(bookmark.getPosition() / 1000), + entry.getTitle(), Util.formatDuration(bookmark.getPosition() / 1000), formatter.format(bookmark.getCreated()), formatter.format(bookmark.getChanged()), comment); Util.info(context, R.string.bookmark_details_title, msg, false); } - private void deleteBookmark(final Bookmark bookmark) { - final MusicDirectory.Entry entry = bookmark.getEntry(); + private void deleteBookmark(final MusicDirectory.Entry entry) { Util.confirmDialog(context, R.string.bookmark_delete_title, entry.getTitle(), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { @@ -145,7 +145,7 @@ public class SelectBookmarkFragment extends SelectListFragment<Bookmark> { @Override protected void done(Void result) { - adapter.remove(bookmark); + adapter.remove(entry); adapter.notifyDataSetChanged(); Util.toast(context, context.getResources().getString(R.string.bookmark_deleted, entry.getTitle())); } diff --git a/src/github/daneren2005/dsub/service/CachedMusicService.java b/src/github/daneren2005/dsub/service/CachedMusicService.java index e97ffe24..e753151e 100644 --- a/src/github/daneren2005/dsub/service/CachedMusicService.java +++ b/src/github/daneren2005/dsub/service/CachedMusicService.java @@ -32,7 +32,6 @@ import android.graphics.Bitmap; import android.util.Log; import github.daneren2005.dsub.domain.Artist; -import github.daneren2005.dsub.domain.Bookmark; import github.daneren2005.dsub.domain.ChatMessage; import github.daneren2005.dsub.domain.Genre; import github.daneren2005.dsub.domain.Indexes; @@ -769,7 +768,7 @@ public class CachedMusicService implements MusicService { } @Override - public List<Bookmark> getBookmarks(boolean refresh, Context context, ProgressListener progressListener) throws Exception { + public MusicDirectory getBookmarks(boolean refresh, Context context, ProgressListener progressListener) throws Exception { return musicService.getBookmarks(refresh, context, progressListener); } diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java index b311df6b..4b8f9018 100644 --- a/src/github/daneren2005/dsub/service/DownloadService.java +++ b/src/github/daneren2005/dsub/service/DownloadService.java @@ -294,9 +294,11 @@ public class DownloadService extends Service { return binder; } - public synchronized void download(Bookmark bookmark) { + public synchronized void download(MusicDirectory.Entry entry) { + Bookmark bookmark = entry.getBookmark(); + clear(); - DownloadFile downloadFile = new DownloadFile(this, bookmark.getEntry(), false); + DownloadFile downloadFile = new DownloadFile(this, entry, false); downloadList.add(downloadFile); revision++; updateJukeboxPlaylist(); diff --git a/src/github/daneren2005/dsub/service/MusicService.java b/src/github/daneren2005/dsub/service/MusicService.java index f0751230..58df8904 100644 --- a/src/github/daneren2005/dsub/service/MusicService.java +++ b/src/github/daneren2005/dsub/service/MusicService.java @@ -154,7 +154,7 @@ public interface MusicService { void setRating(String id, int rating, Context context, ProgressListener progressListener) throws Exception; - List<Bookmark> getBookmarks(boolean refresh, Context context, ProgressListener progressListener) throws Exception; + MusicDirectory getBookmarks(boolean refresh, Context context, ProgressListener progressListener) throws Exception; void createBookmark(String id, int position, String comment, Context context, ProgressListener progressListener) throws Exception; diff --git a/src/github/daneren2005/dsub/service/OfflineMusicService.java b/src/github/daneren2005/dsub/service/OfflineMusicService.java index 329bf5cd..82d3de10 100644 --- a/src/github/daneren2005/dsub/service/OfflineMusicService.java +++ b/src/github/daneren2005/dsub/service/OfflineMusicService.java @@ -37,7 +37,6 @@ import android.util.Log; import org.apache.http.HttpResponse; import github.daneren2005.dsub.domain.Artist; -import github.daneren2005.dsub.domain.Bookmark; import github.daneren2005.dsub.domain.ChatMessage; import github.daneren2005.dsub.domain.Genre; import github.daneren2005.dsub.domain.Indexes; @@ -743,7 +742,7 @@ public class OfflineMusicService implements MusicService { } @Override - public List<Bookmark> getBookmarks(boolean refresh, Context context, ProgressListener progressListener) throws Exception { + public MusicDirectory getBookmarks(boolean refresh, Context context, ProgressListener progressListener) throws Exception { throw new OfflineException(ERRORMSG); } diff --git a/src/github/daneren2005/dsub/service/RESTMusicService.java b/src/github/daneren2005/dsub/service/RESTMusicService.java index 52d0f877..13d1555c 100644 --- a/src/github/daneren2005/dsub/service/RESTMusicService.java +++ b/src/github/daneren2005/dsub/service/RESTMusicService.java @@ -1115,7 +1115,7 @@ public class RESTMusicService implements MusicService { } @Override - public List<Bookmark> getBookmarks(boolean refresh, Context context, ProgressListener progressListener) throws Exception { + public MusicDirectory getBookmarks(boolean refresh, Context context, ProgressListener progressListener) throws Exception { checkServerVersion(context, "1.9", "Bookmarks not supported."); Reader reader = getReader(context, progressListener, "getBookmarks", null); diff --git a/src/github/daneren2005/dsub/service/parser/BookmarkParser.java b/src/github/daneren2005/dsub/service/parser/BookmarkParser.java index 68dc3898..2677d845 100644 --- a/src/github/daneren2005/dsub/service/parser/BookmarkParser.java +++ b/src/github/daneren2005/dsub/service/parser/BookmarkParser.java @@ -36,10 +36,10 @@ public class BookmarkParser extends MusicDirectoryEntryParser { super(context, instance); } - public List<Bookmark> parse(Reader reader, ProgressListener progressListener) throws Exception { + public MusicDirectory parse(Reader reader, ProgressListener progressListener) throws Exception { init(reader); - List<Bookmark> bookmarks = new ArrayList<Bookmark>(); + List<MusicDirectory.Entry> bookmarks = new ArrayList<MusicDirectory.Entry>(); Bookmark bookmark = null; int eventType; @@ -58,9 +58,8 @@ public class BookmarkParser extends MusicDirectoryEntryParser { bookmark.setUsername(get("username")); } else if ("entry".equals(name)) { MusicDirectory.Entry entry = parseEntry(null); - entry.setTrack(null); - bookmark.setEntry(entry); - bookmarks.add(bookmark); + entry.setBookmark(bookmark); + bookmarks.add(entry); } else if ("error".equals(name)) { handleError(); } @@ -69,6 +68,6 @@ public class BookmarkParser extends MusicDirectoryEntryParser { validate(); - return bookmarks; + return new MusicDirectory(bookmarks); } } diff --git a/src/github/daneren2005/dsub/view/BookmarkAdapter.java b/src/github/daneren2005/dsub/view/BookmarkAdapter.java index b0541397..ea585744 100644 --- a/src/github/daneren2005/dsub/view/BookmarkAdapter.java +++ b/src/github/daneren2005/dsub/view/BookmarkAdapter.java @@ -32,18 +32,19 @@ import github.daneren2005.dsub.domain.Bookmark; import github.daneren2005.dsub.domain.MusicDirectory; import github.daneren2005.dsub.util.Util; -public class BookmarkAdapter extends ArrayAdapter<Bookmark> { +public class BookmarkAdapter extends ArrayAdapter<MusicDirectory.Entry> { private final static String TAG = BookmarkAdapter.class.getSimpleName(); private Context activity; - public BookmarkAdapter(Context activity, List<Bookmark> bookmarks) { + public BookmarkAdapter(Context activity, List<MusicDirectory.Entry> bookmarks) { super(activity, android.R.layout.simple_list_item_1, bookmarks); this.activity = activity; } public View getView(int position, View convertView, ViewGroup parent) { - Bookmark bookmark = getItem(position); - MusicDirectory.Entry entry = bookmark.getEntry(); + MusicDirectory.Entry entry = getItem(position); + Bookmark bookmark = entry.getBookmark(); + SongView view; if (convertView != null) { view = (SongView) convertView; |