aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-02-24 08:30:17 -0800
committerScott Jackson <daneren2005@gmail.com>2013-02-24 08:30:17 -0800
commit7f490872cdbf8301892fe9d06a9b164c18764409 (patch)
tree7ae4e282c415faa54bd968df781eef2037e93b54 /subsonic-android
parentd6edc0fdb45c29a31b3c93dfaf2d08ef77548c59 (diff)
downloaddsub-7f490872cdbf8301892fe9d06a9b164c18764409.tar.gz
dsub-7f490872cdbf8301892fe9d06a9b164c18764409.tar.bz2
dsub-7f490872cdbf8301892fe9d06a9b164c18764409.zip
Drag and Drop in viewing a album/playlist
Diffstat (limited to 'subsonic-android')
-rw-r--r--subsonic-android/res/layout/select_album.xml15
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java22
2 files changed, 27 insertions, 10 deletions
diff --git a/subsonic-android/res/layout/select_album.xml b/subsonic-android/res/layout/select_album.xml
index a5802246..b688a95b 100644
--- a/subsonic-android/res/layout/select_album.xml
+++ b/subsonic-android/res/layout/select_album.xml
@@ -19,13 +19,14 @@
android:layout_height="wrap_content"
android:padding="10dip"/>
- <ListView android:id="@+id/select_album_entries"
- android:textFilterEnabled="true"
- android:layout_width="fill_parent"
- android:layout_height="0dip"
- android:layout_weight="1.0"
- android:fastScrollEnabled="true"
- />
+ <com.mobeta.android.dslv.DragSortListView
+ style="@style/DragDropListView"
+ android:id="@+id/select_album_entries"
+ android:textFilterEnabled="true"
+ android:layout_width="fill_parent"
+ android:layout_height="0dip"
+ android:layout_weight="1.0"
+ android:fastScrollEnabled="true"/>
<include layout="@layout/button_bar"/>
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java
index 926467ec..46a32ed4 100644
--- a/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java
+++ b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java
@@ -38,6 +38,7 @@ import github.daneren2005.dsub.R;
import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.service.*;
import github.daneren2005.dsub.util.*;
+import com.mobeta.android.dslv.*;
import java.io.File;
import java.util.*;
@@ -46,7 +47,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
private static final String TAG = SelectAlbumActivity.class.getSimpleName();
- private ListView entryList;
+ private DragSortListView entryList;
private View footer;
private View emptyView;
private boolean hideButtons = false;
@@ -54,6 +55,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
private Boolean licenseValid;
private boolean showHeader = true;
private EntryAdapter entryAdapter;
+ private List<MusicDirectory.Entry> entries;
/**
* Called when the activity is first created.
@@ -63,7 +65,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.select_album);
- entryList = (ListView) findViewById(R.id.select_album_entries);
+ entryList = (DragSortListView) findViewById(R.id.select_album_entries);
footer = LayoutInflater.from(this).inflate(R.layout.select_album_footer, entryList, false);
entryList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
@@ -87,6 +89,20 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
}
}
});
+ entryList.setDropListener(new DragSortListView.DropListener() {
+ @Override
+ public void drop(int from, int to) {
+ int max = entries.size();
+ if(to >= max) {
+ to = max - 1;
+ }
+ else if(to < 0) {
+ to = 0;
+ }
+ entries.add(to, entries.remove(from));
+ entryAdapter.notifyDataSetChanged();
+ }
+ });
moreButton = (Button) footer.findViewById(R.id.select_album_more);
emptyView = findViewById(R.id.select_album_empty);
@@ -678,7 +694,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
@Override
protected void done(Pair<MusicDirectory, Boolean> result) {
- List<MusicDirectory.Entry> entries = result.getFirst().getChildren();
+ entries = result.getFirst().getChildren();
int songCount = 0;
for (MusicDirectory.Entry entry : entries) {