aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2016-02-24 17:39:50 -0800
committerScott Jackson <daneren2005@gmail.com>2016-02-24 17:39:50 -0800
commit7b19f527fc24d6b1682035c25034018631202caa (patch)
tree3187413228353bfaa257f8694f933bd35e73077b /app
parentc3e7ae912506d7b1a4b46dbebe0c2c15dcb622db (diff)
downloaddsub-7b19f527fc24d6b1682035c25034018631202caa.tar.gz
dsub-7b19f527fc24d6b1682035c25034018631202caa.tar.bz2
dsub-7b19f527fc24d6b1682035c25034018631202caa.zip
Move SelectDirectoryFragment to use abstract setupLayoutManager
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java37
1 files changed, 16 insertions, 21 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
index 718ad5c5..f4f0ac30 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
@@ -190,27 +190,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Section
recyclerView.setHasFixedSize(true);
fastScroller = (FastScroller) rootView.findViewById(R.id.fragment_fast_scroller);
setupScrollList(recyclerView);
-
- if(largeAlbums) {
- GridLayoutManager gridLayoutManager = new GridLayoutManager(context, getRecyclerColumnCount());
- gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
- @Override
- public int getSpanSize(int position) {
- int viewType = entryGridAdapter.getItemViewType(position);
- if(viewType == EntryGridAdapter.VIEW_TYPE_SONG || viewType == EntryGridAdapter.VIEW_TYPE_HEADER || viewType == EntryInfiniteGridAdapter.VIEW_TYPE_LOADING) {
- return getRecyclerColumnCount();
- } else {
- return 1;
- }
- }
- });
- recyclerView.addItemDecoration(new GridSpacingDecoration());
- recyclerView.setLayoutManager(gridLayoutManager);
- } else {
- LinearLayoutManager layoutManager = new LinearLayoutManager(context);
- layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
- recyclerView.setLayoutManager(layoutManager);
- }
+ setupLayoutManager(recyclerView, largeAlbums);
if(entries == null) {
if(primaryFragment || secondaryFragment) {
@@ -693,6 +673,21 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Section
return entryGridAdapter;
}
+ @Override
+ public GridLayoutManager.SpanSizeLookup getSpanSizeLookup(final GridLayoutManager gridLayoutManager) {
+ return new GridLayoutManager.SpanSizeLookup() {
+ @Override
+ public int getSpanSize(int position) {
+ int viewType = entryGridAdapter.getItemViewType(position);
+ if(viewType == EntryGridAdapter.VIEW_TYPE_SONG || viewType == EntryGridAdapter.VIEW_TYPE_HEADER || viewType == EntryInfiniteGridAdapter.VIEW_TYPE_LOADING) {
+ return gridLayoutManager.getSpanCount();
+ } else {
+ return 1;
+ }
+ }
+ };
+ }
+
private void finishLoading() {
boolean validData = !entries.isEmpty() || !albums.isEmpty();
if(!validData) {