diff options
author | Scott Jackson <daneren2005@gmail.com> | 2013-02-17 16:20:41 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2013-02-17 16:20:41 -0800 |
commit | fa9e77b8e90fa684e0374c8ac3237baadd38f7b6 (patch) | |
tree | 59c2590a3a4ff905c700aba6873afe32a1e4ecb9 /subsonic-android/src | |
parent | e4ce03c6f1c3fb5ec48fcefbf814d83a1d5090f4 (diff) | |
download | dsub-fa9e77b8e90fa684e0374c8ac3237baadd38f7b6.tar.gz dsub-fa9e77b8e90fa684e0374c8ac3237baadd38f7b6.tar.bz2 dsub-fa9e77b8e90fa684e0374c8ac3237baadd38f7b6.zip |
Added drag drop functionality to now playing tab
Diffstat (limited to 'subsonic-android/src')
3 files changed, 28 insertions, 2 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java index a4222ce5..e4578db1 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java @@ -81,6 +81,7 @@ import github.daneren2005.dsub.util.*; import github.daneren2005.dsub.view.AutoRepeatButton; import java.util.ArrayList; import java.util.concurrent.ScheduledFuture; +import com.mobeta.android.dslv.*; public class DownloadActivity extends SubsonicTabActivity implements OnGestureListener { private static final String TAG = DownloadActivity.class.getSimpleName(); @@ -95,7 +96,7 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi private TextView emptyTextView; private TextView songTitleTextView; private ImageView albumArtImageView; - private ListView playlistView; + private DragSortListView playlistView; private TextView positionTextView; private TextView durationTextView; private TextView statusTextView; @@ -145,7 +146,7 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi durationTextView = (TextView) findViewById(R.id.download_duration); statusTextView = (TextView) findViewById(R.id.download_status); progressBar = (HorizontalSlider) findViewById(R.id.download_progress_bar); - playlistView = (ListView) findViewById(R.id.download_list); + playlistView = (DragSortListView) findViewById(R.id.download_list); previousButton = (AutoRepeatButton)findViewById(R.id.download_previous); nextButton = (AutoRepeatButton)findViewById(R.id.download_next); pauseButton = findViewById(R.id.download_pause); @@ -344,6 +345,13 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi } } }); + playlistView.setDropListener(new DragSortListView.DropListener() { + @Override + public void drop(int from, int to) { + getDownloadService().swap(from, to); + onDownloadListChanged(); + } + }); registerForContextMenu(playlistView); diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java index 0536c198..c086c258 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java @@ -130,4 +130,6 @@ public interface DownloadService { boolean getSleepTimer(); void setVolume(float volume); + + void swap(int from, int to); } diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java index 9e6662cf..349252e0 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java @@ -981,6 +981,22 @@ public class DownloadServiceImpl extends Service implements DownloadService { mediaPlayer.setVolume(volume, volume); } } + + @Override + public void swap(int from, int to) { + int max = size(); + if(to >= max) { + to = max - 1; + } + else if(to < 0) { + to = 0; + } + + downloadList.add(to, downloadList.remove(from)); + if(jukeboxEnabled) { + updateJukeboxPlaylist(); + } + } private void handleError(Exception x) { Log.w(TAG, "Media player error: " + x, x); |