add sort method for artists
This commit is contained in:
parent
56298b08c3
commit
bd6bdfb7ea
3 changed files with 35 additions and 24 deletions
|
|
@ -184,14 +184,8 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
|
||||||
menu.findItem(R.id.action_colored_footers).setChecked(absLibraryRecyclerViewCustomGridSizeFragment.usePalette());
|
menu.findItem(R.id.action_colored_footers).setChecked(absLibraryRecyclerViewCustomGridSizeFragment.usePalette());
|
||||||
menu.findItem(R.id.action_colored_footers).setEnabled(absLibraryRecyclerViewCustomGridSizeFragment.canUsePalette());
|
menu.findItem(R.id.action_colored_footers).setEnabled(absLibraryRecyclerViewCustomGridSizeFragment.canUsePalette());
|
||||||
|
|
||||||
// TODO the API doesn't support artist sorting
|
setUpSortMethodMenu(absLibraryRecyclerViewCustomGridSizeFragment, menu.findItem(R.id.action_sort_method).getSubMenu());
|
||||||
if (currentFragment instanceof ArtistsFragment) {
|
setUpSortOrderMenu(absLibraryRecyclerViewCustomGridSizeFragment, menu.findItem(R.id.action_sort_order).getSubMenu());
|
||||||
menu.removeItem(R.id.action_sort_method);
|
|
||||||
menu.removeItem(R.id.action_sort_order);
|
|
||||||
} else {
|
|
||||||
setUpSortMethodMenu(absLibraryRecyclerViewCustomGridSizeFragment, menu.findItem(R.id.action_sort_method).getSubMenu());
|
|
||||||
setUpSortOrderMenu(absLibraryRecyclerViewCustomGridSizeFragment, menu.findItem(R.id.action_sort_order).getSubMenu());
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
menu.removeItem(R.id.action_grid_size);
|
menu.removeItem(R.id.action_grid_size);
|
||||||
menu.removeItem(R.id.action_colored_footers);
|
menu.removeItem(R.id.action_colored_footers);
|
||||||
|
|
@ -344,32 +338,28 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
|
||||||
SortMethod currentSortMethod = fragment.getSortMethod();
|
SortMethod currentSortMethod = fragment.getSortMethod();
|
||||||
sortMethodMenu.clear();
|
sortMethodMenu.clear();
|
||||||
|
|
||||||
|
sortMethodMenu.add(0, R.id.action_sort_method_name, 0, R.string.sort_method_name)
|
||||||
|
.setChecked(currentSortMethod.equals(SortMethod.NAME));
|
||||||
|
|
||||||
if (fragment instanceof AlbumsFragment) {
|
if (fragment instanceof AlbumsFragment) {
|
||||||
sortMethodMenu.add(0, R.id.action_sort_method_name, 0, R.string.sort_method_name)
|
|
||||||
.setChecked(currentSortMethod.equals(SortMethod.NAME));
|
|
||||||
sortMethodMenu.add(0, R.id.action_sort_method_artist, 1, R.string.sort_method_artist)
|
sortMethodMenu.add(0, R.id.action_sort_method_artist, 1, R.string.sort_method_artist)
|
||||||
.setChecked(currentSortMethod.equals(SortMethod.ARTIST));
|
.setChecked(currentSortMethod.equals(SortMethod.ARTIST));
|
||||||
sortMethodMenu.add(0, R.id.action_sort_method_year, 2, R.string.sort_method_year)
|
sortMethodMenu.add(0, R.id.action_sort_method_year, 2, R.string.sort_method_year)
|
||||||
.setChecked(currentSortMethod.equals(SortMethod.YEAR));
|
.setChecked(currentSortMethod.equals(SortMethod.YEAR));
|
||||||
sortMethodMenu.add(0, R.id.action_sort_method_added, 3, R.string.sort_method_added)
|
|
||||||
.setChecked(currentSortMethod.equals(SortMethod.ADDED));
|
|
||||||
sortMethodMenu.add(0, R.id.action_sort_method_random, 4, R.string.sort_method_random)
|
|
||||||
.setChecked(currentSortMethod.equals(SortMethod.RANDOM));
|
|
||||||
} else if (fragment instanceof SongsFragment) {
|
} else if (fragment instanceof SongsFragment) {
|
||||||
sortMethodMenu.add(0, R.id.action_sort_method_name, 0, R.string.sort_method_name)
|
|
||||||
.setChecked(currentSortMethod.equals(SortMethod.NAME));
|
|
||||||
sortMethodMenu.add(0, R.id.action_sort_method_album, 1, R.string.sort_method_album)
|
sortMethodMenu.add(0, R.id.action_sort_method_album, 1, R.string.sort_method_album)
|
||||||
.setChecked(currentSortMethod.equals(SortMethod.ALBUM));
|
.setChecked(currentSortMethod.equals(SortMethod.ALBUM));
|
||||||
sortMethodMenu.add(0, R.id.action_sort_method_artist, 2, R.string.sort_method_artist)
|
sortMethodMenu.add(0, R.id.action_sort_method_artist, 2, R.string.sort_method_artist)
|
||||||
.setChecked(currentSortMethod.equals(SortMethod.ARTIST));
|
.setChecked(currentSortMethod.equals(SortMethod.ARTIST));
|
||||||
sortMethodMenu.add(0, R.id.action_sort_method_year, 3, R.string.sort_method_year)
|
sortMethodMenu.add(0, R.id.action_sort_method_year, 3, R.string.sort_method_year)
|
||||||
.setChecked(currentSortMethod.equals(SortMethod.YEAR));
|
.setChecked(currentSortMethod.equals(SortMethod.YEAR));
|
||||||
sortMethodMenu.add(0, R.id.action_sort_method_added, 4, R.string.sort_method_added)
|
|
||||||
.setChecked(currentSortMethod.equals(SortMethod.ADDED));
|
|
||||||
sortMethodMenu.add(0, R.id.action_sort_method_random, 5, R.string.sort_method_random)
|
|
||||||
.setChecked(currentSortMethod.equals(SortMethod.RANDOM));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sortMethodMenu.add(0, R.id.action_sort_method_added, 4, R.string.sort_method_added)
|
||||||
|
.setChecked(currentSortMethod.equals(SortMethod.ADDED));
|
||||||
|
sortMethodMenu.add(0, R.id.action_sort_method_random, 5, R.string.sort_method_random)
|
||||||
|
.setChecked(currentSortMethod.equals(SortMethod.RANDOM));
|
||||||
|
|
||||||
sortMethodMenu.setGroupCheckable(0, true, true);
|
sortMethodMenu.setGroupCheckable(0, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,9 @@ public class ArtistsFragment extends AbsLibraryPagerRecyclerViewCustomGridSizeFr
|
||||||
query.setStartIndex(getAdapter().getItemCount());
|
query.setStartIndex(getAdapter().getItemCount());
|
||||||
query.setParentId(QueryUtil.currentLibrary.getId());
|
query.setParentId(QueryUtil.currentLibrary.getId());
|
||||||
|
|
||||||
|
query.setSortBy(new String[]{PreferenceUtil.getInstance(App.getInstance()).getArtistSortMethod().getApi()});
|
||||||
|
query.setSortOrder(PreferenceUtil.getInstance(App.getInstance()).getArtistSortOrder().getApi());
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -95,12 +98,12 @@ public class ArtistsFragment extends AbsLibraryPagerRecyclerViewCustomGridSizeFr
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SortMethod loadSortMethod() {
|
protected SortMethod loadSortMethod() {
|
||||||
return SortMethod.NAME;
|
return PreferenceUtil.getInstance(getActivity()).getArtistSortMethod();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void saveSortMethod(SortMethod sortMethod) {
|
protected void saveSortMethod(SortMethod sortMethod) {
|
||||||
// not supported through API
|
PreferenceUtil.getInstance(getActivity()).setArtistSortMethod(sortMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -109,12 +112,12 @@ public class ArtistsFragment extends AbsLibraryPagerRecyclerViewCustomGridSizeFr
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SortOrder loadSortOrder() {
|
protected SortOrder loadSortOrder() {
|
||||||
return SortOrder.ASCENDING;
|
return PreferenceUtil.getInstance(getActivity()).getArtistSortOrder();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void saveSortOrder(SortOrder sortOrder) {
|
protected void saveSortOrder(SortOrder sortOrder) {
|
||||||
// not supported through API
|
PreferenceUtil.getInstance(getActivity()).setArtistSortOrder(sortOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -43,9 +43,11 @@ public final class PreferenceUtil {
|
||||||
|
|
||||||
public static final String ALBUM_SORT_METHOD = "album_sort_method";
|
public static final String ALBUM_SORT_METHOD = "album_sort_method";
|
||||||
public static final String SONG_SORT_METHOD = "song_sort_method";
|
public static final String SONG_SORT_METHOD = "song_sort_method";
|
||||||
|
public static final String ARTIST_SORT_METHOD = "artist_sort_method";
|
||||||
|
|
||||||
public static final String ALBUM_SORT_ORDER = "album_sort_order";
|
public static final String ALBUM_SORT_ORDER = "album_sort_order";
|
||||||
public static final String SONG_SORT_ORDER = "song_sort_order";
|
public static final String SONG_SORT_ORDER = "song_sort_order";
|
||||||
|
public static final String ARTIST_SORT_ORDER = "artist_sort_order";
|
||||||
|
|
||||||
public static final String ALBUM_GRID_SIZE = "album_grid_size";
|
public static final String ALBUM_GRID_SIZE = "album_grid_size";
|
||||||
public static final String ALBUM_GRID_SIZE_LAND = "album_grid_size_land";
|
public static final String ALBUM_GRID_SIZE_LAND = "album_grid_size_land";
|
||||||
|
|
@ -271,6 +273,14 @@ public final class PreferenceUtil {
|
||||||
mPreferences.edit().putString(SONG_SORT_ORDER, sortOrder.toString()).apply();
|
mPreferences.edit().putString(SONG_SORT_ORDER, sortOrder.toString()).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final SortOrder getArtistSortOrder() {
|
||||||
|
return SortOrder.valueOf(mPreferences.getString(ARTIST_SORT_ORDER, SortOrder.ASCENDING.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArtistSortOrder(SortOrder sortOrder) {
|
||||||
|
mPreferences.edit().putString(ARTIST_SORT_ORDER, sortOrder.toString()).apply();
|
||||||
|
}
|
||||||
|
|
||||||
public final SortMethod getAlbumSortMethod() {
|
public final SortMethod getAlbumSortMethod() {
|
||||||
return SortMethod.valueOf(mPreferences.getString(ALBUM_SORT_METHOD, SortMethod.RANDOM.toString()));
|
return SortMethod.valueOf(mPreferences.getString(ALBUM_SORT_METHOD, SortMethod.RANDOM.toString()));
|
||||||
}
|
}
|
||||||
|
|
@ -287,6 +297,14 @@ public final class PreferenceUtil {
|
||||||
mPreferences.edit().putString(SONG_SORT_METHOD, sortMethod.toString()).apply();
|
mPreferences.edit().putString(SONG_SORT_METHOD, sortMethod.toString()).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final SortMethod getArtistSortMethod() {
|
||||||
|
return SortMethod.valueOf(mPreferences.getString(ARTIST_SORT_METHOD, SortMethod.NAME.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArtistSortMethod(SortMethod sortMethod) {
|
||||||
|
mPreferences.edit().putString(ARTIST_SORT_METHOD, sortMethod.toString()).apply();
|
||||||
|
}
|
||||||
|
|
||||||
public int getLastSleepTimerValue() {
|
public int getLastSleepTimerValue() {
|
||||||
return mPreferences.getInt(SLEEP_TIMER_LAST_VALUE, 30);
|
return mPreferences.getInt(SLEEP_TIMER_LAST_VALUE, 30);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue