mirror of
https://github.com/CappielloAntonio/tempo.git
synced 2026-02-01 15:03:37 +00:00
Adapters refactoring
This commit is contained in:
@@ -7,16 +7,13 @@ import androidx.lifecycle.AndroidViewModel;
|
||||
import androidx.lifecycle.LiveData;
|
||||
|
||||
import com.cappielloantonio.play.model.Album;
|
||||
import com.cappielloantonio.play.model.Artist;
|
||||
import com.cappielloantonio.play.repository.AlbumRepository;
|
||||
import com.cappielloantonio.play.repository.ArtistRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AlbumCatalogueViewModel extends AndroidViewModel {
|
||||
private AlbumRepository albumRepository;
|
||||
|
||||
private LiveData<List<Album>> albumList;
|
||||
public LiveData<List<Album>> albumList;
|
||||
|
||||
public AlbumCatalogueViewModel(@NonNull Application application) {
|
||||
super(application);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.cappielloantonio.play.viewmodel;
|
||||
|
||||
import android.app.Application;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.AndroidViewModel;
|
||||
@@ -19,6 +20,7 @@ public class HomeViewModel extends AndroidViewModel {
|
||||
private LiveData<List<Song>> recentlyPlayedSongSample;
|
||||
private LiveData<List<Song>> recentlyAddedSongSample;
|
||||
private LiveData<List<Song>> mostPlayedSongSample;
|
||||
private List<Integer> years;
|
||||
|
||||
public HomeViewModel(@NonNull Application application) {
|
||||
super(application);
|
||||
@@ -29,6 +31,7 @@ public class HomeViewModel extends AndroidViewModel {
|
||||
recentlyPlayedSongSample = songRepository.getListLiveRecentlyPlayedSampleSong(20);
|
||||
recentlyAddedSongSample = songRepository.getListLiveRecentlyAddedSampleSong(20);
|
||||
mostPlayedSongSample = songRepository.getListLiveMostPlayedSampleSong(20);
|
||||
years = songRepository.getYearList();
|
||||
}
|
||||
|
||||
|
||||
@@ -51,4 +54,9 @@ public class HomeViewModel extends AndroidViewModel {
|
||||
public LiveData<List<Song>> getMostPlayedSongList() {
|
||||
return mostPlayedSongSample;
|
||||
}
|
||||
|
||||
public List<Integer> getYearList() {
|
||||
Log.d(TAG, "getYearList: " + years.toString());
|
||||
return years;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ public class SongListPageViewModel extends AndroidViewModel {
|
||||
public Artist artist;
|
||||
public ArrayList<String> filters = new ArrayList<>();
|
||||
public ArrayList<String> filterNames = new ArrayList<>();
|
||||
public int year = 0;
|
||||
|
||||
public SongListPageViewModel(@NonNull Application application) {
|
||||
super(application);
|
||||
@@ -52,6 +53,9 @@ public class SongListPageViewModel extends AndroidViewModel {
|
||||
case Song.BY_GENRES:
|
||||
songList = songRepository.getFilteredListLiveSong(filters);
|
||||
break;
|
||||
case Song.BY_YEAR:
|
||||
songList = songRepository.getSongByYearListLive(year);
|
||||
break;
|
||||
}
|
||||
|
||||
return songList;
|
||||
|
||||
Reference in New Issue
Block a user