From 16640a1f9196a2e934753f08d00a99a284ca3178 Mon Sep 17 00:00:00 2001 From: daneren2005 Date: Tue, 19 Nov 2013 16:41:17 -0800 Subject: Always clone list to avoid crashes --- .../dsub/fragments/DownloadFragment.java | 24 ++++++++++------------ 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'src') 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(context) { + List 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 list; + + list = new ArrayList(); 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(); -- cgit v1.2.3