aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-08-25 22:54:01 -0700
committerScott Jackson <daneren2005@gmail.com>2013-08-25 22:54:01 -0700
commitfab9783ccaf4b290b0eedb6cf8a34a4143cd13da (patch)
treef8891b69c6226d7a1c882bb982e2d8597d53dbcb
parent4a784471ab1380784e93e8071943420256faaab3 (diff)
downloaddsub-fab9783ccaf4b290b0eedb6cf8a34a4143cd13da.tar.gz
dsub-fab9783ccaf4b290b0eedb6cf8a34a4143cd13da.tar.bz2
dsub-fab9783ccaf4b290b0eedb6cf8a34a4143cd13da.zip
Closes #126 Keep lists on orientation change
-rw-r--r--src/github/daneren2005/dsub/domain/Lyrics.java4
-rw-r--r--src/github/daneren2005/dsub/domain/MusicDirectory.java7
-rw-r--r--src/github/daneren2005/dsub/domain/SearchResult.java3
-rw-r--r--src/github/daneren2005/dsub/fragments/ChatFragment.java35
-rw-r--r--src/github/daneren2005/dsub/fragments/DownloadFragment.java22
-rw-r--r--src/github/daneren2005/dsub/fragments/LyricsFragment.java50
-rw-r--r--src/github/daneren2005/dsub/fragments/SearchFragment.java26
-rw-r--r--src/github/daneren2005/dsub/fragments/SelectArtistFragment.java58
-rw-r--r--src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java22
-rw-r--r--src/github/daneren2005/dsub/fragments/SelectGenreFragment.java22
-rw-r--r--src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java26
-rw-r--r--src/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java26
-rw-r--r--src/github/daneren2005/dsub/util/Constants.java3
13 files changed, 251 insertions, 53 deletions
diff --git a/src/github/daneren2005/dsub/domain/Lyrics.java b/src/github/daneren2005/dsub/domain/Lyrics.java
index feb75cd6..5272920d 100644
--- a/src/github/daneren2005/dsub/domain/Lyrics.java
+++ b/src/github/daneren2005/dsub/domain/Lyrics.java
@@ -18,12 +18,14 @@
*/
package github.daneren2005.dsub.domain;
+import java.io.Serializable;
+
/**
* Song lyrics.
*
* @author Sindre Mehus
*/
-public class Lyrics {
+public class Lyrics implements Serializable {
private String artist;
private String title;
diff --git a/src/github/daneren2005/dsub/domain/MusicDirectory.java b/src/github/daneren2005/dsub/domain/MusicDirectory.java
index 6e51eff8..c05d1631 100644
--- a/src/github/daneren2005/dsub/domain/MusicDirectory.java
+++ b/src/github/daneren2005/dsub/domain/MusicDirectory.java
@@ -36,6 +36,13 @@ public class MusicDirectory {
private String parent;
private List<Entry> children = new ArrayList<Entry>();
+ public MusicDirectory() {
+
+ }
+ public MusicDirectory(List<Entry> children) {
+ this.children = children;
+ }
+
public String getName() {
return name;
}
diff --git a/src/github/daneren2005/dsub/domain/SearchResult.java b/src/github/daneren2005/dsub/domain/SearchResult.java
index 11a56540..3427f2ca 100644
--- a/src/github/daneren2005/dsub/domain/SearchResult.java
+++ b/src/github/daneren2005/dsub/domain/SearchResult.java
@@ -18,6 +18,7 @@
*/
package github.daneren2005.dsub.domain;
+import java.io.Serializable;
import java.util.List;
/**
@@ -25,7 +26,7 @@ import java.util.List;
*
* @author Sindre Mehus
*/
-public class SearchResult {
+public class SearchResult implements Serializable {
private final List<Artist> artists;
private final List<MusicDirectory.Entry> albums;
diff --git a/src/github/daneren2005/dsub/fragments/ChatFragment.java b/src/github/daneren2005/dsub/fragments/ChatFragment.java
index a17d680c..198b93a4 100644
--- a/src/github/daneren2005/dsub/fragments/ChatFragment.java
+++ b/src/github/daneren2005/dsub/fragments/ChatFragment.java
@@ -2,6 +2,8 @@ package github.daneren2005.dsub.fragments;
import android.content.Context;
import android.content.SharedPreferences;
+
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -46,12 +48,23 @@ public class ChatFragment extends SubsonicFragment {
private EditText messageEditText;
private ImageButton sendButton;
private Long lastChatMessageTime = (long) 0;
- private ArrayList<ChatMessage> messageList = new ArrayList<ChatMessage>();
+ private ArrayList<ChatMessage> messageList;
private ScheduledExecutorService executorService;
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
+
+ if(bundle != null) {
+ List<ChatMessage> abstractList = (List<ChatMessage>) bundle.getSerializable(Constants.FRAGMENT_LIST);
+ messageList = new ArrayList<ChatMessage>(abstractList);
+ }
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ outState.putSerializable(Constants.FRAGMENT_LIST, (Serializable) messageList);
}
@Override
@@ -99,7 +112,21 @@ public class ChatFragment extends SubsonicFragment {
}
});
- invalidated = true;
+ if(messageList == null) {
+ messageList = new ArrayList<ChatMessage>();
+ invalidated = true;
+ } else {
+ for (ChatMessage message : messageList) {
+ if (message.getTime() > lastChatMessageTime) {
+ lastChatMessageTime = message.getTime();
+ }
+ }
+
+ ChatAdapter chatAdapter = new ChatAdapter(context, messageList);
+ chatListView.setAdapter(chatAdapter);
+ }
+ setTitle(R.string.button_bar_chat);
+
return rootView;
}
@@ -161,8 +188,6 @@ public class ChatFragment extends SubsonicFragment {
}
private synchronized void load(final boolean refresh) {
- Log.i(TAG, "Loading: " + refresh);
- setTitle(R.string.button_bar_chat);
BackgroundTask<List<ChatMessage>> task = new TabBackgroundTask<List<ChatMessage>>(this) {
@Override
protected List<ChatMessage> doInBackground() throws Throwable {
@@ -176,7 +201,7 @@ public class ChatFragment extends SubsonicFragment {
if(refresh) {
messageList.clear();
}
-
+
// Reset lastChatMessageTime if we have a newer message
for (ChatMessage message : result) {
if (message.getTime() > lastChatMessageTime) {
diff --git a/src/github/daneren2005/dsub/fragments/DownloadFragment.java b/src/github/daneren2005/dsub/fragments/DownloadFragment.java
index f6aa15fe..f1f4b7c0 100644
--- a/src/github/daneren2005/dsub/fragments/DownloadFragment.java
+++ b/src/github/daneren2005/dsub/fragments/DownloadFragment.java
@@ -105,6 +105,7 @@ public class DownloadFragment extends SubsonicFragment implements OnGestureListe
private SongListAdapter songListAdapter;
private SilentBackgroundTask<Void> onProgressChangedTask;
private boolean seekInProgress = false;
+ private boolean startFlipped = false;
/**
* Called when the activity is first created.
@@ -112,6 +113,18 @@ public class DownloadFragment extends SubsonicFragment implements OnGestureListe
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+
+ if(savedInstanceState != null) {
+ if(savedInstanceState.getInt(Constants.FRAGMENT_DOWNLOAD_FLIPPER) == 1) {
+ startFlipped = true;
+ }
+ }
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ outState.putInt(Constants.FRAGMENT_DOWNLOAD_FLIPPER, playlistFlipper.getDisplayedChild());
}
@Override
@@ -692,11 +705,9 @@ public class DownloadFragment extends SubsonicFragment implements OnGestureListe
setControlsVisible(true);
DownloadService downloadService = getDownloadService();
- if (downloadService == null || downloadService.getCurrentPlaying() == null) {
+ if (downloadService == null || downloadService.getCurrentPlaying() == null || startFlipped) {
playlistFlipper.setDisplayedChild(1);
}
-
- scrollToCurrent();
if (downloadService != null && downloadService.getKeepScreenOn()) {
context.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
} else {
@@ -816,6 +827,11 @@ public class DownloadFragment extends SubsonicFragment implements OnGestureListe
onCurrentChanged();
}
+ if(startFlipped) {
+ scrollToCurrent();
+ startFlipped = false;
+ }
+
onProgressChanged();
}
diff --git a/src/github/daneren2005/dsub/fragments/LyricsFragment.java b/src/github/daneren2005/dsub/fragments/LyricsFragment.java
index 0b247986..826029f5 100644
--- a/src/github/daneren2005/dsub/fragments/LyricsFragment.java
+++ b/src/github/daneren2005/dsub/fragments/LyricsFragment.java
@@ -38,16 +38,40 @@ import github.daneren2005.dsub.util.TabBackgroundTask;
* @author Sindre Mehus
*/
public final class LyricsFragment extends SubsonicFragment {
+ private TextView artistView;
+ private TextView titleView;
+ private TextView textView;
+
+ private Lyrics lyrics;
+
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
- setTitle(R.string.download_menu_lyrics);
+
+ if(bundle != null) {
+ lyrics = (Lyrics) bundle.getSerializable(Constants.FRAGMENT_LIST);
+ }
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ outState.putSerializable(Constants.FRAGMENT_LIST, lyrics);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
+ setTitle(R.string.download_menu_lyrics);
rootView = inflater.inflate(R.layout.lyrics, container, false);
- load();
+ artistView = (TextView) rootView.findViewById(R.id.lyrics_artist);
+ titleView = (TextView) rootView.findViewById(R.id.lyrics_title);
+ textView = (TextView) rootView.findViewById(R.id.lyrics_text);
+
+ if(lyrics == null) {
+ load();
+ } else {
+ setLyrics();
+ }
return rootView;
}
@@ -64,18 +88,20 @@ public final class LyricsFragment extends SubsonicFragment {
@Override
protected void done(Lyrics result) {
- TextView artistView = (TextView) rootView.findViewById(R.id.lyrics_artist);
- TextView titleView = (TextView) rootView.findViewById(R.id.lyrics_title);
- TextView textView = (TextView) rootView.findViewById(R.id.lyrics_text);
- if (result != null && result.getArtist() != null) {
- artistView.setText(result.getArtist());
- titleView.setText(result.getTitle());
- textView.setText(result.getText());
- } else {
- artistView.setText(R.string.lyrics_nomatch);
- }
+ lyrics = result;
+ setLyrics();
}
};
task.execute();
}
+
+ private void setLyrics() {
+ if (lyrics != null && lyrics.getArtist() != null) {
+ artistView.setText(lyrics.getArtist());
+ titleView.setText(lyrics.getTitle());
+ textView.setText(lyrics.getText());
+ } else {
+ artistView.setText(R.string.lyrics_nomatch);
+ }
+ }
} \ No newline at end of file
diff --git a/src/github/daneren2005/dsub/fragments/SearchFragment.java b/src/github/daneren2005/dsub/fragments/SearchFragment.java
index 869287d1..21f810a4 100644
--- a/src/github/daneren2005/dsub/fragments/SearchFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SearchFragment.java
@@ -1,11 +1,14 @@
package github.daneren2005.dsub.fragments;
+import java.io.Serializable;
import java.util.ArrayList;
+import java.util.Dictionary;
import java.util.List;
import java.util.Arrays;
import android.content.Intent;
import android.os.Bundle;
+import android.util.Log;
import android.view.ContextMenu;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -36,6 +39,8 @@ import github.daneren2005.dsub.util.TabBackgroundTask;
import github.daneren2005.dsub.util.Util;
public class SearchFragment extends SubsonicFragment {
+ private static final String TAG = SearchFragment.class.getSimpleName();
+
private static final int DEFAULT_ARTISTS = 3;
private static final int DEFAULT_ALBUMS = 5;
private static final int DEFAULT_SONGS = 10;
@@ -60,10 +65,21 @@ public class SearchFragment extends SubsonicFragment {
private ListAdapter moreAlbumsAdapter;
private ListAdapter moreSongsAdapter;
private EntryAdapter songAdapter;
+ private boolean skipSearch = false;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+
+ if(savedInstanceState != null) {
+ searchResult = (SearchResult) savedInstanceState.getSerializable(Constants.FRAGMENT_LIST);
+ }
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ outState.putSerializable(Constants.FRAGMENT_LIST, searchResult);
}
@Override
@@ -115,6 +131,11 @@ public class SearchFragment extends SubsonicFragment {
});
registerForContextMenu(list);
((SearchActivity)context).onSupportNewIntent(context.getIntent());
+
+ if(searchResult != null) {
+ skipSearch = true;
+ }
+
return rootView;
}
@@ -169,6 +190,11 @@ public class SearchFragment extends SubsonicFragment {
}
public void search(final String query, final boolean autoplay) {
+ if(skipSearch) {
+ skipSearch = false;
+ populateList();
+ return;
+ }
mergeAdapter = new MergeAdapter();
list.setAdapter(mergeAdapter);
diff --git a/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java b/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java
index 9451c648..b11f6fe7 100644
--- a/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java
@@ -27,6 +27,7 @@ import github.daneren2005.dsub.util.TabBackgroundTask;
import github.daneren2005.dsub.util.Util;
import github.daneren2005.dsub.view.ArtistAdapter;
import java.io.File;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@@ -39,10 +40,23 @@ public class SelectArtistFragment extends SubsonicFragment implements AdapterVie
private View folderButton;
private TextView folderName;
private List<MusicFolder> musicFolders = null;
+ private List<Artist> artists;
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
+
+ if(bundle != null) {
+ artists = (List<Artist>) bundle.getSerializable(Constants.FRAGMENT_LIST);
+ musicFolders = (List<MusicFolder>) bundle.getSerializable(Constants.FRAGMENT_LIST2);
+ }
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ outState.putSerializable(Constants.FRAGMENT_LIST, (Serializable) artists);
+ outState.putSerializable(Constants.FRAGMENT_LIST2, (Serializable) musicFolders);
}
@Override
@@ -58,10 +72,15 @@ public class SelectArtistFragment extends SubsonicFragment implements AdapterVie
folderButton = folderButtonParent.findViewById(R.id.select_artist_folder);
registerForContextMenu(artistList);
- if(!primaryFragment) {
- invalidated = true;
+ if(artists == null) {
+ if(!primaryFragment) {
+ invalidated = true;
+ } else {
+ refresh(false);
+ }
} else {
- refresh(false);
+ artistList.setAdapter(new ArtistAdapter(context, artists));
+ setMusicFolders();
}
return rootView;
@@ -177,30 +196,33 @@ public class SelectArtistFragment extends SubsonicFragment implements AdapterVie
@Override
protected void done(Indexes result) {
- List<Artist> artists = new ArrayList<Artist>(result.getShortcuts().size() + result.getArtists().size());
+ artists = new ArrayList<Artist>(result.getShortcuts().size() + result.getArtists().size());
artists.addAll(result.getShortcuts());
artists.addAll(result.getArtists());
artistList.setAdapter(new ArtistAdapter(context, artists));
- // Display selected music folder
- if (musicFolders != null) {
- String musicFolderId = Util.getSelectedMusicFolderId(context);
- if (musicFolderId == null) {
- folderName.setText(R.string.select_artist_all_folders);
- } else {
- for (MusicFolder musicFolder : musicFolders) {
- if (musicFolder.getId().equals(musicFolderId)) {
- folderName.setText(musicFolder.getName());
- break;
- }
- }
- }
- }
+ setMusicFolders();
artistList.setVisibility(View.VISIBLE);
}
};
task.execute();
}
+ private void setMusicFolders() {
+ // Display selected music folder
+ if (musicFolders != null) {
+ String musicFolderId = Util.getSelectedMusicFolderId(context);
+ if (musicFolderId == null) {
+ folderName.setText(R.string.select_artist_all_folders);
+ } else {
+ for (MusicFolder musicFolder : musicFolders) {
+ if (musicFolder.getId().equals(musicFolderId)) {
+ folderName.setText(musicFolder.getName());
+ break;
+ }
+ }
+ }
+ }
+ }
private void selectFolder() {
folderButton.showContextMenu();
diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
index 9c5a5360..60d3eaad 100644
--- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
@@ -20,6 +20,8 @@ import android.widget.TextView;
import github.daneren2005.dsub.R;
import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.view.EntryAdapter;
+
+import java.io.Serializable;
import java.util.List;
import com.mobeta.android.dslv.*;
import github.daneren2005.dsub.activity.DownloadActivity;
@@ -78,6 +80,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
if(tmp > 0) {
rootId = tmp;
}
+ entries = (List<MusicDirectory.Entry>) bundle.getSerializable(Constants.FRAGMENT_LIST);
}
}
@@ -85,6 +88,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt(Constants.FRAGMENT_ID, rootId);
+ outState.putSerializable(Constants.FRAGMENT_LIST, (Serializable) entries);
}
@Override
@@ -128,11 +132,23 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
albumListExtra = args.getString(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_EXTRA);
albumListSize = args.getInt(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_SIZE, 0);
}
- if(primaryFragment) {
- load(false);
+
+ if(entries == null) {
+ if(primaryFragment) {
+ load(false);
+ } else {
+ invalidated = true;
+ }
} else {
- invalidated = true;
+ new LoadTask() {
+ @Override
+ protected MusicDirectory load(MusicService service) throws Exception {
+ albumListSize = entries.size();
+ return new MusicDirectory(entries);
+ }
+ }.execute();
}
+
if(name != null) {
setTitle(name);
}
diff --git a/src/github/daneren2005/dsub/fragments/SelectGenreFragment.java b/src/github/daneren2005/dsub/fragments/SelectGenreFragment.java
index a509c4b7..2a6693ca 100644
--- a/src/github/daneren2005/dsub/fragments/SelectGenreFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SelectGenreFragment.java
@@ -36,6 +36,8 @@ import github.daneren2005.dsub.util.BackgroundTask;
import github.daneren2005.dsub.util.Constants;
import github.daneren2005.dsub.util.TabBackgroundTask;
import github.daneren2005.dsub.view.GenreAdapter;
+
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@@ -43,10 +45,21 @@ public class SelectGenreFragment extends SubsonicFragment implements AdapterView
private static final String TAG = SelectGenreFragment.class.getSimpleName();
private ListView genreListView;
private View emptyView;
+ private List<Genre> genres;
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
+
+ if(bundle != null) {
+ genres = (List<Genre>) bundle.getSerializable(Constants.FRAGMENT_LIST);
+ }
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ outState.putSerializable(Constants.FRAGMENT_LIST, (Serializable) genres);
}
@Override
@@ -56,7 +69,12 @@ public class SelectGenreFragment extends SubsonicFragment implements AdapterView
genreListView = (ListView)rootView.findViewById(R.id.select_genre_list);
genreListView.setOnItemClickListener(this);
emptyView = rootView.findViewById(R.id.select_genre_empty);
- refresh();
+
+ if(genres == null) {
+ refresh();
+ } else {
+ genreListView.setAdapter(new GenreAdapter(context, genres));
+ }
return rootView;
}
@@ -101,7 +119,7 @@ public class SelectGenreFragment extends SubsonicFragment implements AdapterView
protected List<Genre> doInBackground() throws Throwable {
MusicService musicService = MusicServiceFactory.getMusicService(context);
- List<Genre> genres = new ArrayList<Genre>();
+ genres = new ArrayList<Genre>();
try {
genres = musicService.getGenres(refresh, context, this);
diff --git a/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java b/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java
index 8bcd9d7a..48338b3d 100644
--- a/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java
@@ -30,6 +30,8 @@ import github.daneren2005.dsub.util.LoadingTask;
import github.daneren2005.dsub.util.TabBackgroundTask;
import github.daneren2005.dsub.util.Util;
import github.daneren2005.dsub.view.PlaylistAdapter;
+
+import java.io.Serializable;
import java.util.List;
public class SelectPlaylistFragment extends SubsonicFragment implements AdapterView.OnItemClickListener {
@@ -38,10 +40,21 @@ public class SelectPlaylistFragment extends SubsonicFragment implements AdapterV
private ListView list;
private View emptyTextView;
private PlaylistAdapter playlistAdapter;
+ private List<Playlist> playlists;
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
+
+ if(bundle != null) {
+ playlists = (List<Playlist>) bundle.getSerializable(Constants.FRAGMENT_LIST);
+ }
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ outState.putSerializable(Constants.FRAGMENT_LIST, (Serializable) playlists);
}
@Override
@@ -52,10 +65,15 @@ public class SelectPlaylistFragment extends SubsonicFragment implements AdapterV
emptyTextView = rootView.findViewById(R.id.select_playlist_empty);
list.setOnItemClickListener(this);
registerForContextMenu(list);
- if(!primaryFragment) {
- invalidated = true;
+
+ if(playlists == null) {
+ if(!primaryFragment) {
+ invalidated = true;
+ } else {
+ refresh(false);
+ }
} else {
- refresh(false);
+ list.setAdapter(playlistAdapter = new PlaylistAdapter(context, playlists));
}
return rootView;
@@ -170,7 +188,7 @@ public class SelectPlaylistFragment extends SubsonicFragment implements AdapterV
@Override
protected List<Playlist> doInBackground() throws Throwable {
MusicService musicService = MusicServiceFactory.getMusicService(context);
- List<Playlist> playlists = musicService.getPlaylists(refresh, context, this);
+ playlists = musicService.getPlaylists(refresh, context, this);
if(!Util.isOffline(context) && refresh) {
new CacheCleaner(context, getDownloadService()).cleanPlaylists(playlists);
}
diff --git a/src/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java b/src/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java
index 9cd42633..e9a06076 100644
--- a/src/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java
@@ -48,6 +48,8 @@ import github.daneren2005.dsub.util.SilentBackgroundTask;
import github.daneren2005.dsub.util.TabBackgroundTask;
import github.daneren2005.dsub.util.Util;
import github.daneren2005.dsub.view.PodcastChannelAdapter;
+
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@@ -60,10 +62,21 @@ public class SelectPodcastsFragment extends SubsonicFragment implements AdapterV
private ListView podcastListView;
private PodcastChannelAdapter podcastAdapter;
private View emptyView;
+ private List<PodcastChannel> channels;
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
+
+ if(bundle != null) {
+ channels = (List<PodcastChannel>) bundle.getSerializable(Constants.FRAGMENT_LIST);
+ }
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ outState.putSerializable(Constants.FRAGMENT_LIST, (Serializable) channels);
}
@Override
@@ -74,10 +87,15 @@ public class SelectPodcastsFragment extends SubsonicFragment implements AdapterV
podcastListView.setOnItemClickListener(this);
registerForContextMenu(podcastListView);
emptyView = rootView.findViewById(R.id.select_podcasts_empty);
- if(!primaryFragment) {
- invalidated = true;
+
+ if(channels == null) {
+ if(!primaryFragment) {
+ invalidated = true;
+ } else {
+ refresh(false);
+ }
} else {
- refresh(false);
+ podcastListView.setAdapter(podcastAdapter = new PodcastChannelAdapter(context, channels));
}
return rootView;
@@ -147,7 +165,7 @@ public class SelectPodcastsFragment extends SubsonicFragment implements AdapterV
protected List<PodcastChannel> doInBackground() throws Throwable {
MusicService musicService = MusicServiceFactory.getMusicService(context);
- List<PodcastChannel> channels = new ArrayList<PodcastChannel>();
+ channels = new ArrayList<PodcastChannel>();
try {
channels = musicService.getPodcastChannels(refresh, context, this);
diff --git a/src/github/daneren2005/dsub/util/Constants.java b/src/github/daneren2005/dsub/util/Constants.java
index 4bb3696c..41e13b2f 100644
--- a/src/github/daneren2005/dsub/util/Constants.java
+++ b/src/github/daneren2005/dsub/util/Constants.java
@@ -131,6 +131,9 @@ public final class Constants {
public static final String MAIN_BACK_STACK_TABS = "backStackTabs";
public static final String MAIN_BACK_STACK_POSITION = "backStackPosition";
public static final String FRAGMENT_ID = "fragmentId";
+ public static final String FRAGMENT_LIST = "fragmentList";
+ public static final String FRAGMENT_LIST2 = "fragmentList2";
+ public static final String FRAGMENT_DOWNLOAD_FLIPPER = "fragmentDownloadFlipper";
// Name of the preferences file.
public static final String PREFERENCES_FILE_NAME = "github.daneren2005.dsub_preferences";