Fixed MainActivity fragments padding
This commit is contained in:
parent
70fd12f8bf
commit
03c0802856
5 changed files with 17 additions and 15 deletions
|
|
@ -88,6 +88,16 @@ public abstract class AbsMainActivityRecyclerViewCustomGridSizeFragment<A extend
|
||||||
return R.layout.item_list;
|
return R.layout.item_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void applyRecyclerViewPaddingForLayoutRes(@LayoutRes int res) {
|
||||||
|
int padding;
|
||||||
|
if (res == R.layout.item_grid) {
|
||||||
|
padding = (int) (getResources().getDisplayMetrics().density * 2);
|
||||||
|
} else {
|
||||||
|
padding = 0;
|
||||||
|
}
|
||||||
|
getRecyclerView().setPadding(padding, padding, padding, padding);
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract int loadGridSize();
|
protected abstract int loadGridSize();
|
||||||
|
|
||||||
protected abstract void saveGridSize(int gridColumns);
|
protected abstract void saveGridSize(int gridColumns);
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,12 @@ public class AlbumsFragment extends AbsMainActivityRecyclerViewCustomGridSizeFra
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
protected AlbumAdapter createAdapter() {
|
protected AlbumAdapter createAdapter() {
|
||||||
|
int itemLayoutRes = getItemLayoutRes();
|
||||||
|
applyRecyclerViewPaddingForLayoutRes(itemLayoutRes);
|
||||||
return new AlbumAdapter(
|
return new AlbumAdapter(
|
||||||
getMainActivity(),
|
getMainActivity(),
|
||||||
AlbumLoader.getAllAlbums(getActivity()),
|
AlbumLoader.getAllAlbums(getActivity()),
|
||||||
getItemLayoutRes(),
|
itemLayoutRes,
|
||||||
loadUsePalette(),
|
loadUsePalette(),
|
||||||
getMainActivity());
|
getMainActivity());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,12 @@ public class ArtistsFragment extends AbsMainActivityRecyclerViewCustomGridSizeFr
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
protected ArtistAdapter createAdapter() {
|
protected ArtistAdapter createAdapter() {
|
||||||
|
int itemLayoutRes = getItemLayoutRes();
|
||||||
|
applyRecyclerViewPaddingForLayoutRes(itemLayoutRes);
|
||||||
return new ArtistAdapter(
|
return new ArtistAdapter(
|
||||||
getMainActivity(),
|
getMainActivity(),
|
||||||
ArtistLoader.getAllArtists(getActivity()),
|
ArtistLoader.getAllArtists(getActivity()),
|
||||||
getItemLayoutRes(),
|
itemLayoutRes,
|
||||||
loadUsePalette(),
|
loadUsePalette(),
|
||||||
getMainActivity());
|
getMainActivity());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ public class SongsFragment extends AbsMainActivityRecyclerViewCustomGridSizeFrag
|
||||||
MainActivity mainActivity = getMainActivity();
|
MainActivity mainActivity = getMainActivity();
|
||||||
ArrayList<Song> songs = SongLoader.getAllSongs(getActivity());
|
ArrayList<Song> songs = SongLoader.getAllSongs(getActivity());
|
||||||
int itemLayoutRes = getItemLayoutRes();
|
int itemLayoutRes = getItemLayoutRes();
|
||||||
|
applyRecyclerViewPaddingForLayoutRes(itemLayoutRes);
|
||||||
boolean usePalette = loadUsePalette();
|
boolean usePalette = loadUsePalette();
|
||||||
|
|
||||||
if (getGridSize() <= getMaxGridSizeForList()) {
|
if (getGridSize() <= getMaxGridSizeForList()) {
|
||||||
|
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:id="@+id/gridview"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:columnWidth="56dp"
|
|
||||||
android:numColumns="7"
|
|
||||||
android:verticalSpacing="4dp"
|
|
||||||
android:horizontalSpacing="4dp"
|
|
||||||
android:padding="16dp"
|
|
||||||
android:clipToPadding="false"
|
|
||||||
android:stretchMode="columnWidth"
|
|
||||||
android:gravity="center" />
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue