diff options
author | Scott Jackson <daneren2005@gmail.com> | 2015-07-31 17:43:27 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2015-07-31 17:43:27 -0700 |
commit | 3434eb025e25e6511211c09b0c9712397899025b (patch) | |
tree | d94ecc0bcf3716fb66c7039d6df7b1598d86d9f1 /app/src | |
parent | 9de4a3118f4e8b6a8e37c771dbb6b0f7aad6f7ee (diff) | |
download | dsub-3434eb025e25e6511211c09b0c9712397899025b.tar.gz dsub-3434eb025e25e6511211c09b0c9712397899025b.tar.bz2 dsub-3434eb025e25e6511211c09b0c9712397899025b.zip |
Default grid span to make headers full width
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/fragments/SearchFragment.java | 3 | ||||
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java | 21 |
2 files changed, 19 insertions, 5 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SearchFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SearchFragment.java index f442dabb..cd294161 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SearchFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SearchFragment.java @@ -92,8 +92,7 @@ public class SearchFragment extends SubsonicFragment implements SectionAdapter.O } @Override - public GridLayoutManager.SpanSizeLookup getSpanSizeLookup() { - final int columns = getRecyclerColumnCount(); + public GridLayoutManager.SpanSizeLookup getSpanSizeLookup(final int columns) { return new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int position) { diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java index ddc39235..d1eab8b7 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java @@ -555,7 +555,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR final int columns = getRecyclerColumnCount(); GridLayoutManager gridLayoutManager = new GridLayoutManager(context, columns); - GridLayoutManager.SpanSizeLookup spanSizeLookup = getSpanSizeLookup(); + GridLayoutManager.SpanSizeLookup spanSizeLookup = getSpanSizeLookup(columns); if(spanSizeLookup != null) { gridLayoutManager.setSpanSizeLookup(spanSizeLookup); } @@ -570,8 +570,23 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR layoutManager.setOrientation(LinearLayoutManager.VERTICAL); return layoutManager; } - public GridLayoutManager.SpanSizeLookup getSpanSizeLookup() { - return null; + public GridLayoutManager.SpanSizeLookup getSpanSizeLookup(final int columns) { + return new GridLayoutManager.SpanSizeLookup() { + @Override + public int getSpanSize(int position) { + SectionAdapter adapter = getCurrentAdapter(); + if(adapter != null) { + int viewType = getCurrentAdapter().getItemViewType(position); + if (viewType == SectionAdapter.VIEW_TYPE_HEADER) { + return columns; + } else { + return 1; + } + } else { + return 1; + } + } + }; } public RecyclerView.ItemDecoration getItemDecoration() { return new GridSpacingDecoration(); |