mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 01:53:31 +00:00
Refactoring - Removed most of the click listeners from the adapters and moved them into the appropriate fragments
This commit is contained in:
parent
29f56945c2
commit
754fc69eab
54 changed files with 1143 additions and 1137 deletions
|
|
@ -52,6 +52,8 @@ public class HomeViewModel extends AndroidViewModel {
|
|||
private final MutableLiveData<List<Media>> newestPodcastEpisodes = new MutableLiveData<>(null);
|
||||
|
||||
private final MutableLiveData<List<Chronology>> thisGridTopSong = new MutableLiveData<>(null);
|
||||
private final MutableLiveData<List<Media>> mediaInstantMix = new MutableLiveData<>(null);
|
||||
private final MutableLiveData<List<Media>> artistInstantMix = new MutableLiveData<>(null);
|
||||
|
||||
public HomeViewModel(@NonNull Application application) {
|
||||
super(application);
|
||||
|
|
@ -194,6 +196,22 @@ public class HomeViewModel extends AndroidViewModel {
|
|||
return newestPodcastEpisodes;
|
||||
}
|
||||
|
||||
public LiveData<List<Media>> getMediaInstantMix(LifecycleOwner owner, Media media) {
|
||||
mediaInstantMix.setValue(Collections.emptyList());
|
||||
|
||||
songRepository.getInstantMix(media, 20).observe(owner, mediaInstantMix::postValue);
|
||||
|
||||
return mediaInstantMix;
|
||||
}
|
||||
|
||||
public LiveData<List<Media>> getArtistInstantMix(LifecycleOwner owner, Artist artist) {
|
||||
artistInstantMix.setValue(Collections.emptyList());
|
||||
|
||||
artistRepository.getInstantMix(artist, 20).observe(owner, artistInstantMix::postValue);
|
||||
|
||||
return artistInstantMix;
|
||||
}
|
||||
|
||||
public void refreshDiscoverySongSample(LifecycleOwner owner) {
|
||||
songRepository.getRandomSample(10, null, null).observe(owner, dicoverSongSample::postValue);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import com.cappielloantonio.play.util.DownloadUtil;
|
|||
import com.cappielloantonio.play.util.MappingUtil;
|
||||
import com.cappielloantonio.play.util.PreferenceUtil;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class PlayerBottomSheetViewModel extends AndroidViewModel {
|
||||
|
|
@ -32,6 +33,8 @@ public class PlayerBottomSheetViewModel extends AndroidViewModel {
|
|||
|
||||
private final MutableLiveData<Media> liveMedia = new MutableLiveData<>(null);
|
||||
private final MutableLiveData<Artist> liveArtist = new MutableLiveData<>(null);
|
||||
private final MutableLiveData<List<Media>> instantMix = new MutableLiveData<>(null);
|
||||
|
||||
|
||||
public PlayerBottomSheetViewModel(@NonNull Application application) {
|
||||
super(application);
|
||||
|
|
@ -105,4 +108,12 @@ public class PlayerBottomSheetViewModel extends AndroidViewModel {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public LiveData<List<Media>> getMediaInstantMix(LifecycleOwner owner, Media media) {
|
||||
instantMix.setValue(Collections.emptyList());
|
||||
|
||||
songRepository.getInstantMix(media, 20).observe(owner, instantMix::postValue);
|
||||
|
||||
return instantMix;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,10 @@ import android.content.Context;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.AndroidViewModel;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
|
||||
import com.cappielloantonio.play.model.Album;
|
||||
import com.cappielloantonio.play.model.Artist;
|
||||
|
|
@ -17,6 +20,10 @@ import com.cappielloantonio.play.util.DownloadUtil;
|
|||
import com.cappielloantonio.play.util.MappingUtil;
|
||||
import com.cappielloantonio.play.util.PreferenceUtil;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@UnstableApi
|
||||
public class SongBottomSheetViewModel extends AndroidViewModel {
|
||||
private final SongRepository songRepository;
|
||||
private final AlbumRepository albumRepository;
|
||||
|
|
@ -24,6 +31,8 @@ public class SongBottomSheetViewModel extends AndroidViewModel {
|
|||
|
||||
private Media song;
|
||||
|
||||
private final MutableLiveData<List<Media>> instantMix = new MutableLiveData<>(null);
|
||||
|
||||
public SongBottomSheetViewModel(@NonNull Application application) {
|
||||
super(application);
|
||||
|
||||
|
|
@ -64,4 +73,12 @@ public class SongBottomSheetViewModel extends AndroidViewModel {
|
|||
public LiveData<Artist> getArtist() {
|
||||
return artistRepository.getArtist(song.getArtistId());
|
||||
}
|
||||
|
||||
public LiveData<List<Media>> getInstantMix(LifecycleOwner owner, Media media) {
|
||||
instantMix.setValue(Collections.emptyList());
|
||||
|
||||
songRepository.getInstantMix(media, 20).observe(owner, instantMix::postValue);
|
||||
|
||||
return instantMix;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue