aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/adapter/SectionAdapter.java14
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/DownloadFileItemHelperCallback.java5
2 files changed, 18 insertions, 1 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/adapter/SectionAdapter.java b/app/src/main/java/github/daneren2005/dsub/adapter/SectionAdapter.java
index 95bef065..d5f9a6ea 100644
--- a/app/src/main/java/github/daneren2005/dsub/adapter/SectionAdapter.java
+++ b/app/src/main/java/github/daneren2005/dsub/adapter/SectionAdapter.java
@@ -363,6 +363,20 @@ public abstract class SectionAdapter<T> extends RecyclerView.Adapter<UpdateViewH
}
}
+ public void moveItem(int from, int to) {
+ List<T> section = sections.get(0);
+ int max = section.size();
+ if(to >= max) {
+ to = max - 1;
+ } else if(to < 0) {
+ to = 0;
+ }
+
+ T moved = section.remove(from);
+ section.add(to, moved);
+
+ notifyItemMoved(from, to);
+ }
public void removeItem(T item) {
int subPosition = 0;
for(List<T> section: sections) {
diff --git a/app/src/main/java/github/daneren2005/dsub/util/DownloadFileItemHelperCallback.java b/app/src/main/java/github/daneren2005/dsub/util/DownloadFileItemHelperCallback.java
index 4074fece..e1e2dc63 100644
--- a/app/src/main/java/github/daneren2005/dsub/util/DownloadFileItemHelperCallback.java
+++ b/app/src/main/java/github/daneren2005/dsub/util/DownloadFileItemHelperCallback.java
@@ -2,6 +2,7 @@ package github.daneren2005.dsub.util;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.helper.ItemTouchHelper;
+import android.util.Log;
import org.eclipse.jetty.util.ArrayQueue;
@@ -15,6 +16,8 @@ import github.daneren2005.dsub.view.SongView;
import github.daneren2005.dsub.view.UpdateView;
public class DownloadFileItemHelperCallback extends ItemTouchHelper.SimpleCallback {
+ private static final String TAG = DownloadFileItemHelperCallback.class.getSimpleName();
+
private SubsonicFragment fragment;
private boolean mainList;
@@ -31,7 +34,7 @@ public class DownloadFileItemHelperCallback extends ItemTouchHelper.SimpleCallba
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder fromHolder, RecyclerView.ViewHolder toHolder) {
int from = fromHolder.getAdapterPosition();
int to = toHolder.getAdapterPosition();
- getSectionAdapter().notifyItemMoved(from, to);
+ getSectionAdapter().moveItem(from, to);
synchronized (pendingOperations) {
pendingOperations.add(new Pair<>(from, to));