From ff38b10ad35996a5f5f981532e1b5d455bdfc0e7 Mon Sep 17 00:00:00 2001 From: daneren2005 Date: Wed, 20 Nov 2013 13:29:34 -0800 Subject: Attempt to fix download list going back to top on changes --- .../dsub/fragments/DownloadFragment.java | 31 +++++++++++++++------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/github/daneren2005/dsub/fragments/DownloadFragment.java b/src/github/daneren2005/dsub/fragments/DownloadFragment.java index fe886e42..e6b7c0a6 100644 --- a/src/github/daneren2005/dsub/fragments/DownloadFragment.java +++ b/src/github/daneren2005/dsub/fragments/DownloadFragment.java @@ -103,6 +103,7 @@ public class DownloadFragment extends SubsonicFragment implements OnGestureListe private VisualizerView visualizerView; private boolean nowPlaying = true; private ScheduledFuture hideControlsFuture; + private List songList; private SongListAdapter songListAdapter; private SilentBackgroundTask onProgressChangedTask; private SilentBackgroundTask onCurrentChangedTask; @@ -866,8 +867,8 @@ public class DownloadFragment extends SubsonicFragment implements OnGestureListe } if(startFlipped) { - scrollToCurrent(); startFlipped = false; + scrollToCurrent(); } onProgressChanged(); @@ -941,7 +942,6 @@ public class DownloadFragment extends SubsonicFragment implements OnGestureListe } onDownloadListChangedTask = new SilentBackgroundTask(context) { - List list; int currentPlayingIndex; int size; @@ -950,19 +950,19 @@ public class DownloadFragment extends SubsonicFragment implements OnGestureListe currentPlayingIndex = downloadService.getCurrentPlayingIndex() + 1; size = downloadService.size(); - list = new ArrayList(); - if(nowPlaying) { - list.addAll(downloadService.getSongs()); - } - else { - list.addAll(downloadService.getBackgroundDownloads()); - } - return null; } @Override protected void done(Void result) { + List list; + if(nowPlaying) { + list = downloadService.getSongs(); + } + else { + list = downloadService.getBackgroundDownloads(); + } + if(downloadService.isShufflePlayEnabled()) { emptyTextView.setText(R.string.download_shuffle_loading); } @@ -971,6 +971,17 @@ public class DownloadFragment extends SubsonicFragment implements OnGestureListe } playlistView.setAdapter(songListAdapter = new SongListAdapter(list)); + + if(songListAdapter == null || refresh) { + songList = new ArrayList(); + songList.addAll(list); + playlistView.setAdapter(songListAdapter = new SongListAdapter(songList)); + } else { + songList.clear(); + songList.addAll(list); + songListAdapter.notifyDataSetChanged(); + } + emptyTextView.setVisibility(list.isEmpty() ? View.VISIBLE : View.GONE); currentRevision = downloadService.getDownloadListUpdateRevision(); -- cgit v1.2.3