feat: Mark currently playing song in PlayerSongQueueAdapter

This commit is contained in:
Jaime García 2025-09-22 00:35:23 +02:00
parent 52ba783a90
commit d810010090
No known key found for this signature in database
GPG key ID: BC4E5F71A71BDA5B
3 changed files with 38 additions and 0 deletions

View file

@ -17,6 +17,7 @@ import com.cappielloantonio.tempo.databinding.ItemPlayerQueueSongBinding;
import com.cappielloantonio.tempo.glide.CustomGlideRequest;
import com.cappielloantonio.tempo.interfaces.ClickCallback;
import com.cappielloantonio.tempo.interfaces.MediaIndexCallback;
import com.cappielloantonio.tempo.interfaces.MediaSongIdCallback;
import com.cappielloantonio.tempo.service.MediaManager;
import com.cappielloantonio.tempo.subsonic.models.Child;
import com.cappielloantonio.tempo.util.Constants;
@ -86,6 +87,19 @@ public class PlayerSongQueueAdapter extends RecyclerView.Adapter<PlayerSongQueue
}
});
MediaManager.getCurrentSongId(mediaBrowserListenableFuture, new MediaSongIdCallback() {
@Override
public void onRecovery(String id) {
if (song.getId().equals(id)) {
holder.item.playPauseIcon.setVisibility(View.VISIBLE);
holder.item.coverArtOverlay.setVisibility(View.VISIBLE);
} else {
holder.item.playPauseIcon.setVisibility(View.INVISIBLE);
holder.item.coverArtOverlay.setVisibility(View.INVISIBLE);
}
}
});
if (Preferences.showItemRating()) {
if (song.getStarred() == null && song.getUserRating() == null) {
holder.item.ratingIndicatorImageView.setVisibility(View.GONE);

View file

@ -110,6 +110,7 @@ public class PlayerQueueFragment extends Fragment implements ClickCallback {
playerSongQueueAdapter = new PlayerSongQueueAdapter(this);
bind.playerQueueRecyclerView.setAdapter(playerSongQueueAdapter);
setMediaBrowserListenableFuture();
playerBottomSheetViewModel.getQueueSong().observe(getViewLifecycleOwner(), queue -> {
if (queue != null) {
playerSongQueueAdapter.setItems(queue.stream().map(item -> (Child) item).collect(Collectors.toList()));
@ -215,5 +216,6 @@ public class PlayerQueueFragment extends Fragment implements ClickCallback {
@Override
public void onMediaClick(Bundle bundle) {
MediaManager.startQueue(mediaBrowserListenableFuture, bundle.getParcelableArrayList(Constants.TRACKS_OBJECT), bundle.getInt(Constants.ITEM_POSITION));
updateNowPlayingItem();
}
}

View file

@ -20,6 +20,28 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/cover_art_overlay"
android:layout_width="52dp"
android:layout_height="52dp"
android:layout_marginStart="2dp"
android:background="#80000000"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/play_pause_icon"
android:layout_width="28dp"
android:layout_height="28dp"
android:layout_marginStart="14dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:src="@drawable/button_play_pause_selector" />
<TextView
android:id="@+id/queue_song_title_text_view"
style="@style/LabelMedium"