aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android/src
diff options
context:
space:
mode:
Diffstat (limited to 'subsonic-android/src')
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java20
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java4
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java21
3 files changed, 43 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 f7736375..954a3f02 100644
--- a/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java
+++ b/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java
@@ -36,6 +36,7 @@ import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.os.Handler;
+import android.os.Parcelable;
import android.util.Log;
import android.view.ContextMenu;
import android.view.Display;
@@ -81,6 +82,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 +97,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;
@@ -146,7 +148,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);
@@ -345,6 +347,20 @@ 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();
+ }
+ });
+ playlistView.setRemoveListener(new DragSortListView.RemoveListener() {
+ @Override
+ public void remove(int which) {
+ getDownloadService().remove(which);
+ 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..889d7d2b 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java
@@ -60,6 +60,8 @@ public interface DownloadService {
void clearIncomplete();
int size();
+
+ void remove(int which);
void remove(DownloadFile downloadFile);
@@ -130,4 +132,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 c0275386..c874e8f5 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
@@ -420,6 +420,11 @@ public class DownloadServiceImpl extends Service implements DownloadService {
}
updateJukeboxPlaylist();
}
+
+ @Override
+ public synchronized void remove(int which) {
+ downloadList.remove(which);
+ }
@Override
public synchronized void remove(DownloadFile downloadFile) {
@@ -977,6 +982,22 @@ public class DownloadServiceImpl extends Service implements DownloadService {
mediaPlayer.setVolume(volume, volume);
}
}
+
+ @Override
+ public synchronized 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);