From 096f97542c1f8b9baa6cc53fb2f6909f969e261f Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Fri, 22 May 2015 17:56:12 -0700 Subject: Allow more fine tuned control over LayoutManager --- .../dsub/fragments/SelectRecyclerFragment.java | 41 +++++++++++++--------- 1 file changed, 25 insertions(+), 16 deletions(-) (limited to 'app/src') diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectRecyclerFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectRecyclerFragment.java index 6fd56fd1..c19e9b28 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectRecyclerFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectRecyclerFragment.java @@ -153,26 +153,35 @@ public abstract class SelectRecyclerFragment extends SubsonicFragment { currentTask.execute(); } - public void setupLayoutManager() { + private void setupLayoutManager() { + recyclerView.setLayoutManager(getLayoutManager()); + } + public RecyclerView.LayoutManager getLayoutManager() { if(largeCells) { - final int columns = context.getResources().getInteger(R.integer.Grid_Columns); - GridLayoutManager gridLayoutManager = new GridLayoutManager(context, columns); - - GridLayoutManager.SpanSizeLookup spanSizeLookup = getSpanSizeLookup(); - if(spanSizeLookup != null) { - gridLayoutManager.setSpanSizeLookup(spanSizeLookup); - } - RecyclerView.ItemDecoration itemDecoration = getItemDecoration(); - if(itemDecoration != null) { - recyclerView.addItemDecoration(itemDecoration); - } - recyclerView.setLayoutManager(gridLayoutManager); + return getGridLayoutManager(); } else { - LinearLayoutManager layoutManager = new LinearLayoutManager(context); - layoutManager.setOrientation(LinearLayoutManager.VERTICAL); - recyclerView.setLayoutManager(layoutManager); + return getLinearLayoutManager(); } } + public GridLayoutManager getGridLayoutManager() { + final int columns = context.getResources().getInteger(R.integer.Grid_Columns); + GridLayoutManager gridLayoutManager = new GridLayoutManager(context, columns); + + GridLayoutManager.SpanSizeLookup spanSizeLookup = getSpanSizeLookup(); + if(spanSizeLookup != null) { + gridLayoutManager.setSpanSizeLookup(spanSizeLookup); + } + RecyclerView.ItemDecoration itemDecoration = getItemDecoration(); + if(itemDecoration != null) { + recyclerView.addItemDecoration(itemDecoration); + } + return gridLayoutManager; + } + public LinearLayoutManager getLinearLayoutManager() { + LinearLayoutManager layoutManager = new LinearLayoutManager(context); + layoutManager.setOrientation(LinearLayoutManager.VERTICAL); + return layoutManager; + } public GridLayoutManager.SpanSizeLookup getSpanSizeLookup() { return null; } -- cgit v1.2.3