mirror of
https://github.com/CappielloAntonio/tempo.git
synced 2026-02-02 15:33:36 +00:00
feat: implemented last set filter as default grouping for downloaded tracks
This commit is contained in:
@@ -27,6 +27,7 @@ import com.cappielloantonio.tempo.subsonic.models.Child;
|
||||
import com.cappielloantonio.tempo.ui.activity.MainActivity;
|
||||
import com.cappielloantonio.tempo.ui.adapter.DownloadHorizontalAdapter;
|
||||
import com.cappielloantonio.tempo.util.Constants;
|
||||
import com.cappielloantonio.tempo.util.Preferences;
|
||||
import com.cappielloantonio.tempo.viewmodel.DownloadViewModel;
|
||||
import com.google.android.material.appbar.MaterialToolbar;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
@@ -169,18 +170,23 @@ public class DownloadFragment extends Fragment implements ClickCallback {
|
||||
popup.setOnMenuItemClickListener(menuItem -> {
|
||||
if (menuItem.getItemId() == R.id.menu_download_group_by_track) {
|
||||
downloadViewModel.initViewStack(new DownloadStack(Constants.DOWNLOAD_TYPE_TRACK, null));
|
||||
Preferences.setDefaultDownloadViewType(Constants.DOWNLOAD_TYPE_TRACK);
|
||||
return true;
|
||||
} else if (menuItem.getItemId() == R.id.menu_download_group_by_album) {
|
||||
downloadViewModel.initViewStack(new DownloadStack(Constants.DOWNLOAD_TYPE_ALBUM, null));
|
||||
Preferences.setDefaultDownloadViewType(Constants.DOWNLOAD_TYPE_ALBUM);
|
||||
return true;
|
||||
} else if (menuItem.getItemId() == R.id.menu_download_group_by_artist) {
|
||||
downloadViewModel.initViewStack(new DownloadStack(Constants.DOWNLOAD_TYPE_ARTIST, null));
|
||||
Preferences.setDefaultDownloadViewType(Constants.DOWNLOAD_TYPE_ARTIST);
|
||||
return true;
|
||||
} else if (menuItem.getItemId() == R.id.menu_download_group_by_genre) {
|
||||
downloadViewModel.initViewStack(new DownloadStack(Constants.DOWNLOAD_TYPE_GENRE, null));
|
||||
Preferences.setDefaultDownloadViewType(Constants.DOWNLOAD_TYPE_GENRE);
|
||||
return true;
|
||||
} else if (menuItem.getItemId() == R.id.menu_download_group_by_year) {
|
||||
downloadViewModel.initViewStack(new DownloadStack(Constants.DOWNLOAD_TYPE_YEAR, null));
|
||||
Preferences.setDefaultDownloadViewType(Constants.DOWNLOAD_TYPE_YEAR);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ object Preferences {
|
||||
private const val REPLAY_GAIN_MODE = "replay_gain_mode"
|
||||
private const val AUDIO_TRANSCODE_PRIORITY = "audio_transcode_priority"
|
||||
private const val DOWNLOAD_STORAGE = "download_storage"
|
||||
private const val DEFAULT_DOWNLOAD_VIEW_TYPE = "default_download_view_type"
|
||||
|
||||
@JvmStatic
|
||||
fun getServer(): String? {
|
||||
@@ -272,4 +273,20 @@ object Preferences {
|
||||
storagePreference.toString()
|
||||
).apply()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getDefaultDownloadViewType(): String {
|
||||
return App.getInstance().preferences.getString(
|
||||
DEFAULT_DOWNLOAD_VIEW_TYPE,
|
||||
Constants.DOWNLOAD_TYPE_TRACK
|
||||
)!!
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun setDefaultDownloadViewType(viewType: String) {
|
||||
return App.getInstance().preferences.edit().putString(
|
||||
DEFAULT_DOWNLOAD_VIEW_TYPE,
|
||||
viewType
|
||||
).apply()
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import com.cappielloantonio.tempo.model.DownloadStack;
|
||||
import com.cappielloantonio.tempo.repository.DownloadRepository;
|
||||
import com.cappielloantonio.tempo.subsonic.models.Child;
|
||||
import com.cappielloantonio.tempo.util.Constants;
|
||||
import com.cappielloantonio.tempo.util.Preferences;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -30,7 +31,7 @@ public class DownloadViewModel extends AndroidViewModel {
|
||||
|
||||
downloadRepository = new DownloadRepository();
|
||||
|
||||
initViewStack(new DownloadStack(Constants.DOWNLOAD_TYPE_TRACK, null));
|
||||
initViewStack(new DownloadStack(Preferences.getDefaultDownloadViewType(), null));
|
||||
}
|
||||
|
||||
public LiveData<List<Child>> getDownloadedTracks(LifecycleOwner owner) {
|
||||
|
||||
Reference in New Issue
Block a user