disable artist sort for now
This commit is contained in:
parent
78c93786db
commit
354c2f5885
5 changed files with 20 additions and 96 deletions
|
|
@ -178,16 +178,7 @@ public class ArtistAdapter extends AbsMultiSelectAdapter<ArtistAdapter.ViewHolde
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public String getSectionName(int position) {
|
public String getSectionName(int position) {
|
||||||
@Nullable String sectionName = null;
|
return MusicUtil.getSectionName(dataSet.get(position).getName());
|
||||||
switch (PreferenceUtil.getInstance(activity).getArtistSortMethod()) {
|
|
||||||
case SortMethod.NAME:
|
|
||||||
sectionName = dataSet.get(position).getName();
|
|
||||||
break;
|
|
||||||
case SortMethod.RANDOM:
|
|
||||||
return activity.getResources().getString(R.string.random);
|
|
||||||
}
|
|
||||||
|
|
||||||
return MusicUtil.getSectionName(sectionName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ViewHolder extends MediaEntryViewHolder {
|
public class ViewHolder extends MediaEntryViewHolder {
|
||||||
|
|
|
||||||
|
|
@ -166,6 +166,7 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
|
||||||
.setCloseDrawableRes(R.drawable.ic_close_white_24dp)
|
.setCloseDrawableRes(R.drawable.ic_close_white_24dp)
|
||||||
.setBackgroundColor(ThemeUtil.shiftBackgroundColorForLightText(ThemeStore.primaryColor(getActivity())))
|
.setBackgroundColor(ThemeUtil.shiftBackgroundColorForLightText(ThemeStore.primaryColor(getActivity())))
|
||||||
.start(callback);
|
.start(callback);
|
||||||
|
|
||||||
return cab;
|
return cab;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -203,8 +204,14 @@ 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());
|
||||||
|
|
||||||
setUpSortMethodMenu(absLibraryRecyclerViewCustomGridSizeFragment, menu.findItem(R.id.action_sort_method).getSubMenu());
|
// TODO the API doesn't support artist sorting
|
||||||
setUpSortOrderMenu(absLibraryRecyclerViewCustomGridSizeFragment, menu.findItem(R.id.action_sort_order).getSubMenu());
|
if (currentFragment instanceof ArtistsFragment) {
|
||||||
|
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);
|
||||||
|
|
@ -362,11 +369,6 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
|
||||||
.setChecked(currentSortMethod.equals(SortMethod.YEAR));
|
.setChecked(currentSortMethod.equals(SortMethod.YEAR));
|
||||||
sortMethodMenu.add(0, R.id.action_sort_method_random, 3, R.string.sort_order_random)
|
sortMethodMenu.add(0, R.id.action_sort_method_random, 3, R.string.sort_order_random)
|
||||||
.setChecked(currentSortMethod.equals(SortMethod.RANDOM));
|
.setChecked(currentSortMethod.equals(SortMethod.RANDOM));
|
||||||
} else if (fragment instanceof ArtistsFragment) {
|
|
||||||
sortMethodMenu.add(0, R.id.action_sort_method_name, 0, R.string.sort_order_name)
|
|
||||||
.setChecked(currentSortMethod.equals(SortMethod.NAME));
|
|
||||||
sortMethodMenu.add(0, R.id.action_sort_method_random, 1, R.string.sort_order_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_order_name)
|
sortMethodMenu.add(0, R.id.action_sort_method_name, 0, R.string.sort_order_name)
|
||||||
.setChecked(currentSortMethod.equals(SortMethod.NAME));
|
.setChecked(currentSortMethod.equals(SortMethod.NAME));
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import androidx.recyclerview.widget.GridLayoutManager;
|
||||||
|
|
||||||
import com.kabouzeid.gramophone.R;
|
import com.kabouzeid.gramophone.R;
|
||||||
import com.kabouzeid.gramophone.adapter.artist.ArtistAdapter;
|
import com.kabouzeid.gramophone.adapter.artist.ArtistAdapter;
|
||||||
|
import com.kabouzeid.gramophone.helper.sort.SortMethod;
|
||||||
import com.kabouzeid.gramophone.interfaces.MediaCallback;
|
import com.kabouzeid.gramophone.interfaces.MediaCallback;
|
||||||
import com.kabouzeid.gramophone.model.Artist;
|
import com.kabouzeid.gramophone.model.Artist;
|
||||||
import com.kabouzeid.gramophone.util.PreferenceUtil;
|
import com.kabouzeid.gramophone.util.PreferenceUtil;
|
||||||
|
|
@ -60,12 +61,12 @@ public class ArtistsFragment extends AbsLibraryPagerRecyclerViewCustomGridSizeFr
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String loadSortMethod() {
|
protected String loadSortMethod() {
|
||||||
return PreferenceUtil.getInstance(getActivity()).getArtistSortMethod();
|
return SortMethod.NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void saveSortMethod(String sortMethod) {
|
protected void saveSortMethod(String sortMethod) {
|
||||||
PreferenceUtil.getInstance(getActivity()).setArtistSortMethod(sortMethod);
|
// not supported through API
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -26,11 +26,9 @@ public final class PreferenceUtil {
|
||||||
|
|
||||||
public static final String NOW_PLAYING_SCREEN = "now_playing_screen";
|
public static final String NOW_PLAYING_SCREEN = "now_playing_screen";
|
||||||
|
|
||||||
public static final String ARTIST_SORT_METHOD = "artist_sort_method";
|
|
||||||
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_ORDER = "artist_sort_order";
|
|
||||||
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";
|
||||||
|
|
||||||
|
|
@ -61,8 +59,8 @@ public final class PreferenceUtil {
|
||||||
public static final String SHOW_ALBUM_COVER = "show_album_cover";
|
public static final String SHOW_ALBUM_COVER = "show_album_cover";
|
||||||
public static final String BLUR_ALBUM_COVER = "blur_album_cover";
|
public static final String BLUR_ALBUM_COVER = "blur_album_cover";
|
||||||
|
|
||||||
public static final String LAST_SLEEP_TIMER_VALUE = "last_sleep_timer_value";
|
public static final String SLEEP_TIMER_LAST_VALUE = "sleep_timer_last_value";
|
||||||
public static final String NEXT_SLEEP_TIMER_ELAPSED_REALTIME = "next_sleep_timer_elapsed_real_time";
|
public static final String SLEEP_TIMER_ELAPSED_REALTIME = "sleep_timer_elapsed_real_time";
|
||||||
public static final String SLEEP_TIMER_FINISH_SONG = "sleep_timer_finish_music";
|
public static final String SLEEP_TIMER_FINISH_SONG = "sleep_timer_finish_music";
|
||||||
|
|
||||||
private static PreferenceUtil sInstance;
|
private static PreferenceUtil sInstance;
|
||||||
|
|
@ -186,16 +184,6 @@ public final class PreferenceUtil {
|
||||||
return mPreferences.getBoolean(BLUR_ALBUM_COVER, true);
|
return mPreferences.getBoolean(BLUR_ALBUM_COVER, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String getArtistSortOrder() {
|
|
||||||
return mPreferences.getString(ARTIST_SORT_ORDER, SortOrder.DESCENDING);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setArtistSortOrder(final String sortOrder) {
|
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
|
||||||
editor.putString(ARTIST_SORT_ORDER, sortOrder);
|
|
||||||
editor.commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final String getAlbumSortOrder() {
|
public final String getAlbumSortOrder() {
|
||||||
return mPreferences.getString(ALBUM_SORT_ORDER, SortOrder.DESCENDING);
|
return mPreferences.getString(ALBUM_SORT_ORDER, SortOrder.DESCENDING);
|
||||||
}
|
}
|
||||||
|
|
@ -216,16 +204,6 @@ public final class PreferenceUtil {
|
||||||
editor.commit();
|
editor.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String getArtistSortMethod() {
|
|
||||||
return mPreferences.getString(ARTIST_SORT_METHOD, SortMethod.NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setArtistSortMethod(final String sortMethod) {
|
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
|
||||||
editor.putString(ARTIST_SORT_METHOD, sortMethod);
|
|
||||||
editor.commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final String getAlbumSortMethod() {
|
public final String getAlbumSortMethod() {
|
||||||
return mPreferences.getString(ALBUM_SORT_METHOD, SortMethod.NAME);
|
return mPreferences.getString(ALBUM_SORT_METHOD, SortMethod.NAME);
|
||||||
}
|
}
|
||||||
|
|
@ -247,22 +225,22 @@ public final class PreferenceUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLastSleepTimerValue() {
|
public int getLastSleepTimerValue() {
|
||||||
return mPreferences.getInt(LAST_SLEEP_TIMER_VALUE, 30);
|
return mPreferences.getInt(SLEEP_TIMER_LAST_VALUE, 30);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLastSleepTimerValue(final int value) {
|
public void setLastSleepTimerValue(final int value) {
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||||
editor.putInt(LAST_SLEEP_TIMER_VALUE, value);
|
editor.putInt(SLEEP_TIMER_LAST_VALUE, value);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getNextSleepTimerElapsedRealTime() {
|
public long getNextSleepTimerElapsedRealTime() {
|
||||||
return mPreferences.getLong(NEXT_SLEEP_TIMER_ELAPSED_REALTIME, -1);
|
return mPreferences.getLong(SLEEP_TIMER_ELAPSED_REALTIME, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNextSleepTimerElapsedRealtime(final long value) {
|
public void setNextSleepTimerElapsedRealtime(final long value) {
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||||
editor.putLong(NEXT_SLEEP_TIMER_ELAPSED_REALTIME, value);
|
editor.putLong(SLEEP_TIMER_ELAPSED_REALTIME, value);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -148,29 +148,12 @@ public class QueryUtil {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void getAlbum(String id, MediaCallback callback) {
|
|
||||||
App.getApiClient().GetItemAsync(id, App.getApiClient().getCurrentUserId(), new Response<BaseItemDto>() {
|
|
||||||
@Override
|
|
||||||
public void onResponse(BaseItemDto itemDto) {
|
|
||||||
List<Album> albums = new ArrayList<>();
|
|
||||||
albums.add(new Album(itemDto));
|
|
||||||
callback.onLoadMedia(albums);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(Exception exception) {
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void getArtists(MediaCallback callback) {
|
public static void getArtists(MediaCallback callback) {
|
||||||
ArtistsQuery query = new ArtistsQuery();
|
ArtistsQuery query = new ArtistsQuery();
|
||||||
query.setFields(new ItemFields[]{ItemFields.Genres});
|
query.setFields(new ItemFields[]{ItemFields.Genres});
|
||||||
query.setUserId(App.getApiClient().getCurrentUserId());
|
query.setUserId(App.getApiClient().getCurrentUserId());
|
||||||
query.setLimit(100);
|
query.setLimit(100);
|
||||||
query.setRecursive(true);
|
query.setRecursive(true);
|
||||||
applySortMethod(query, PreferenceUtil.getInstance(App.getInstance()).getArtistSortMethod());
|
|
||||||
if (currentLibrary != null && query.getParentId() == null) query.setParentId(currentLibrary.getId());
|
if (currentLibrary != null && query.getParentId() == null) query.setParentId(currentLibrary.getId());
|
||||||
App.getApiClient().GetAlbumArtistsAsync(query, new Response<ItemsResult>() {
|
App.getApiClient().GetAlbumArtistsAsync(query, new Response<ItemsResult>() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -190,22 +173,6 @@ public class QueryUtil {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void getArtist(String id, MediaCallback callback) {
|
|
||||||
App.getApiClient().GetItemAsync(id, App.getApiClient().getCurrentUserId(), new Response<BaseItemDto>() {
|
|
||||||
@Override
|
|
||||||
public void onResponse(BaseItemDto itemDto) {
|
|
||||||
List<Artist> artists = new ArrayList<>();
|
|
||||||
artists.add(new Artist(itemDto));
|
|
||||||
callback.onLoadMedia(artists);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(Exception exception) {
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void getSongs(ItemQuery query, MediaCallback callback) {
|
public static void getSongs(ItemQuery query, MediaCallback callback) {
|
||||||
query.setIncludeItemTypes(new String[]{"Audio"});
|
query.setIncludeItemTypes(new String[]{"Audio"});
|
||||||
query.setUserId(App.getApiClient().getCurrentUserId());
|
query.setUserId(App.getApiClient().getCurrentUserId());
|
||||||
|
|
@ -231,7 +198,7 @@ public class QueryUtil {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemQuery applySortMethod(ItemQuery query, String method) {
|
private static void applySortMethod(ItemQuery query, String method) {
|
||||||
switch (method) {
|
switch (method) {
|
||||||
case SortMethod.NAME:
|
case SortMethod.NAME:
|
||||||
query.setSortBy(new String[]{"SortName"});
|
query.setSortBy(new String[]{"SortName"});
|
||||||
|
|
@ -249,20 +216,5 @@ public class QueryUtil {
|
||||||
query.setSortBy(new String[]{"Random"});
|
query.setSortBy(new String[]{"Random"});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ArtistsQuery applySortMethod(ArtistsQuery query, String method) {
|
|
||||||
switch (method) {
|
|
||||||
case SortMethod.NAME:
|
|
||||||
query.setSortBy(new String[]{"SortName"});
|
|
||||||
break;
|
|
||||||
case SortMethod.RANDOM:
|
|
||||||
query.setSortBy(new String[]{"Random"});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return query;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue