diff options
author | Scott Jackson <daneren2005@gmail.com> | 2015-11-17 17:22:56 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2015-11-17 17:22:56 -0800 |
commit | 128f979438b3d2151123392ddc0e524d34feaf1f (patch) | |
tree | 30df64cf5254bcbbb351e86c94a3129fb43262b6 /app/src/main/java/github/daneren2005/dsub/adapter | |
parent | 25a67f1f8d186fabd339c711ceef6ad8a0c3d5d5 (diff) | |
download | dsub-128f979438b3d2151123392ddc0e524d34feaf1f.tar.gz dsub-128f979438b3d2151123392ddc0e524d34feaf1f.tar.bz2 dsub-128f979438b3d2151123392ddc0e524d34feaf1f.zip |
Fix swapping position of download files not sticking until refresh due to not moving in local list immediately
Diffstat (limited to 'app/src/main/java/github/daneren2005/dsub/adapter')
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/adapter/SectionAdapter.java | 14 |
1 files changed, 14 insertions, 0 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) { |