Highlight currently playing card

This commit is contained in:
ByteHamster 2022-11-30 19:27:55 +01:00
parent 2d115a0ec5
commit 1c08543430
4 changed files with 15 additions and 3 deletions

View File

@ -1,11 +1,11 @@
package de.danoeh.antennapod.view.viewholder;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.RecyclerView;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.MainActivity;
@ -21,9 +21,10 @@ import de.danoeh.antennapod.model.feed.FeedItem;
import de.danoeh.antennapod.model.feed.FeedMedia;
import de.danoeh.antennapod.ui.common.CircularProgressBar;
import de.danoeh.antennapod.ui.common.SquareImageView;
import de.danoeh.antennapod.ui.common.ThemeUtils;
public class HorizontalItemViewHolder extends RecyclerView.ViewHolder {
public final View card;
public final CardView card;
public final ImageView secondaryActionIcon;
private final SquareImageView cover;
private final TextView title;
@ -67,6 +68,12 @@ public class HorizontalItemViewHolder extends RecyclerView.ViewHolder {
if (media == null) {
circularProgressBar.setPercentage(0, item);
} else {
if (PlaybackStatus.isCurrentlyPlaying(media)) {
card.setCardBackgroundColor(ThemeUtils.getColorFromAttr(activity, R.attr.card_background_playing));
} else {
card.setCardBackgroundColor(ThemeUtils.getColorFromAttr(activity, R.attr.card_background));
}
if (item.getMedia().getDuration() > 0) {
progressBar.setProgress(100 * item.getMedia().getPosition() / item.getMedia().getDuration());
}

View File

@ -21,7 +21,6 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/background_elevated"
android:orientation="vertical">
<androidx.cardview.widget.CardView

View File

@ -16,4 +16,6 @@
<attr name="icon_green" format="color" />
<attr name="icon_purple" format="color" />
<attr name="icon_gray" format="color" />
<attr name="card_background" format="color" />
<attr name="card_background_playing" format="color" />
</resources>

View File

@ -29,6 +29,8 @@
<item name="navigation_up">@drawable/navigation_up</item>
<item name="dragview_background">@drawable/ic_drag_lighttheme</item>
<item name="scrollbar_thumb">@drawable/scrollbar_thumb_light</item>
<item name="card_background">#EFEEEE</item>
<item name="card_background_playing">#D8D8D8</item>
<item name="icon_red">#CF1800</item>
<item name="icon_yellow">#F59F00</item>
<item name="icon_green">#008537</item>
@ -68,6 +70,8 @@
<item name="navigation_up">@drawable/navigation_up_dark</item>
<item name="dragview_background">@drawable/ic_drag_darktheme</item>
<item name="scrollbar_thumb">@drawable/scrollbar_thumb_dark</item>
<item name="card_background">#2d3337</item>
<item name="card_background_playing">#444D53</item>
<item name="icon_red">#CF1800</item>
<item name="icon_yellow">#F59F00</item>
<item name="icon_green">#008537</item>