diff options
author | Scott Jackson <daneren2005@gmail.com> | 2013-11-10 22:41:59 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2013-11-10 22:41:59 -0800 |
commit | 5a1510d4431779a2f4c13159e21f29a8a11c4e6d (patch) | |
tree | 1ff36ccea6e578788121170257fe1ffff505f34c /src | |
parent | 130192b2710bc6992cd1ab1f49abfb5b15cdc0ed (diff) | |
download | dsub-5a1510d4431779a2f4c13159e21f29a8a11c4e6d.tar.gz dsub-5a1510d4431779a2f4c13159e21f29a8a11c4e6d.tar.bz2 dsub-5a1510d4431779a2f4c13159e21f29a8a11c4e6d.zip |
Fix another Galaxy S3 freeze situation
Diffstat (limited to 'src')
-rw-r--r-- | src/github/daneren2005/dsub/fragments/DownloadFragment.java | 98 |
1 files changed, 58 insertions, 40 deletions
diff --git a/src/github/daneren2005/dsub/fragments/DownloadFragment.java b/src/github/daneren2005/dsub/fragments/DownloadFragment.java index 50960834..057b302f 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 SongListAdapter songListAdapter;
private SilentBackgroundTask<Void> onProgressChangedTask;
private SilentBackgroundTask<Void> onCurrentChangedTask;
+ private SilentBackgroundTask<Void> onDownloadListChangedTask;
private boolean seekInProgress = false;
private boolean startFlipped = false;
@@ -899,54 +900,71 @@ public class DownloadFragment extends SubsonicFragment implements OnGestureListe private void onDownloadListChanged() {
onDownloadListChanged(false);
}
- private void onDownloadListChanged(boolean refresh) {
- DownloadService downloadService = getDownloadService();
- if (downloadService == null) {
+ private void onDownloadListChanged(final boolean refresh) {
+ final DownloadService downloadService = getDownloadService();
+ if (downloadService == null || onDownloadListChangedTask != null) {
return;
}
- List<DownloadFile> list;
- if(nowPlaying) {
- list = downloadService.getSongs();
- }
- else {
- list = downloadService.getBackgroundDownloads();
- }
+ onDownloadListChangedTask = new SilentBackgroundTask<Void>(context) {
+ int currentPlayingIndex;
+ int size;
- if(downloadService.isShufflePlayEnabled()) {
- emptyTextView.setText(R.string.download_shuffle_loading);
- }
- else {
- emptyTextView.setText(R.string.download_empty);
- }
+ @Override
+ protected Void doInBackground() throws Throwable {
+ currentPlayingIndex = downloadService.getCurrentPlayingIndex() + 1;
+ size = downloadService.size();
+ return null;
+ }
- if(songListAdapter == null || refresh) {
- playlistView.setAdapter(songListAdapter = new SongListAdapter(list));
- } else {
- songListAdapter.notifyDataSetChanged();
- }
- emptyTextView.setVisibility(list.isEmpty() ? View.VISIBLE : View.GONE);
- currentRevision = downloadService.getDownloadListUpdateRevision();
+ @Override
+ protected void done(Void result) {
+ List<DownloadFile> list;
+ if(nowPlaying) {
+ list = downloadService.getSongs();
+ }
+ else {
+ list = downloadService.getBackgroundDownloads();
+ }
- switch (downloadService.getRepeatMode()) {
- case OFF:
- if("light".equals(SubsonicActivity.getThemeName()) | "light_fullscreen".equals(SubsonicActivity.getThemeName())) {
- repeatButton.setImageResource(R.drawable.media_repeat_off_light);
+ if(downloadService.isShufflePlayEnabled()) {
+ emptyTextView.setText(R.string.download_shuffle_loading);
+ }
+ else {
+ emptyTextView.setText(R.string.download_empty);
+ }
+
+ if(songListAdapter == null || refresh) {
+ playlistView.setAdapter(songListAdapter = new SongListAdapter(list));
} else {
- repeatButton.setImageResource(R.drawable.media_repeat_off);
+ songListAdapter.notifyDataSetChanged();
}
- break;
- case ALL:
- repeatButton.setImageResource(R.drawable.media_repeat_all);
- break;
- case SINGLE:
- repeatButton.setImageResource(R.drawable.media_repeat_single);
- break;
- default:
- break;
- }
-
- setSubtitle(context.getResources().getString(R.string.download_playing_out_of, downloadService.getCurrentPlayingIndex() + 1, downloadService.size()));
+ emptyTextView.setVisibility(list.isEmpty() ? View.VISIBLE : View.GONE);
+ currentRevision = downloadService.getDownloadListUpdateRevision();
+
+ switch (downloadService.getRepeatMode()) {
+ case OFF:
+ if("light".equals(SubsonicActivity.getThemeName()) | "light_fullscreen".equals(SubsonicActivity.getThemeName())) {
+ repeatButton.setImageResource(R.drawable.media_repeat_off_light);
+ } else {
+ repeatButton.setImageResource(R.drawable.media_repeat_off);
+ }
+ break;
+ case ALL:
+ repeatButton.setImageResource(R.drawable.media_repeat_all);
+ break;
+ case SINGLE:
+ repeatButton.setImageResource(R.drawable.media_repeat_single);
+ break;
+ default:
+ break;
+ }
+
+ setSubtitle(context.getResources().getString(R.string.download_playing_out_of, currentPlayingIndex, size));
+ onDownloadListChangedTask = null;
+ }
+ };
+ onDownloadListChangedTask.execute();
}
private void onCurrentChanged() {
|