aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/SearchFragment.java3
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java21
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();