diff options
author | ByteHamster <info@bytehamster.com> | 2020-10-23 22:50:45 +0200 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2020-10-24 10:51:15 +0200 |
commit | 8ecd9803bb91cb39256718927b4ea6724ab82582 (patch) | |
tree | 9811ebd7f93da2493fa9635a778f50065bb967fa /app | |
parent | ee4b2c05545b81ef154a5802479793e8eaf29af1 (diff) | |
download | AntennaPod-8ecd9803bb91cb39256718927b4ea6724ab82582.zip |
Fixed played state sometimes not being displayed
Diffstat (limited to 'app')
3 files changed, 216 insertions, 204 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/EpisodeItemListAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/EpisodeItemListAdapter.java index 8efc89c9a..4762622d1 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/EpisodeItemListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/EpisodeItemListAdapter.java @@ -92,11 +92,11 @@ public class EpisodeItemListAdapter extends RecyclerView.Adapter<EpisodeItemView // Set all listeners to null. This is required to prevent leaking fragments that have set a listener. // Activity -> recycledViewPool -> EpisodeItemViewHolder -> Listener -> Fragment (can not be garbage collected) holder.itemView.setOnClickListener(null); + holder.itemView.setOnCreateContextMenuListener(null); + holder.itemView.setOnLongClickListener(null); holder.secondaryActionButton.setOnClickListener(null); holder.dragHandle.setOnTouchListener(null); holder.coverHolder.setOnTouchListener(null); - holder.container.setOnCreateContextMenuListener(null); - holder.container.setOnLongClickListener(null); } /** diff --git a/app/src/main/java/de/danoeh/antennapod/view/viewholder/EpisodeItemViewHolder.java b/app/src/main/java/de/danoeh/antennapod/view/viewholder/EpisodeItemViewHolder.java index 902e5094b..35744227f 100644 --- a/app/src/main/java/de/danoeh/antennapod/view/viewholder/EpisodeItemViewHolder.java +++ b/app/src/main/java/de/danoeh/antennapod/view/viewholder/EpisodeItemViewHolder.java @@ -39,7 +39,7 @@ import de.danoeh.antennapod.view.CircularProgressBar; public class EpisodeItemViewHolder extends RecyclerView.ViewHolder { private static final String TAG = "EpisodeItemViewHolder"; - public final View container; + private final View container; public final ImageView dragHandle; private final TextView placeholder; private final ImageView cover; @@ -102,7 +102,7 @@ public class EpisodeItemViewHolder extends RecyclerView.ViewHolder { isNew.setVisibility(item.isNew() ? View.VISIBLE : View.GONE); isFavorite.setVisibility(item.isTagged(FeedItem.TAG_FAVORITE) ? View.VISIBLE : View.GONE); isInQueue.setVisibility(item.isTagged(FeedItem.TAG_QUEUE) ? View.VISIBLE : View.GONE); - itemView.setAlpha(item.isPlayed() ? 0.5f : 1.0f); + container.setAlpha(item.isPlayed() ? 0.5f : 1.0f); ItemActionButton actionButton = ItemActionButton.forItem(item, true, true); actionButton.configure(secondaryActionButton, secondaryActionIcon, activity); @@ -116,6 +116,7 @@ public class EpisodeItemViewHolder extends RecyclerView.ViewHolder { progressBar.setVisibility(View.GONE); duration.setVisibility(View.GONE); position.setVisibility(View.GONE); + itemView.setBackgroundResource(ThemeUtils.getDrawableFromAttr(activity, R.attr.selectableItemBackground)); } if (coverHolder.getVisibility() == View.VISIBLE) { @@ -136,9 +137,9 @@ public class EpisodeItemViewHolder extends RecyclerView.ViewHolder { Converter.getDurationStringLocalized(activity, media.getDuration()))); if (media.isCurrentlyPlaying()) { - container.setBackgroundColor(ThemeUtils.getColorFromAttr(activity, R.attr.currently_playing_background)); + itemView.setBackgroundColor(ThemeUtils.getColorFromAttr(activity, R.attr.currently_playing_background)); } else { - container.setBackgroundResource(ThemeUtils.getDrawableFromAttr(activity, R.attr.selectableItemBackground)); + itemView.setBackgroundResource(ThemeUtils.getDrawableFromAttr(activity, R.attr.selectableItemBackground)); } if (DownloadRequester.getInstance().isDownloadingFile(media)) { diff --git a/app/src/main/res/layout/feeditemlist_item.xml b/app/src/main/res/layout/feeditemlist_item.xml index 7083365e7..a8ae5743e 100644 --- a/app/src/main/res/layout/feeditemlist_item.xml +++ b/app/src/main/res/layout/feeditemlist_item.xml @@ -1,225 +1,236 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout +<FrameLayout xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" - android:id="@+id/container" android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="horizontal" - android:gravity="center_vertical" - android:baselineAligned="false" - android:paddingStart="12dp" - android:paddingLeft="12dp" - android:paddingEnd="0dp" - android:paddingRight="0dp"> + android:layout_height="wrap_content"> - <LinearLayout - android:layout_width="wrap_content" - android:layout_height="match_parent" - android:id="@+id/left_padding" - android:minWidth="4dp"> - <ImageView - android:id="@+id/drag_handle" - android:layout_width="16dp" - android:layout_height="match_parent" - android:importantForAccessibility="no" - android:scaleType="fitCenter" - android:src="?attr/dragview_background" - android:paddingStart="0dp" - android:paddingLeft="0dp" - android:paddingEnd="4dp" - android:paddingRight="4dp" - tools:src="@drawable/ic_drag_darktheme" - tools:background="@android:color/holo_green_dark"/> - - </LinearLayout> - - <androidx.cardview.widget.CardView - android:layout_width="@dimen/thumbnail_length_queue_item" - android:layout_height="@dimen/thumbnail_length_queue_item" - android:layout_marginBottom="@dimen/listitem_threeline_verticalpadding" - android:layout_marginTop="@dimen/listitem_threeline_verticalpadding" - android:layout_marginRight="@dimen/listitem_threeline_textleftpadding" - android:layout_marginEnd="@dimen/listitem_threeline_textleftpadding" - android:id="@+id/coverHolder" - app:cardBackgroundColor="@color/non_square_icon_background" - app:cardCornerRadius="4dp" - app:cardPreventCornerOverlap="false" - app:cardElevation="0dp"> - - <RelativeLayout - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <TextView - android:id="@+id/txtvPlaceholder" - android:layout_width="@dimen/thumbnail_length_queue_item" - android:layout_height="@dimen/thumbnail_length_queue_item" - android:layout_centerVertical="true" - android:gravity="center" - android:background="@color/light_gray" - android:maxLines="3" - android:padding="2dp" - android:ellipsize="end"/> - <ImageView - android:id="@+id/imgvCover" - android:layout_width="@dimen/thumbnail_length_queue_item" - android:layout_height="@dimen/thumbnail_length_queue_item" - android:layout_centerVertical="true" - android:importantForAccessibility="no" - tools:src="@tools:sample/avatars"/> - - </RelativeLayout> - </androidx.cardview.widget.CardView> + <!-- + This parent FrameLayout is necessary because RecyclerView's ItemAnimator changes alpha values, + which conflicts with our played state indicator. + --> <LinearLayout - android:layout_width="0dp" + android:id="@+id/container" + android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginBottom="@dimen/listitem_threeline_verticalpadding" - android:layout_marginRight="@dimen/listitem_threeline_textrightpadding" - android:layout_marginEnd="@dimen/listitem_threeline_textrightpadding" - android:layout_marginTop="@dimen/listitem_threeline_verticalpadding" - android:layout_weight="1" - tools:background="@android:color/holo_red_dark" - android:orientation="vertical"> + android:orientation="horizontal" + android:gravity="center_vertical" + android:baselineAligned="false" + android:paddingStart="12dp" + android:paddingLeft="12dp" + android:paddingEnd="0dp" + android:paddingRight="0dp" + tools:ignore="UselessParent"> <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:id="@+id/status" - android:orientation="horizontal" - android:gravity="center_vertical"> - - <TextView - android:text="@string/new_label" - style="@style/AntennaPod.TextView.UnreadIndicator" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:id="@+id/statusUnread" - android:layout_marginRight="4dp" - android:layout_marginEnd="4dp" - tools:text="@sample/episodes.json/data/status_label"/> - - <ImageView - android:layout_width="14sp" - android:layout_height="14sp" - app:srcCompat="?attr/type_video" - tools:srcCompat="@drawable/ic_videocam_black_24dp" - android:contentDescription="@string/media_type_video_label" - android:id="@+id/ivIsVideo"/> - - <ImageView - android:layout_width="14sp" - android:layout_height="14sp" - app:srcCompat="?attr/ic_unfav" - tools:srcCompat="@drawable/ic_star_black" - android:contentDescription="@string/is_favorite_label" - android:id="@+id/isFavorite"/> - + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:id="@+id/left_padding" + android:minWidth="4dp"> <ImageView - android:layout_width="14sp" - android:layout_height="14sp" - app:srcCompat="?attr/stat_playlist" - tools:srcCompat="@drawable/ic_playlist_black" - android:contentDescription="@string/in_queue_label" - android:id="@+id/ivInPlaylist"/> - - <TextView - android:id="@+id/separatorIcons" - style="@style/AntennaPod.TextView.ListItemSecondaryTitle" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginLeft="4dp" - android:layout_marginStart="4dp" - android:layout_marginRight="4dp" - android:layout_marginEnd="4dp" - android:text="·" - tools:background="@android:color/holo_blue_light"/> - - <TextView - android:id="@+id/txtvPubDate" - style="@style/AntennaPod.TextView.ListItemSecondaryTitle" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginRight="4dp" - android:layout_marginEnd="4dp" - tools:text="@sample/episodes.json/data/published_at"/> - - <TextView - style="@style/AntennaPod.TextView.ListItemSecondaryTitle" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginRight="4dp" - android:layout_marginEnd="4dp" - android:text="·" - tools:background="@android:color/holo_blue_light"/> - - <TextView - android:id="@+id/size" - style="@style/AntennaPod.TextView.ListItemSecondaryTitle" - android:layout_marginRight="4dp" - android:layout_marginEnd="4dp" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - tools:text="10 MB"/> + android:id="@+id/drag_handle" + android:layout_width="16dp" + android:layout_height="match_parent" + android:importantForAccessibility="no" + android:scaleType="fitCenter" + android:src="?attr/dragview_background" + android:paddingStart="0dp" + android:paddingLeft="0dp" + android:paddingEnd="4dp" + android:paddingRight="4dp" + tools:src="@drawable/ic_drag_darktheme" + tools:background="@android:color/holo_green_dark"/> </LinearLayout> - <!-- - Warning: android:contentDescription is set to an empty string. - The title is read as contentDescription of left_padding to have it read first. - Keep this in mind when changing the order of this layout! - --> - <TextView - android:id="@+id/txtvTitle" - style="@style/AntennaPod.TextView.ListItemPrimaryTitle" - android:layout_width="match_parent" - android:layout_height="wrap_content" - tools:text="@sample/episodes.json/data/title" - android:importantForAccessibility="no" - android:ellipsize="end" - tools:background="@android:color/holo_blue_light"/> + <androidx.cardview.widget.CardView + android:layout_width="@dimen/thumbnail_length_queue_item" + android:layout_height="@dimen/thumbnail_length_queue_item" + android:layout_marginBottom="@dimen/listitem_threeline_verticalpadding" + android:layout_marginTop="@dimen/listitem_threeline_verticalpadding" + android:layout_marginRight="@dimen/listitem_threeline_textleftpadding" + android:layout_marginEnd="@dimen/listitem_threeline_textleftpadding" + android:id="@+id/coverHolder" + app:cardBackgroundColor="@color/non_square_icon_background" + app:cardCornerRadius="4dp" + app:cardPreventCornerOverlap="false" + app:cardElevation="0dp"> + + <RelativeLayout + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <TextView + android:id="@+id/txtvPlaceholder" + android:layout_width="@dimen/thumbnail_length_queue_item" + android:layout_height="@dimen/thumbnail_length_queue_item" + android:layout_centerVertical="true" + android:gravity="center" + android:background="@color/light_gray" + android:maxLines="3" + android:padding="2dp" + android:ellipsize="end"/> + <ImageView + android:id="@+id/imgvCover" + android:layout_width="@dimen/thumbnail_length_queue_item" + android:layout_height="@dimen/thumbnail_length_queue_item" + android:layout_centerVertical="true" + android:importantForAccessibility="no" + tools:src="@tools:sample/avatars"/> + + </RelativeLayout> + </androidx.cardview.widget.CardView> <LinearLayout - android:layout_width="match_parent" + android:layout_width="0dp" android:layout_height="wrap_content" - android:id="@+id/progress" - android:orientation="horizontal" - android:gravity="center_vertical"> - + android:layout_marginBottom="@dimen/listitem_threeline_verticalpadding" + android:layout_marginRight="@dimen/listitem_threeline_textrightpadding" + android:layout_marginEnd="@dimen/listitem_threeline_textrightpadding" + android:layout_marginTop="@dimen/listitem_threeline_verticalpadding" + android:layout_weight="1" + tools:background="@android:color/holo_red_dark" + android:orientation="vertical"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:id="@+id/status" + android:orientation="horizontal" + android:gravity="center_vertical"> + + <TextView + android:text="@string/new_label" + style="@style/AntennaPod.TextView.UnreadIndicator" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:id="@+id/statusUnread" + android:layout_marginRight="4dp" + android:layout_marginEnd="4dp" + tools:text="@sample/episodes.json/data/status_label"/> + + <ImageView + android:layout_width="14sp" + android:layout_height="14sp" + app:srcCompat="?attr/type_video" + tools:srcCompat="@drawable/ic_videocam_black_24dp" + android:contentDescription="@string/media_type_video_label" + android:id="@+id/ivIsVideo"/> + + <ImageView + android:layout_width="14sp" + android:layout_height="14sp" + app:srcCompat="?attr/ic_unfav" + tools:srcCompat="@drawable/ic_star_black" + android:contentDescription="@string/is_favorite_label" + android:id="@+id/isFavorite"/> + + <ImageView + android:layout_width="14sp" + android:layout_height="14sp" + app:srcCompat="?attr/stat_playlist" + tools:srcCompat="@drawable/ic_playlist_black" + android:contentDescription="@string/in_queue_label" + android:id="@+id/ivInPlaylist"/> + + <TextView + android:id="@+id/separatorIcons" + style="@style/AntennaPod.TextView.ListItemSecondaryTitle" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginLeft="4dp" + android:layout_marginStart="4dp" + android:layout_marginRight="4dp" + android:layout_marginEnd="4dp" + android:text="·" + tools:background="@android:color/holo_blue_light"/> + + <TextView + android:id="@+id/txtvPubDate" + style="@style/AntennaPod.TextView.ListItemSecondaryTitle" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginRight="4dp" + android:layout_marginEnd="4dp" + tools:text="@sample/episodes.json/data/published_at"/> + + <TextView + style="@style/AntennaPod.TextView.ListItemSecondaryTitle" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginRight="4dp" + android:layout_marginEnd="4dp" + android:text="·" + tools:background="@android:color/holo_blue_light"/> + + <TextView + android:id="@+id/size" + style="@style/AntennaPod.TextView.ListItemSecondaryTitle" + android:layout_marginRight="4dp" + android:layout_marginEnd="4dp" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + tools:text="10 MB"/> + + </LinearLayout> + + <!-- + Warning: android:contentDescription is set to an empty string. + The title is read as contentDescription of left_padding to have it read first. + Keep this in mind when changing the order of this layout! + --> <TextView - android:id="@+id/txtvPosition" - style="@style/AntennaPod.TextView.ListItemSecondaryTitle" - android:layout_width="wrap_content" + android:id="@+id/txtvTitle" + style="@style/AntennaPod.TextView.ListItemPrimaryTitle" + android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginBottom="0dp" - tools:text="00:42:23" - tools:background="@android:color/holo_blue_light"/> - - <ProgressBar - android:id="@+id/progressBar" - style="?attr/progressBarTheme" - android:layout_width="0dp" - android:layout_weight="1" - android:layout_height="4dp" - android:max="100" - android:layout_margin="4dp" + tools:text="@sample/episodes.json/data/title" + android:importantForAccessibility="no" + android:ellipsize="end" tools:background="@android:color/holo_blue_light"/> - <TextView - android:id="@+id/txtvDuration" - style="@style/AntennaPod.TextView.ListItemSecondaryTitle" - android:layout_width="wrap_content" + <LinearLayout + android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginBottom="0dp" - tools:text="@sample/episodes.json/data/duration" - tools:background="@android:color/holo_blue_light"/> + android:id="@+id/progress" + android:orientation="horizontal" + android:gravity="center_vertical"> + + <TextView + android:id="@+id/txtvPosition" + style="@style/AntennaPod.TextView.ListItemSecondaryTitle" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginBottom="0dp" + tools:text="00:42:23" + tools:background="@android:color/holo_blue_light"/> + + <ProgressBar + android:id="@+id/progressBar" + style="?attr/progressBarTheme" + android:layout_width="0dp" + android:layout_weight="1" + android:layout_height="4dp" + android:max="100" + android:layout_margin="4dp" + tools:background="@android:color/holo_blue_light"/> + + <TextView + android:id="@+id/txtvDuration" + style="@style/AntennaPod.TextView.ListItemSecondaryTitle" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginBottom="0dp" + tools:text="@sample/episodes.json/data/duration" + tools:background="@android:color/holo_blue_light"/> + + </LinearLayout> </LinearLayout> - </LinearLayout> + <include layout="@layout/secondary_action"/> - <include layout="@layout/secondary_action"/> - -</LinearLayout> + </LinearLayout> +</FrameLayout> |