diff options
Diffstat (limited to 'app/src')
8 files changed, 43 insertions, 10 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java index e055983e..e190e4c1 100644 --- a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java +++ b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java @@ -745,6 +745,9 @@ public class SubsonicActivity extends AppCompatActivity implements OnItemSelecte // Commit it all trans.commit(); + + oldFragment.setIsOnlyVisible(false); + currentFragment.setIsOnlyVisible(false); } recreateSpinner(); } @@ -791,6 +794,8 @@ public class SubsonicActivity extends AppCompatActivity implements OnItemSelecte } else { secondaryContainer.startAnimation(AnimationUtils.loadAnimation(this, R.anim.exit_to_right)); secondaryContainer.setVisibility(View.GONE); + + currentFragment.setIsOnlyVisible(true); } trans.commit(); 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 4e1fbdca..b19ededa 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SearchFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SearchFragment.java @@ -90,13 +90,13 @@ public class SearchFragment extends SubsonicFragment implements SectionAdapter.O } @Override - public GridLayoutManager.SpanSizeLookup getSpanSizeLookup(final int columns) { + public GridLayoutManager.SpanSizeLookup getSpanSizeLookup() { return new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int position) { int viewType = adapter.getItemViewType(position); if(viewType == EntryGridAdapter.VIEW_TYPE_SONG || viewType == EntryGridAdapter.VIEW_TYPE_HEADER || viewType == ArtistAdapter.VIEW_TYPE_ARTIST) { - return columns; + return getRecyclerColumnCount(); } else { return 1; } diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java index bdb1e550..3f8f7844 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java @@ -251,7 +251,7 @@ public class SelectPodcastsFragment extends SelectRecyclerFragment<Serializable> } @Override - public GridLayoutManager.SpanSizeLookup getSpanSizeLookup(final int columns) { + public GridLayoutManager.SpanSizeLookup getSpanSizeLookup() { return new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int position) { @@ -259,7 +259,7 @@ public class SelectPodcastsFragment extends SelectRecyclerFragment<Serializable> if(adapter != null) { int viewType = getCurrentAdapter().getItemViewType(position); if (viewType == SectionAdapter.VIEW_TYPE_HEADER || viewType == PodcastChannelAdapter.VIEW_TYPE_PODCAST_EPISODE || viewType == PodcastChannelAdapter.VIEW_TYPE_PODCAST_LEGACY) { - return columns; + return getRecyclerColumnCount(); } else { return 1; } 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 84011480..7ae7fff8 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectRecyclerFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectRecyclerFragment.java @@ -17,6 +17,7 @@ package github.daneren2005.dsub.fragments; import android.os.Bundle; import android.support.v4.widget.SwipeRefreshLayout; +import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.RecyclerView; import android.util.Log; import android.view.LayoutInflater; @@ -48,7 +49,6 @@ public abstract class SelectRecyclerFragment<T> extends SubsonicFragment impleme protected List<T> objects; protected boolean serialize = true; protected boolean largeAlbums = false; - protected int columns; protected boolean pullToRefresh = true; protected boolean backgroundUpdate = true; @@ -59,7 +59,6 @@ public abstract class SelectRecyclerFragment<T> extends SubsonicFragment impleme if(bundle != null && serialize) { objects = (List<T>) bundle.getSerializable(Constants.FRAGMENT_LIST); } - columns = context.getResources().getInteger(R.integer.Grid_Columns); } @Override @@ -111,6 +110,18 @@ public abstract class SelectRecyclerFragment<T> extends SubsonicFragment impleme } @Override + public void setIsOnlyVisible(boolean isOnlyVisible) { + boolean update = this.isOnlyVisible != isOnlyVisible; + super.setIsOnlyVisible(isOnlyVisible); + if(update && adapter != null) { + RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager(); + if(layoutManager instanceof GridLayoutManager) { + ((GridLayoutManager) layoutManager).setSpanCount(getRecyclerColumnCount()); + } + } + } + + @Override protected void refresh(final boolean refresh) { int titleRes = getTitleResource(); if(titleRes != 0) { 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 e7685ed4..956597a4 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java @@ -113,6 +113,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR protected View rootView; protected boolean primaryFragment = false; protected boolean secondaryFragment = false; + protected boolean isOnlyVisible = true; protected boolean invalidated = false; protected static Random random = new Random(); protected GestureDetector gestureScanner; @@ -476,6 +477,9 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR public void setSecondaryFragment(boolean secondary) { secondaryFragment = secondary; } + public void setIsOnlyVisible(boolean isOnlyVisible) { + this.isOnlyVisible = isOnlyVisible; + } public void invalidate() { if(primaryFragment) { @@ -632,7 +636,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR final int columns = getRecyclerColumnCount(); GridLayoutManager gridLayoutManager = new GridLayoutManager(context, columns); - GridLayoutManager.SpanSizeLookup spanSizeLookup = getSpanSizeLookup(columns); + GridLayoutManager.SpanSizeLookup spanSizeLookup = getSpanSizeLookup(); if(spanSizeLookup != null) { gridLayoutManager.setSpanSizeLookup(spanSizeLookup); } @@ -647,7 +651,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR layoutManager.setOrientation(LinearLayoutManager.VERTICAL); return layoutManager; } - public GridLayoutManager.SpanSizeLookup getSpanSizeLookup(final int columns) { + public GridLayoutManager.SpanSizeLookup getSpanSizeLookup() { return new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int position) { @@ -655,7 +659,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR if(adapter != null) { int viewType = getCurrentAdapter().getItemViewType(position); if (viewType == SectionAdapter.VIEW_TYPE_HEADER) { - return columns; + return getRecyclerColumnCount(); } else { return 1; } @@ -669,7 +673,11 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR return new GridSpacingDecoration(); } public int getRecyclerColumnCount() { - return context.getResources().getInteger(R.integer.Grid_Columns); + if(isOnlyVisible) { + return context.getResources().getInteger(R.integer.Grid_FullScreen_Columns); + } else { + return context.getResources().getInteger(R.integer.Grid_Columns); + } } protected void warnIfStorageUnavailable() { diff --git a/app/src/main/res/values-large-land/integers.xml b/app/src/main/res/values-large-land/integers.xml new file mode 100644 index 00000000..b9736063 --- /dev/null +++ b/app/src/main/res/values-large-land/integers.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <integer name="Grid.FullScreen.Columns">4</integer> +</resources>
\ No newline at end of file diff --git a/app/src/main/res/values-xlarge-land/integers.xml b/app/src/main/res/values-xlarge-land/integers.xml new file mode 100644 index 00000000..acfc72ff --- /dev/null +++ b/app/src/main/res/values-xlarge-land/integers.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <integer name="Grid.FullScreen.Columns">5</integer> +</resources>
\ No newline at end of file diff --git a/app/src/main/res/values/integers.xml b/app/src/main/res/values/integers.xml index 57371a11..05bcdb28 100644 --- a/app/src/main/res/values/integers.xml +++ b/app/src/main/res/values/integers.xml @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <resources> <integer name="Grid.Columns">2</integer> + <integer name="Grid.FullScreen.Columns">@integer/Grid.Columns</integer> <integer name="TextDescriptionLength">5</integer> </resources>
\ No newline at end of file |