diff options
author | Scott Jackson <daneren2005@gmail.com> | 2013-02-22 07:39:25 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2013-02-22 07:39:25 -0800 |
commit | 543bfb2a1aee38b0ccb5dabbf3416e69cb0566d1 (patch) | |
tree | f33fb27cf5539ead2d675556d8b49bbe8cbaa4ad /subsonic-android/src | |
parent | 587de188035dc7312268055dc723aa418cf274e2 (diff) | |
download | dsub-543bfb2a1aee38b0ccb5dabbf3416e69cb0566d1.tar.gz dsub-543bfb2a1aee38b0ccb5dabbf3416e69cb0566d1.tar.bz2 dsub-543bfb2a1aee38b0ccb5dabbf3416e69cb0566d1.zip |
Don't go back to the top when removing a song from a playlist
Diffstat (limited to 'subsonic-android/src')
-rw-r--r-- | subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java | 11 | ||||
-rw-r--r-- | subsonic-android/src/github/daneren2005/dsub/view/EntryAdapter.java | 13 |
2 files changed, 15 insertions, 9 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java index 392401bf..926467ec 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java @@ -53,6 +53,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity { private Button moreButton; private Boolean licenseValid; private boolean showHeader = true; + private EntryAdapter entryAdapter; /** * Called when the activity is first created. @@ -695,7 +696,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity { } emptyView.setVisibility(entries.isEmpty() ? View.VISIBLE : View.GONE); - entryList.setAdapter(new EntryAdapter(SelectAlbumActivity.this, getImageLoader(), entries, true)); + entryList.setAdapter(entryAdapter = new EntryAdapter(SelectAlbumActivity.this, getImageLoader(), entries, true)); licenseValid = result.getSecond(); invalidateOptionsMenu(); @@ -753,12 +754,16 @@ public class SelectAlbumActivity extends SubsonicTabActivity { @Override protected void done(Void result) { - refresh(); + for(int i = indexes.size() - 1; i >= 0; i--) { + entryList.setItemChecked(indexes.get(i) + 1, false); + entryAdapter.removeAt(indexes.get(i)); + } + entryAdapter.notifyDataSetChanged(); Util.toast(SelectAlbumActivity.this, getResources().getString(R.string.removed_playlist, indexes.size(), name)); } @Override - protected void error(Throwable error) { + protected void error(Throwable error) { String msg; if (error instanceof OfflineException || error instanceof ServerTooOldException) { msg = getErrorMessage(error); diff --git a/subsonic-android/src/github/daneren2005/dsub/view/EntryAdapter.java b/subsonic-android/src/github/daneren2005/dsub/view/EntryAdapter.java index 6d2c7a63..476d3478 100644 --- a/subsonic-android/src/github/daneren2005/dsub/view/EntryAdapter.java +++ b/subsonic-android/src/github/daneren2005/dsub/view/EntryAdapter.java @@ -37,13 +37,19 @@ public class EntryAdapter extends ArrayAdapter<MusicDirectory.Entry> { private final SubsonicTabActivity activity; private final ImageLoader imageLoader; private final boolean checkable; + private List<MusicDirectory.Entry> entries; public EntryAdapter(SubsonicTabActivity activity, ImageLoader imageLoader, List<MusicDirectory.Entry> entries, boolean checkable) { super(activity, android.R.layout.simple_list_item_1, entries); + this.entries = entries; this.activity = activity; this.imageLoader = imageLoader; this.checkable = checkable; } + + public void removeAt(int position) { + entries.remove(position); + } @Override public View getView(int position, View convertView, ViewGroup parent) { @@ -51,12 +57,7 @@ public class EntryAdapter extends ArrayAdapter<MusicDirectory.Entry> { if (entry.isDirectory()) { AlbumView view; - // TODO: Reuse AlbumView objects once cover art loading is working. -// if (convertView != null && convertView instanceof AlbumView) { -// view = (AlbumView) convertView; -// } else { - view = new AlbumView(activity); -// } + view = new AlbumView(activity); view.setAlbum(entry, imageLoader); return view; |