mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 09:33:33 +00:00
feat: add preference to sort artists by album count
This commit is contained in:
parent
4c865e199d
commit
5d51132921
4 changed files with 24 additions and 1 deletions
|
|
@ -34,6 +34,7 @@ import com.cappielloantonio.tempo.interfaces.ClickCallback;
|
||||||
import com.cappielloantonio.tempo.ui.activity.MainActivity;
|
import com.cappielloantonio.tempo.ui.activity.MainActivity;
|
||||||
import com.cappielloantonio.tempo.ui.adapter.ArtistCatalogueAdapter;
|
import com.cappielloantonio.tempo.ui.adapter.ArtistCatalogueAdapter;
|
||||||
import com.cappielloantonio.tempo.util.Constants;
|
import com.cappielloantonio.tempo.util.Constants;
|
||||||
|
import com.cappielloantonio.tempo.util.Preferences;
|
||||||
import com.cappielloantonio.tempo.viewmodel.ArtistCatalogueViewModel;
|
import com.cappielloantonio.tempo.viewmodel.ArtistCatalogueViewModel;
|
||||||
import com.cappielloantonio.tempo.subsonic.models.ArtistID3;
|
import com.cappielloantonio.tempo.subsonic.models.ArtistID3;
|
||||||
|
|
||||||
|
|
@ -114,7 +115,10 @@ public class ArtistCatalogueFragment extends Fragment implements ClickCallback {
|
||||||
artistAdapter = new ArtistCatalogueAdapter(this);
|
artistAdapter = new ArtistCatalogueAdapter(this);
|
||||||
artistAdapter.setStateRestorationPolicy(RecyclerView.Adapter.StateRestorationPolicy.PREVENT_WHEN_EMPTY);
|
artistAdapter.setStateRestorationPolicy(RecyclerView.Adapter.StateRestorationPolicy.PREVENT_WHEN_EMPTY);
|
||||||
bind.artistCatalogueRecyclerView.setAdapter(artistAdapter);
|
bind.artistCatalogueRecyclerView.setAdapter(artistAdapter);
|
||||||
artistCatalogueViewModel.getArtistList().observe(getViewLifecycleOwner(), artistList -> artistAdapter.setItems(artistList));
|
artistCatalogueViewModel.getArtistList().observe(getViewLifecycleOwner(), artistList -> {
|
||||||
|
artistAdapter.setItems(artistList);
|
||||||
|
artistAdapter.sort(Preferences.getArtistSortOrder());
|
||||||
|
});
|
||||||
|
|
||||||
bind.artistCatalogueRecyclerView.setOnTouchListener((v, event) -> {
|
bind.artistCatalogueRecyclerView.setOnTouchListener((v, event) -> {
|
||||||
hideKeyboard(v);
|
hideKeyboard(v);
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,7 @@ object Preferences {
|
||||||
private const val ALBUM_DETAIL = "album_detail"
|
private const val ALBUM_DETAIL = "album_detail"
|
||||||
private const val ALBUM_SORT_ORDER = "album_sort_order"
|
private const val ALBUM_SORT_ORDER = "album_sort_order"
|
||||||
private const val DEFAULT_ALBUM_SORT_ORDER = Constants.ALBUM_ORDER_BY_NAME
|
private const val DEFAULT_ALBUM_SORT_ORDER = Constants.ALBUM_ORDER_BY_NAME
|
||||||
|
private const val ARTIST_SORT_BY_ALBUM_COUNT= "artist_sort_by_album_count"
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun getServer(): String? {
|
fun getServer(): String? {
|
||||||
|
|
@ -656,4 +657,14 @@ object Preferences {
|
||||||
fun setAlbumSortOrder(sortOrder: String) {
|
fun setAlbumSortOrder(sortOrder: String) {
|
||||||
App.getInstance().preferences.edit().putString(ALBUM_SORT_ORDER, sortOrder).apply()
|
App.getInstance().preferences.edit().putString(ALBUM_SORT_ORDER, sortOrder).apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun getArtistSortOrder(): String {
|
||||||
|
val sort_by_album_count = App.getInstance().preferences.getBoolean(ARTIST_SORT_BY_ALBUM_COUNT, false)
|
||||||
|
Log.d("Preferences", "getSortOrder")
|
||||||
|
if (sort_by_album_count)
|
||||||
|
return Constants.ARTIST_ORDER_BY_ALBUM_COUNT
|
||||||
|
else
|
||||||
|
return Constants.ARTIST_ORDER_BY_NAME
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -528,4 +528,6 @@
|
||||||
|
|
||||||
<string name="settings_album_detail">Show album detail</string>
|
<string name="settings_album_detail">Show album detail</string>
|
||||||
<string name="settings_album_detail_summary">If enabled, show the album details like genre, song count etc. on the album page</string>
|
<string name="settings_album_detail_summary">If enabled, show the album details like genre, song count etc. on the album page</string>
|
||||||
|
<string name="settings_artist_sort_by_album_count">Sort artists by album count</string>
|
||||||
|
<string name="settings_artist_sort_by_album_count_summary">If enabled, sort the artists by album count. Sort by name if disabled.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,12 @@
|
||||||
android:summary="@string/settings_album_detail_summary"
|
android:summary="@string/settings_album_detail_summary"
|
||||||
android:key="album_detail" />
|
android:key="album_detail" />
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:title="@string/settings_artist_sort_by_album_count"
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:summary="@string/settings_artist_sort_by_album_count_summary"
|
||||||
|
android:key="artist_sort_by_album_count" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory app:title="@string/settings_title_playlist">
|
<PreferenceCategory app:title="@string/settings_title_playlist">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue