wip: radio working from artist page

This commit is contained in:
eddyizm 2025-12-27 17:52:29 -08:00
parent 3b3f55c5de
commit c1b2ec09a4
No known key found for this signature in database
GPG key ID: CF5F671829E8158A

View file

@ -9,7 +9,6 @@ import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Toast;
import android.widget.ToggleButton; import android.widget.ToggleButton;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -32,6 +31,7 @@ import com.cappielloantonio.tempo.interfaces.ClickCallback;
import com.cappielloantonio.tempo.service.MediaManager; import com.cappielloantonio.tempo.service.MediaManager;
import com.cappielloantonio.tempo.service.MediaService; import com.cappielloantonio.tempo.service.MediaService;
import com.cappielloantonio.tempo.subsonic.models.ArtistID3; import com.cappielloantonio.tempo.subsonic.models.ArtistID3;
import com.cappielloantonio.tempo.subsonic.models.Child;
import com.cappielloantonio.tempo.ui.activity.MainActivity; import com.cappielloantonio.tempo.ui.activity.MainActivity;
import com.cappielloantonio.tempo.ui.adapter.AlbumCatalogueAdapter; import com.cappielloantonio.tempo.ui.adapter.AlbumCatalogueAdapter;
import com.cappielloantonio.tempo.ui.adapter.ArtistCatalogueAdapter; import com.cappielloantonio.tempo.ui.adapter.ArtistCatalogueAdapter;
@ -203,22 +203,27 @@ public class ArtistPageFragment extends Fragment implements ClickCallback {
} }
}); });
} }
private void initPlayButtons() { private void initPlayButtons() {
bind.artistPageShuffleButton.setOnClickListener(v -> artistPageViewModel.getArtistShuffleList().observe(getViewLifecycleOwner(), songs -> { bind.artistPageShuffleButton.setOnClickListener(v -> artistPageViewModel.getArtistShuffleList().observe(getViewLifecycleOwner(), new androidx.lifecycle.Observer<List<Child>>() {
if (!songs.isEmpty()) { @Override
MediaManager.startQueue(mediaBrowserListenableFuture, songs, 0); public void onChanged(List<Child> songs) {
activity.setBottomSheetInPeek(true); if (songs != null && !songs.isEmpty()) {
} else { MediaManager.startQueue(mediaBrowserListenableFuture, songs, 0);
Toast.makeText(requireContext(), getString(R.string.artist_error_retrieving_tracks), Toast.LENGTH_SHORT).show(); activity.setBottomSheetInPeek(true);
artistPageViewModel.getArtistShuffleList().removeObserver(this);
}
} }
})); }));
bind.artistPageRadioButton.setOnClickListener(v -> artistPageViewModel.getArtistInstantMix().observe(getViewLifecycleOwner(), songs -> { bind.artistPageRadioButton.setOnClickListener(v -> artistPageViewModel.getArtistInstantMix().observe(getViewLifecycleOwner(), new androidx.lifecycle.Observer<List<Child>>() {
if (songs != null && !songs.isEmpty()) { @Override
MediaManager.startQueue(mediaBrowserListenableFuture, songs, 0); public void onChanged(List<Child> songs) {
activity.setBottomSheetInPeek(true); if (songs != null && !songs.isEmpty()) {
} else { MediaManager.startQueue(mediaBrowserListenableFuture, songs, 0);
Toast.makeText(requireContext(), getString(R.string.artist_error_retrieving_radio), Toast.LENGTH_SHORT).show(); activity.setBottomSheetInPeek(true);
artistPageViewModel.getArtistInstantMix().removeObserver(this);
}
} }
})); }));
} }