aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/github
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2015-11-14 11:32:37 -0800
committerScott Jackson <daneren2005@gmail.com>2015-11-14 11:32:37 -0800
commitd0d6b87b562d350cfcac0296d973c6bb969d0c7a (patch)
tree11aa9e0754148ece0187100c919c7997f74908cd /app/src/main/java/github
parentd4d86f9f0a9a40a834ab180df249a85af0ab2a4d (diff)
downloaddsub-d0d6b87b562d350cfcac0296d973c6bb969d0c7a.tar.gz
dsub-d0d6b87b562d350cfcac0296d973c6bb969d0c7a.tar.bz2
dsub-d0d6b87b562d350cfcac0296d973c6bb969d0c7a.zip
Show lager grid for landscape tablets with only one fragment visible
Diffstat (limited to 'app/src/main/java/github')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java5
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/SearchFragment.java4
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java4
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/SelectRecyclerFragment.java15
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java16
5 files changed, 34 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() {