aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-08-26 20:07:03 -0700
committerScott Jackson <daneren2005@gmail.com>2013-08-26 20:07:03 -0700
commit054f83744088381f99765bf2957ddbed19d8e61f (patch)
tree3165e65b53c544fd897a4bfe10c2772a76624628 /src
parentfab9783ccaf4b290b0eedb6cf8a34a4143cd13da (diff)
downloaddsub-054f83744088381f99765bf2957ddbed19d8e61f.tar.gz
dsub-054f83744088381f99765bf2957ddbed19d8e61f.tar.bz2
dsub-054f83744088381f99765bf2957ddbed19d8e61f.zip
Refactor remembering lists so it's done in onCreateView (seems to be only way it keeps position intact)
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/fragments/SearchFragment.java2
-rw-r--r--src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java88
2 files changed, 44 insertions, 46 deletions
diff --git a/src/github/daneren2005/dsub/fragments/SearchFragment.java b/src/github/daneren2005/dsub/fragments/SearchFragment.java
index 21f810a4..6fa86737 100644
--- a/src/github/daneren2005/dsub/fragments/SearchFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SearchFragment.java
@@ -134,6 +134,7 @@ public class SearchFragment extends SubsonicFragment {
if(searchResult != null) {
skipSearch = true;
+ populateList();
}
return rootView;
@@ -192,7 +193,6 @@ public class SearchFragment extends SubsonicFragment {
public void search(final String query, final boolean autoplay) {
if(skipSearch) {
skipSearch = false;
- populateList();
return;
}
mergeAdapter = new MergeAdapter();
diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
index 60d3eaad..c5489c6c 100644
--- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
@@ -140,13 +140,8 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
invalidated = true;
}
} else {
- new LoadTask() {
- @Override
- protected MusicDirectory load(MusicService service) throws Exception {
- albumListSize = entries.size();
- return new MusicDirectory(entries);
- }
- }.execute();
+ licenseValid = true;
+ finishLoading();
}
if(name != null) {
@@ -437,44 +432,47 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
@Override
protected void done(Pair<MusicDirectory, Boolean> result) {
entries = result.getFirst().getChildren();
-
- int songCount = 0;
- for (MusicDirectory.Entry entry : entries) {
- if (!entry.isDirectory()) {
- songCount++;
- }
- }
-
- if (songCount > 0) {
- if(showHeader) {
- View header = createHeader(entries);
- if(header != null) {
- entryList.addHeaderView(header, null, false);
- }
- }
- } else {
- showHeader = false;
- hideButtons = true;
- }
-
- emptyView.setVisibility(entries.isEmpty() ? View.VISIBLE : View.GONE);
- entryAdapter = new EntryAdapter(context, getImageLoader(), entries, (podcastId == null) ? true : false);
- if(albumListType == null || "starred".equals(albumListType)) {
- entryList.setAdapter(entryAdapter);
- } else {
- entryList.setAdapter(new AlbumListAdapter(context, entryAdapter, albumListType, albumListExtra, albumListSize));
- }
- entryList.setVisibility(View.VISIBLE);
- licenseValid = result.getSecond();
- context.supportInvalidateOptionsMenu();
-
- Bundle args = getArguments();
- boolean playAll = args.getBoolean(Constants.INTENT_EXTRA_NAME_AUTOPLAY, false);
- if (playAll && songCount > 0) {
- playAll(args.getBoolean(Constants.INTENT_EXTRA_NAME_SHUFFLE, false), false);
- }
- }
- }
+ licenseValid = result.getSecond();
+ finishLoading();
+ }
+ }
+
+ private void finishLoading() {
+ int songCount = 0;
+ for (MusicDirectory.Entry entry : entries) {
+ if (!entry.isDirectory()) {
+ songCount++;
+ }
+ }
+
+ if (songCount > 0) {
+ if(showHeader) {
+ View header = createHeader(entries);
+ if(header != null) {
+ entryList.addHeaderView(header, null, false);
+ }
+ }
+ } else {
+ showHeader = false;
+ hideButtons = true;
+ }
+
+ emptyView.setVisibility(entries.isEmpty() ? View.VISIBLE : View.GONE);
+ entryAdapter = new EntryAdapter(context, getImageLoader(), entries, (podcastId == null) ? true : false);
+ if(albumListType == null || "starred".equals(albumListType)) {
+ entryList.setAdapter(entryAdapter);
+ } else {
+ entryList.setAdapter(new AlbumListAdapter(context, entryAdapter, albumListType, albumListExtra, albumListSize));
+ }
+ entryList.setVisibility(View.VISIBLE);
+ context.supportInvalidateOptionsMenu();
+
+ Bundle args = getArguments();
+ boolean playAll = args.getBoolean(Constants.INTENT_EXTRA_NAME_AUTOPLAY, false);
+ if (playAll && songCount > 0) {
+ playAll(args.getBoolean(Constants.INTENT_EXTRA_NAME_SHUFFLE, false), false);
+ }
+ }
private void playNow(final boolean shuffle, final boolean append) {
if(getSelectedSongs().size() > 0) {