diff options
author | Scott Jackson <daneren2005@gmail.com> | 2013-02-22 07:40:04 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2013-02-22 07:40:04 -0800 |
commit | f0c10c774562401a09afcc556d441ce8fcc71637 (patch) | |
tree | 1c68b5d754810e845eab95a7a45211acf294e503 /subsonic-android | |
parent | ce6e1589188e6d008d1784a9165fddd1a44e1e7a (diff) | |
download | dsub-f0c10c774562401a09afcc556d441ce8fcc71637.tar.gz dsub-f0c10c774562401a09afcc556d441ce8fcc71637.tar.bz2 dsub-f0c10c774562401a09afcc556d441ce8fcc71637.zip |
Don't go back to the top when changing now playing list
Diffstat (limited to 'subsonic-android')
-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. */ |