aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaneren2005 <daneren2005@gmail.com>2013-11-19 16:41:17 -0800
committerdaneren2005 <daneren2005@gmail.com>2013-11-19 16:41:17 -0800
commit16640a1f9196a2e934753f08d00a99a284ca3178 (patch)
treeb45f602a2fc6c8ace0f0cafc9e9206105855433d
parent9576f4e74f69f9a2a74adf5a51fcb36651cb7ba4 (diff)
downloaddsub-16640a1f9196a2e934753f08d00a99a284ca3178.tar.gz
dsub-16640a1f9196a2e934753f08d00a99a284ca3178.tar.bz2
dsub-16640a1f9196a2e934753f08d00a99a284ca3178.zip
Always clone list to avoid crashes
-rw-r--r--src/github/daneren2005/dsub/fragments/DownloadFragment.java24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/github/daneren2005/dsub/fragments/DownloadFragment.java b/src/github/daneren2005/dsub/fragments/DownloadFragment.java
index a9dd6541..be9c7490 100644
--- a/src/github/daneren2005/dsub/fragments/DownloadFragment.java
+++ b/src/github/daneren2005/dsub/fragments/DownloadFragment.java
@@ -939,6 +939,7 @@ public class DownloadFragment extends SubsonicFragment implements OnGestureListe
}
onDownloadListChangedTask = new SilentBackgroundTask<Void>(context) {
+ List<DownloadFile> list;
int currentPlayingIndex;
int size;
@@ -946,19 +947,20 @@ public class DownloadFragment extends SubsonicFragment implements OnGestureListe
protected Void doInBackground() throws Throwable {
currentPlayingIndex = downloadService.getCurrentPlayingIndex() + 1;
size = downloadService.size();
- return null;
- }
-
- @Override
- protected void done(Void result) {
- List<DownloadFile> list;
+
+ list = new ArrayList<DownloadFile>();
if(nowPlaying) {
- list = downloadService.getSongs();
+ list.add(downloadService.getSongs());
}
else {
- list = downloadService.getBackgroundDownloads();
+ list.add(downloadService.getBackgroundDownloads());
}
+
+ return null;
+ }
+ @Override
+ protected void done(Void result) {
if(downloadService.isShufflePlayEnabled()) {
emptyTextView.setText(R.string.download_shuffle_loading);
}
@@ -966,11 +968,7 @@ public class DownloadFragment extends SubsonicFragment implements OnGestureListe
emptyTextView.setText(R.string.download_empty);
}
- if(songListAdapter == null || refresh) {
- playlistView.setAdapter(songListAdapter = new SongListAdapter(list));
- } else {
- songListAdapter.notifyDataSetChanged();
- }
+ playlistView.setAdapter(songListAdapter = new SongListAdapter(list));
emptyTextView.setVisibility(list.isEmpty() ? View.VISIBLE : View.GONE);
currentRevision = downloadService.getDownloadListUpdateRevision();