diff options
-rw-r--r-- | subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java | 27 | ||||
-rw-r--r-- | subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java | 8 |
2 files changed, 21 insertions, 14 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java index a4222ce5..f7736375 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java @@ -121,6 +121,7 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi private VisualizerView visualizerView; private boolean nowPlaying = true; private ScheduledFuture<?> hideControlsFuture; + private SongListAdapter songListAdapter; /** * Called when the activity is first created. @@ -783,25 +784,35 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi } } } - - private void onDownloadListChanged() { + private void onDownloadListChanged() { + onDownloadListChanged(false); + } + private void onDownloadListChanged(boolean refresh) { DownloadService downloadService = getDownloadService(); if (downloadService == null) { return; } List<DownloadFile> list; - if(nowPlaying) + if(nowPlaying) { list = downloadService.getSongs(); - else + } + else { list = downloadService.getBackgroundDownloads(); + } - if(downloadService.isShufflePlayEnabled()) + if(downloadService.isShufflePlayEnabled()) { emptyTextView.setText(R.string.download_shuffle_loading); - else + } + else { emptyTextView.setText(R.string.download_empty); + } - playlistView.setAdapter(new SongListAdapter(list)); + if(songListAdapter == null || refresh) { + playlistView.setAdapter(songListAdapter = new SongListAdapter(list)); + } else { + songListAdapter.notifyDataSetChanged(); + } emptyTextView.setVisibility(list.isEmpty() ? View.VISIBLE : View.GONE); currentRevision = downloadService.getDownloadListUpdateRevision(); @@ -1004,7 +1015,7 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi private void toggleNowPlaying() { nowPlaying = !nowPlaying; setTitle(nowPlaying ? "Now Playing" : "Downloading"); - onDownloadListChanged(); + onDownloadListChanged(true); } @Override diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java index 9e6662cf..c0275386 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java @@ -498,9 +498,7 @@ public class DownloadServiceImpl extends Service implements DownloadService { @Override public synchronized List<DownloadFile> getSongs() { - List<DownloadFile> temp = new ArrayList<DownloadFile>(); - temp.addAll(downloadList); - return temp; + return downloadList; } @Override @@ -513,9 +511,7 @@ public class DownloadServiceImpl extends Service implements DownloadService { @Override public synchronized List<DownloadFile> getBackgroundDownloads() { - List<DownloadFile> temp = new ArrayList<DownloadFile>(); - temp.addAll(backgroundDownloadList); - return temp; + return backgroundDownloadList; } /** Plays either the current song (resume) or the first/next one in queue. */ |