aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/github/daneren2005/dsub/fragments/DownloadFragment.java
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2015-06-08 17:55:06 -0700
committerScott Jackson <daneren2005@gmail.com>2015-06-08 17:55:06 -0700
commitf47da3c25f2ee0d4f74392a0a7e4a570cc121516 (patch)
treeb6087d0230dacff6d46e38d79019c81c30cf157a /app/src/main/java/github/daneren2005/dsub/fragments/DownloadFragment.java
parent6f218cf51b27e24012335a27e806e3a24cc52c75 (diff)
downloaddsub-f47da3c25f2ee0d4f74392a0a7e4a570cc121516.tar.gz
dsub-f47da3c25f2ee0d4f74392a0a7e4a570cc121516.tar.bz2
dsub-f47da3c25f2ee0d4f74392a0a7e4a570cc121516.zip
#232 Switch NowPlayingFragment to RecyclerView, add swipe to remove and better drag + drop support
Diffstat (limited to 'app/src/main/java/github/daneren2005/dsub/fragments/DownloadFragment.java')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/DownloadFragment.java25
1 files changed, 13 insertions, 12 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/DownloadFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/DownloadFragment.java
index 59229c3f..5a3d63ad 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/DownloadFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/DownloadFragment.java
@@ -30,6 +30,7 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import github.daneren2005.dsub.R;
+import github.daneren2005.dsub.adapter.SectionAdapter;
import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.service.DownloadFile;
import github.daneren2005.dsub.service.DownloadService;
@@ -38,13 +39,15 @@ import github.daneren2005.dsub.util.ProgressListener;
import github.daneren2005.dsub.util.SilentBackgroundTask;
import github.daneren2005.dsub.util.Util;
import github.daneren2005.dsub.adapter.DownloadFileAdapter;
+import github.daneren2005.dsub.view.UpdateView;
-public class DownloadFragment extends SelectListFragment<DownloadFile> {
+public class DownloadFragment extends SelectRecyclerFragment<DownloadFile> {
private long currentRevision;
private ScheduledExecutorService executorService;
public DownloadFragment() {
serialize = false;
+ pullToRefresh = false;
}
@Override
@@ -80,7 +83,7 @@ public class DownloadFragment extends SelectListFragment<DownloadFile> {
}
@Override
- public ArrayAdapter getAdapter(List<DownloadFile> objs) {
+ public SectionAdapter getAdapter(List<DownloadFile> objs) {
return new DownloadFileAdapter(context, objs);
}
@@ -91,9 +94,6 @@ public class DownloadFragment extends SelectListFragment<DownloadFile> {
return new ArrayList<DownloadFile>();
}
- listView.setOnScrollListener(null);
- refreshLayout.setEnabled(false);
-
List<DownloadFile> songList = new ArrayList<DownloadFile>();
songList.addAll(downloadService.getBackgroundDownloads());
currentRevision = downloadService.getDownloadListUpdateRevision();
@@ -106,7 +106,7 @@ public class DownloadFragment extends SelectListFragment<DownloadFile> {
}
@Override
- public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+ public void onItemClicked(DownloadFile item) {
}
@@ -144,11 +144,13 @@ public class DownloadFragment extends SelectListFragment<DownloadFile> {
@Override
public void onCreateContextMenu(android.view.ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, view, menuInfo);
+ UpdateView targetView = adapter.getContextView();
+ menuInfo = new AdapterView.AdapterContextMenuInfo(targetView, 0, 0);
- AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
- Object selectedItem = ((DownloadFile) listView.getItemAtPosition(info.position)).getSong();
+ DownloadFile downloadFile = adapter.getContextItem();
+ MusicDirectory.Entry selectedItem = downloadFile.getSong();
onCreateContextMenu(menu, view, menuInfo, selectedItem);
- if(selectedItem instanceof MusicDirectory.Entry && !((MusicDirectory.Entry) selectedItem).isVideo() && !Util.isOffline(context)) {
+ if(!selectedItem.isVideo() && !Util.isOffline(context)) {
menu.removeItem(R.id.song_menu_remove_playlist);
}
@@ -161,9 +163,8 @@ public class DownloadFragment extends SelectListFragment<DownloadFile> {
return false;
}
- AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo();
- Object selectedItem = ((DownloadFile) listView.getItemAtPosition(info.position)).getSong();
-
+ DownloadFile downloadFile = adapter.getContextItem();
+ MusicDirectory.Entry selectedItem = downloadFile.getSong();
if(onContextItemSelected(menuItem, selectedItem)) {
return true;
}