diff --git a/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/AlbumPageFragment.java b/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/AlbumPageFragment.java index e6595e5f..50a09fe7 100644 --- a/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/AlbumPageFragment.java +++ b/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/AlbumPageFragment.java @@ -307,7 +307,7 @@ public class AlbumPageFragment extends Fragment implements ClickCallback { } private void observePlayback() { - playbackViewModel.getCurrentMediaId().observe(getViewLifecycleOwner(), id -> { + playbackViewModel.getCurrentSongId().observe(getViewLifecycleOwner(), id -> { if (songHorizontalAdapter != null) { Boolean playing = playbackViewModel.getIsPlaying().getValue(); songHorizontalAdapter.setPlaybackState(id, playing != null && playing); @@ -315,7 +315,7 @@ public class AlbumPageFragment extends Fragment implements ClickCallback { }); playbackViewModel.getIsPlaying().observe(getViewLifecycleOwner(), playing -> { if (songHorizontalAdapter != null) { - String id = playbackViewModel.getCurrentMediaId().getValue(); + String id = playbackViewModel.getCurrentSongId().getValue(); songHorizontalAdapter.setPlaybackState(id, playing != null && playing); } }); @@ -323,7 +323,7 @@ public class AlbumPageFragment extends Fragment implements ClickCallback { private void reapplyPlayback() { if (songHorizontalAdapter != null) { - String id = playbackViewModel.getCurrentMediaId().getValue(); + String id = playbackViewModel.getCurrentSongId().getValue(); Boolean playing = playbackViewModel.getIsPlaying().getValue(); songHorizontalAdapter.setPlaybackState(id, playing != null && playing); } diff --git a/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/ArtistPageFragment.java b/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/ArtistPageFragment.java index 11b0a210..1d1cb7d1 100644 --- a/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/ArtistPageFragment.java +++ b/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/ArtistPageFragment.java @@ -29,20 +29,16 @@ import com.cappielloantonio.tempo.service.MediaManager; import com.cappielloantonio.tempo.service.MediaService; import com.cappielloantonio.tempo.subsonic.models.ArtistID3; import com.cappielloantonio.tempo.ui.activity.MainActivity; -import com.cappielloantonio.tempo.ui.adapter.AlbumArtistPageOrSimilarAdapter; import com.cappielloantonio.tempo.ui.adapter.AlbumCatalogueAdapter; import com.cappielloantonio.tempo.ui.adapter.ArtistCatalogueAdapter; -import com.cappielloantonio.tempo.ui.adapter.ArtistSimilarAdapter; import com.cappielloantonio.tempo.ui.adapter.SongHorizontalAdapter; import com.cappielloantonio.tempo.util.Constants; import com.cappielloantonio.tempo.util.MusicUtil; -import com.cappielloantonio.tempo.util.Preferences; import com.cappielloantonio.tempo.viewmodel.ArtistPageViewModel; import com.cappielloantonio.tempo.viewmodel.PlaybackViewModel; import com.google.common.util.concurrent.ListenableFuture; import java.util.ArrayList; -import java.util.Collections; import java.util.List; @UnstableApi @@ -282,7 +278,7 @@ public class ArtistPageFragment extends Fragment implements ClickCallback { } private void observePlayback() { - playbackViewModel.getCurrentMediaId().observe(getViewLifecycleOwner(), id -> { + playbackViewModel.getCurrentSongId().observe(getViewLifecycleOwner(), id -> { if (songHorizontalAdapter != null) { Boolean playing = playbackViewModel.getIsPlaying().getValue(); songHorizontalAdapter.setPlaybackState(id, playing != null && playing); @@ -290,7 +286,7 @@ public class ArtistPageFragment extends Fragment implements ClickCallback { }); playbackViewModel.getIsPlaying().observe(getViewLifecycleOwner(), playing -> { if (songHorizontalAdapter != null) { - String id = playbackViewModel.getCurrentMediaId().getValue(); + String id = playbackViewModel.getCurrentSongId().getValue(); songHorizontalAdapter.setPlaybackState(id, playing != null && playing); } }); @@ -298,7 +294,7 @@ public class ArtistPageFragment extends Fragment implements ClickCallback { private void reapplyPlayback() { if (songHorizontalAdapter != null) { - String id = playbackViewModel.getCurrentMediaId().getValue(); + String id = playbackViewModel.getCurrentSongId().getValue(); Boolean playing = playbackViewModel.getIsPlaying().getValue(); songHorizontalAdapter.setPlaybackState(id, playing != null && playing); } diff --git a/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/HomeTabMusicFragment.java b/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/HomeTabMusicFragment.java index 672dabd4..ae95f35f 100644 --- a/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/HomeTabMusicFragment.java +++ b/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/HomeTabMusicFragment.java @@ -1058,7 +1058,7 @@ public class HomeTabMusicFragment extends Fragment implements ClickCallback { } private void observeStarredSongsPlayback() { - playbackViewModel.getCurrentMediaId().observe(getViewLifecycleOwner(), id -> { + playbackViewModel.getCurrentSongId().observe(getViewLifecycleOwner(), id -> { if (starredSongAdapter != null) { Boolean playing = playbackViewModel.getIsPlaying().getValue(); starredSongAdapter.setPlaybackState(id, playing != null && playing); @@ -1066,14 +1066,14 @@ public class HomeTabMusicFragment extends Fragment implements ClickCallback { }); playbackViewModel.getIsPlaying().observe(getViewLifecycleOwner(), playing -> { if (starredSongAdapter != null) { - String id = playbackViewModel.getCurrentMediaId().getValue(); + String id = playbackViewModel.getCurrentSongId().getValue(); starredSongAdapter.setPlaybackState(id, playing != null && playing); } }); } private void observeTopSongsPlayback() { - playbackViewModel.getCurrentMediaId().observe(getViewLifecycleOwner(), id -> { + playbackViewModel.getCurrentSongId().observe(getViewLifecycleOwner(), id -> { if (topSongAdapter != null) { Boolean playing = playbackViewModel.getIsPlaying().getValue(); topSongAdapter.setPlaybackState(id, playing != null && playing); @@ -1081,7 +1081,7 @@ public class HomeTabMusicFragment extends Fragment implements ClickCallback { }); playbackViewModel.getIsPlaying().observe(getViewLifecycleOwner(), playing -> { if (topSongAdapter != null) { - String id = playbackViewModel.getCurrentMediaId().getValue(); + String id = playbackViewModel.getCurrentSongId().getValue(); topSongAdapter.setPlaybackState(id, playing != null && playing); } }); @@ -1089,7 +1089,7 @@ public class HomeTabMusicFragment extends Fragment implements ClickCallback { private void reapplyStarredSongsPlayback() { if (starredSongAdapter != null) { - String id = playbackViewModel.getCurrentMediaId().getValue(); + String id = playbackViewModel.getCurrentSongId().getValue(); Boolean playing = playbackViewModel.getIsPlaying().getValue(); starredSongAdapter.setPlaybackState(id, playing != null && playing); } @@ -1097,7 +1097,7 @@ public class HomeTabMusicFragment extends Fragment implements ClickCallback { private void reapplyTopSongsPlayback() { if (topSongAdapter != null) { - String id = playbackViewModel.getCurrentMediaId().getValue(); + String id = playbackViewModel.getCurrentSongId().getValue(); Boolean playing = playbackViewModel.getIsPlaying().getValue(); topSongAdapter.setPlaybackState(id, playing != null && playing); } diff --git a/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/PlayerQueueFragment.java b/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/PlayerQueueFragment.java index 1686cc21..06536cd6 100644 --- a/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/PlayerQueueFragment.java +++ b/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/PlayerQueueFragment.java @@ -227,7 +227,7 @@ public class PlayerQueueFragment extends Fragment implements ClickCallback { } private void observePlayback() { - playbackViewModel.getCurrentMediaId().observe(getViewLifecycleOwner(), id -> { + playbackViewModel.getCurrentSongId().observe(getViewLifecycleOwner(), id -> { if (playerSongQueueAdapter != null) { Boolean playing = playbackViewModel.getIsPlaying().getValue(); playerSongQueueAdapter.setPlaybackState(id, playing != null && playing); @@ -235,7 +235,7 @@ public class PlayerQueueFragment extends Fragment implements ClickCallback { }); playbackViewModel.getIsPlaying().observe(getViewLifecycleOwner(), playing -> { if (playerSongQueueAdapter != null) { - String id = playbackViewModel.getCurrentMediaId().getValue(); + String id = playbackViewModel.getCurrentSongId().getValue(); playerSongQueueAdapter.setPlaybackState(id, playing != null && playing); } }); @@ -243,7 +243,7 @@ public class PlayerQueueFragment extends Fragment implements ClickCallback { private void reapplyPlayback() { if (playerSongQueueAdapter != null) { - String id = playbackViewModel.getCurrentMediaId().getValue(); + String id = playbackViewModel.getCurrentSongId().getValue(); Boolean playing = playbackViewModel.getIsPlaying().getValue(); playerSongQueueAdapter.setPlaybackState(id, playing != null && playing); } diff --git a/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/PlaylistPageFragment.java b/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/PlaylistPageFragment.java index e51afc56..ef58e96c 100644 --- a/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/PlaylistPageFragment.java +++ b/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/PlaylistPageFragment.java @@ -282,7 +282,7 @@ public class PlaylistPageFragment extends Fragment implements ClickCallback { } private void observePlayback() { - playbackViewModel.getCurrentMediaId().observe(getViewLifecycleOwner(), id -> { + playbackViewModel.getCurrentSongId().observe(getViewLifecycleOwner(), id -> { if (songHorizontalAdapter != null) { Boolean playing = playbackViewModel.getIsPlaying().getValue(); songHorizontalAdapter.setPlaybackState(id, playing != null && playing); @@ -290,7 +290,7 @@ public class PlaylistPageFragment extends Fragment implements ClickCallback { }); playbackViewModel.getIsPlaying().observe(getViewLifecycleOwner(), playing -> { if (songHorizontalAdapter != null) { - String id = playbackViewModel.getCurrentMediaId().getValue(); + String id = playbackViewModel.getCurrentSongId().getValue(); songHorizontalAdapter.setPlaybackState(id, playing != null && playing); } }); @@ -298,7 +298,7 @@ public class PlaylistPageFragment extends Fragment implements ClickCallback { private void reapplyPlayback() { if (songHorizontalAdapter != null) { - String id = playbackViewModel.getCurrentMediaId().getValue(); + String id = playbackViewModel.getCurrentSongId().getValue(); Boolean playing = playbackViewModel.getIsPlaying().getValue(); songHorizontalAdapter.setPlaybackState(id, playing != null && playing); } diff --git a/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/SearchFragment.java b/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/SearchFragment.java index 7136329e..b6c3b8d3 100644 --- a/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/SearchFragment.java +++ b/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/SearchFragment.java @@ -4,14 +4,11 @@ import android.content.ComponentName; import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.view.inputmethod.EditorInfo; import android.widget.ImageView; import android.widget.TextView; -import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -303,7 +300,7 @@ public class SearchFragment extends Fragment implements ClickCallback { } private void observePlayback() { - playbackViewModel.getCurrentMediaId().observe(getViewLifecycleOwner(), id -> { + playbackViewModel.getCurrentSongId().observe(getViewLifecycleOwner(), id -> { if (songHorizontalAdapter != null) { Boolean playing = playbackViewModel.getIsPlaying().getValue(); songHorizontalAdapter.setPlaybackState(id, playing != null && playing); @@ -311,7 +308,7 @@ public class SearchFragment extends Fragment implements ClickCallback { }); playbackViewModel.getIsPlaying().observe(getViewLifecycleOwner(), playing -> { if (songHorizontalAdapter != null) { - String id = playbackViewModel.getCurrentMediaId().getValue(); + String id = playbackViewModel.getCurrentSongId().getValue(); songHorizontalAdapter.setPlaybackState(id, playing != null && playing); } }); @@ -319,7 +316,7 @@ public class SearchFragment extends Fragment implements ClickCallback { private void reapplyPlayback() { if (songHorizontalAdapter != null) { - String id = playbackViewModel.getCurrentMediaId().getValue(); + String id = playbackViewModel.getCurrentSongId().getValue(); Boolean playing = playbackViewModel.getIsPlaying().getValue(); songHorizontalAdapter.setPlaybackState(id, playing != null && playing); } diff --git a/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/SongListPageFragment.java b/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/SongListPageFragment.java index db6ebe38..4f8bad46 100644 --- a/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/SongListPageFragment.java +++ b/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/SongListPageFragment.java @@ -335,7 +335,7 @@ public class SongListPageFragment extends Fragment implements ClickCallback { } private void observePlayback() { - playbackViewModel.getCurrentMediaId().observe(getViewLifecycleOwner(), id -> { + playbackViewModel.getCurrentSongId().observe(getViewLifecycleOwner(), id -> { if (songHorizontalAdapter != null) { Boolean playing = playbackViewModel.getIsPlaying().getValue(); songHorizontalAdapter.setPlaybackState(id, playing != null && playing); @@ -343,7 +343,7 @@ public class SongListPageFragment extends Fragment implements ClickCallback { }); playbackViewModel.getIsPlaying().observe(getViewLifecycleOwner(), playing -> { if (songHorizontalAdapter != null) { - String id = playbackViewModel.getCurrentMediaId().getValue(); + String id = playbackViewModel.getCurrentSongId().getValue(); songHorizontalAdapter.setPlaybackState(id, playing != null && playing); } }); @@ -351,7 +351,7 @@ public class SongListPageFragment extends Fragment implements ClickCallback { private void reapplyPlayback() { if (songHorizontalAdapter != null) { - String id = playbackViewModel.getCurrentMediaId().getValue(); + String id = playbackViewModel.getCurrentSongId().getValue(); Boolean playing = playbackViewModel.getIsPlaying().getValue(); songHorizontalAdapter.setPlaybackState(id, playing != null && playing); } diff --git a/app/src/main/java/com/cappielloantonio/tempo/viewmodel/PlaybackViewModel.java b/app/src/main/java/com/cappielloantonio/tempo/viewmodel/PlaybackViewModel.java index 6f266148..b1808d9f 100644 --- a/app/src/main/java/com/cappielloantonio/tempo/viewmodel/PlaybackViewModel.java +++ b/app/src/main/java/com/cappielloantonio/tempo/viewmodel/PlaybackViewModel.java @@ -8,20 +8,20 @@ import java.util.Objects; public class PlaybackViewModel extends ViewModel { - private final MutableLiveData currentMediaId = new MutableLiveData<>(null); + private final MutableLiveData currentSongId = new MutableLiveData<>(null); private final MutableLiveData isPlaying = new MutableLiveData<>(false); - public LiveData getCurrentMediaId() { - return currentMediaId; + public LiveData getCurrentSongId() { + return currentSongId; } public LiveData getIsPlaying() { return isPlaying; } - public void update(String mediaId, boolean playing) { - if (!Objects.equals(currentMediaId.getValue(), mediaId)) { - currentMediaId.postValue(mediaId); + public void update(String songId, boolean playing) { + if (!Objects.equals(currentSongId.getValue(), songId)) { + currentSongId.postValue(songId); } if (!Objects.equals(isPlaying.getValue(), playing)) { isPlaying.postValue(playing); @@ -29,7 +29,7 @@ public class PlaybackViewModel extends ViewModel { } public void clear() { - currentMediaId.postValue(null); + currentSongId.postValue(null); isPlaying.postValue(false); } } \ No newline at end of file