mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 17:43:32 +00:00
feat: Replace play/pause button with an icon, allow tapping on full item to play/pause song in Queue
This commit is contained in:
parent
2e29e9537a
commit
14939d20fd
2 changed files with 14 additions and 24 deletions
|
|
@ -112,7 +112,7 @@ public class PlayerSongQueueAdapter extends RecyclerView.Adapter<PlayerSongQueue
|
||||||
} else {
|
} else {
|
||||||
holder.item.ratingIndicatorImageView.setVisibility(View.GONE);
|
holder.item.ratingIndicatorImageView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
holder.item.playPauseButton.setOnClickListener(v -> {
|
holder.itemView.setOnClickListener(v -> {
|
||||||
mediaBrowserListenableFuture.addListener(() -> {
|
mediaBrowserListenableFuture.addListener(() -> {
|
||||||
try {
|
try {
|
||||||
MediaBrowser mediaBrowser = mediaBrowserListenableFuture.get();
|
MediaBrowser mediaBrowser = mediaBrowserListenableFuture.get();
|
||||||
|
|
@ -138,23 +138,19 @@ public class PlayerSongQueueAdapter extends RecyclerView.Adapter<PlayerSongQueue
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bindPlaybackState(@NonNull PlayerSongQueueAdapter.ViewHolder holder, @NonNull Child song) {
|
private void bindPlaybackState(@NonNull PlayerSongQueueAdapter.ViewHolder holder, @NonNull Child song) {
|
||||||
boolean isCurrent = currentPlayingId != null && currentPlayingId.equals(song.getId()) && isPlaying;
|
boolean isCurrent = currentPlayingId != null && currentPlayingId.equals(song.getId());
|
||||||
|
|
||||||
if (isCurrent) {
|
if (isCurrent) {
|
||||||
holder.item.playPauseButton.setVisibility(View.VISIBLE);
|
holder.item.playPauseIcon.setVisibility(View.VISIBLE);
|
||||||
holder.item.playPauseButton.setChecked(true);
|
if (isPlaying) {
|
||||||
|
holder.item.playPauseIcon.setImageResource(R.drawable.ic_pause);
|
||||||
|
} else {
|
||||||
|
holder.item.playPauseIcon.setImageResource(R.drawable.ic_play);
|
||||||
|
}
|
||||||
holder.item.coverArtOverlay.setVisibility(View.VISIBLE);
|
holder.item.coverArtOverlay.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
boolean sameIdPaused = currentPlayingId != null && currentPlayingId.equals(song.getId()) && !isPlaying;
|
holder.item.playPauseIcon.setVisibility(View.GONE);
|
||||||
if (sameIdPaused) {
|
holder.item.coverArtOverlay.setVisibility(View.INVISIBLE);
|
||||||
holder.item.playPauseButton.setVisibility(View.VISIBLE);
|
|
||||||
holder.item.playPauseButton.setChecked(false);
|
|
||||||
holder.item.coverArtOverlay.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
holder.item.playPauseButton.setVisibility(View.GONE);
|
|
||||||
holder.item.playPauseButton.setChecked(false);
|
|
||||||
holder.item.coverArtOverlay.setVisibility(View.INVISIBLE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,18 +31,12 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<ToggleButton
|
<ImageView
|
||||||
android:id="@+id/play_pause_button"
|
android:id="@+id/play_pause_icon"
|
||||||
android:layout_width="28dp"
|
android:layout_width="28dp"
|
||||||
android:layout_height="28dp"
|
android:layout_height="28dp"
|
||||||
android:layout_marginStart="14dp"
|
android:layout_gravity="center"
|
||||||
android:visibility="gone"
|
android:layout_margin="14dp"
|
||||||
android:background="@drawable/button_play_pause_selector"
|
|
||||||
android:checked="false"
|
|
||||||
android:foreground="?android:attr/selectableItemBackgroundBorderless"
|
|
||||||
android:text=""
|
|
||||||
android:textOff=""
|
|
||||||
android:textOn=""
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue