diff options
author | Scott Jackson <daneren2005@gmail.com> | 2014-04-27 15:09:39 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2014-04-27 15:09:39 -0700 |
commit | 4aebaf640b685b42767ef1077178dc5d2084e731 (patch) | |
tree | a267dde5065dcce2f170f5d57dffac3fbbb84452 /src/github/daneren2005 | |
parent | 124e6c82c2a0bae229717d8b4595b14d91616263 (diff) | |
download | dsub-4aebaf640b685b42767ef1077178dc5d2084e731.tar.gz dsub-4aebaf640b685b42767ef1077178dc5d2084e731.tar.bz2 dsub-4aebaf640b685b42767ef1077178dc5d2084e731.zip |
Fix grid lists expanding infinitely
Diffstat (limited to 'src/github/daneren2005')
-rw-r--r-- | src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java | 99 |
1 files changed, 60 insertions, 39 deletions
diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java index 34be2d8c..abbf95c8 100644 --- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java @@ -31,7 +31,7 @@ import github.daneren2005.dsub.view.EntryAdapter; import java.io.Serializable;
import java.util.Iterator;
import java.util.List;
-import com.mobeta.android.dslv.*;
+
import github.daneren2005.dsub.activity.DownloadActivity;
import github.daneren2005.dsub.domain.PodcastEpisode;
import github.daneren2005.dsub.service.MusicService;
@@ -99,6 +99,33 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
+ Bundle args = getArguments();
+ if(args != null) {
+ id = args.getString(Constants.INTENT_EXTRA_NAME_ID);
+ name = args.getString(Constants.INTENT_EXTRA_NAME_NAME);
+ playlistId = args.getString(Constants.INTENT_EXTRA_NAME_PLAYLIST_ID);
+ playlistName = args.getString(Constants.INTENT_EXTRA_NAME_PLAYLIST_NAME);
+ podcastId = args.getString(Constants.INTENT_EXTRA_NAME_PODCAST_ID);
+ podcastName = args.getString(Constants.INTENT_EXTRA_NAME_PODCAST_NAME);
+ podcastDescription = args.getString(Constants.INTENT_EXTRA_NAME_PODCAST_DESCRIPTION);
+ Object shareObj = args.getSerializable(Constants.INTENT_EXTRA_NAME_SHARE);
+ share = (shareObj != null) ? (Share) shareObj : null;
+ albumListType = args.getString(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_TYPE);
+ albumListExtra = args.getString(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_EXTRA);
+ albumListSize = args.getInt(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_SIZE, 0);
+ refreshListing = args.getBoolean(Constants.INTENT_EXTRA_REFRESH_LISTINGS);
+ artist = args.getBoolean(Constants.INTENT_EXTRA_NAME_ARTIST, false);
+
+ String childId = args.getString(Constants.INTENT_EXTRA_NAME_CHILD_ID);
+ if(childId != null) {
+ id = childId;
+ lookupParent = true;
+ }
+ if(entries == null) {
+ entries = (List<MusicDirectory.Entry>) args.getSerializable(Constants.FRAGMENT_LIST);
+ }
+ }
+
rootView = inflater.inflate(R.layout.select_album, container, false);
refreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.refresh_layout);
@@ -108,18 +135,35 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter entryList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
entryList.setOnItemClickListener(this);
- entryList.setOnScrollListener(new AbsListView.OnScrollListener() {
- @Override
- public void onScrollStateChanged(AbsListView view, int scrollState) {}
+ if(albumListType == null || "starred".equals(albumListType)) {
+ albumList = (GridView) inflater.inflate(R.layout.unscrollable_grid_view, entryList, false);
- @Override
- public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
- int topRowVerticalPosition = (entryList.getChildCount() == 0) ? 0 : entryList.getChildAt(0).getTop();
- refreshLayout.setEnabled(topRowVerticalPosition >= 0);
- }
- });
+ entryList.setOnScrollListener(new AbsListView.OnScrollListener() {
+ @Override
+ public void onScrollStateChanged(AbsListView view, int scrollState) {}
- albumList = (GridView) inflater.inflate(R.layout.grid_view, entryList, false);
+ @Override
+ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
+ int topRowVerticalPosition = (entryList.getChildCount() == 0) ? 0 : entryList.getChildAt(0).getTop();
+ refreshLayout.setEnabled(topRowVerticalPosition >= 0);
+ }
+ });
+ } else {
+ ViewGroup rootGroup = (ViewGroup) rootView.findViewById(R.id.select_album_layout);
+ albumList = (GridView) inflater.inflate(R.layout.grid_view, rootGroup, false);
+ rootGroup.addView(albumList);
+
+ albumList.setOnScrollListener(new AbsListView.OnScrollListener() {
+ @Override
+ public void onScrollStateChanged(AbsListView view, int scrollState) {}
+
+ @Override
+ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
+ int topRowVerticalPosition = (albumList.getChildCount() == 0) ? 0 : albumList.getChildAt(0).getTop();
+ refreshLayout.setEnabled(topRowVerticalPosition >= 0);
+ }
+ });
+ }
albumList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
@@ -139,40 +183,17 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter replaceFragment(fragment, true);
}
});
- entryList.addHeaderView(albumList);
+ if(albumListType == null || "starred".equals(albumListType)) {
+ entryList.addHeaderView(albumList);
+ } else {
+ entryList.setVisibility(View.GONE);
+ }
emptyView = rootView.findViewById(R.id.select_album_empty);
registerForContextMenu(entryList);
registerForContextMenu(albumList);
- Bundle args = getArguments();
- if(args != null) {
- id = args.getString(Constants.INTENT_EXTRA_NAME_ID);
- name = args.getString(Constants.INTENT_EXTRA_NAME_NAME);
- playlistId = args.getString(Constants.INTENT_EXTRA_NAME_PLAYLIST_ID);
- playlistName = args.getString(Constants.INTENT_EXTRA_NAME_PLAYLIST_NAME);
- podcastId = args.getString(Constants.INTENT_EXTRA_NAME_PODCAST_ID);
- podcastName = args.getString(Constants.INTENT_EXTRA_NAME_PODCAST_NAME);
- podcastDescription = args.getString(Constants.INTENT_EXTRA_NAME_PODCAST_DESCRIPTION);
- Object shareObj = args.getSerializable(Constants.INTENT_EXTRA_NAME_SHARE);
- share = (shareObj != null) ? (Share) shareObj : null;
- albumListType = args.getString(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_TYPE);
- albumListExtra = args.getString(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_EXTRA);
- albumListSize = args.getInt(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_SIZE, 0);
- refreshListing = args.getBoolean(Constants.INTENT_EXTRA_REFRESH_LISTINGS);
- artist = args.getBoolean(Constants.INTENT_EXTRA_NAME_ARTIST, false);
-
- String childId = args.getString(Constants.INTENT_EXTRA_NAME_CHILD_ID);
- if(childId != null) {
- id = childId;
- lookupParent = true;
- }
- if(entries == null) {
- entries = (List<MusicDirectory.Entry>) args.getSerializable(Constants.FRAGMENT_LIST);
- }
- }
-
if(entries == null) {
if(primaryFragment || secondaryFragment) {
load(false);
|