From a102fc9cad2ebfd9c464a6bddff9db7c273d3bd2 Mon Sep 17 00:00:00 2001 From: Stypox Date: Mon, 7 Jun 2021 07:57:26 +0200 Subject: [PATCH] Use constraint layout for play queue item Also remove invalid ic_selected attribute --- .../subscription/SubscriptionFragment.kt | 6 +- .../player/playqueue/PlayQueueAdapter.java | 8 +- .../player/playqueue/PlayQueueItemHolder.java | 2 - app/src/main/res/layout/play_queue_item.xml | 93 +++++++++---------- app/src/main/res/values/attrs.xml | 3 - app/src/main/res/values/dimens.xml | 4 +- 6 files changed, 56 insertions(+), 60 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt index 13643af15fe..8a235fa8abc 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt @@ -294,8 +294,10 @@ class SubscriptionFragment : BaseStateFragment() { } private fun showLongTapDialog(selectedItem: ChannelInfoItem) { - val commands = arrayOf(getString(R.string.share), getString(R.string.open_in_browser), - getString(R.string.unsubscribe)) + val commands = arrayOf( + getString(R.string.share), getString(R.string.open_in_browser), + getString(R.string.unsubscribe) + ) val actions = DialogInterface.OnClickListener { _, i -> when (i) { diff --git a/app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueueAdapter.java b/app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueueAdapter.java index 462b9eb53db..dd95fb4d509 100644 --- a/app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueueAdapter.java +++ b/app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueueAdapter.java @@ -182,8 +182,10 @@ public int getItemViewType(final int position) { return ITEM_VIEW_TYPE_ID; } + @NonNull @Override - public RecyclerView.ViewHolder onCreateViewHolder(final ViewGroup parent, final int type) { + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull final ViewGroup parent, + final int type) { switch (type) { case FOOTER_VIEW_TYPE_ID: return new HFHolder(footer); @@ -197,7 +199,8 @@ public RecyclerView.ViewHolder onCreateViewHolder(final ViewGroup parent, final } @Override - public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) { + public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, + final int position) { if (holder instanceof PlayQueueItemHolder) { final PlayQueueItemHolder itemHolder = (PlayQueueItemHolder) holder; @@ -207,7 +210,6 @@ public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int pos // Check if the current item should be selected/highlighted final boolean isSelected = playQueue.getIndex() == position; - itemHolder.itemSelected.setVisibility(isSelected ? View.VISIBLE : View.INVISIBLE); itemHolder.itemView.setSelected(isSelected); } else if (holder instanceof HFHolder && position == playQueue.getStreams().size() && footer != null && showFooter) { diff --git a/app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueueItemHolder.java b/app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueueItemHolder.java index c4641034359..1f2537baa50 100644 --- a/app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueueItemHolder.java +++ b/app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueueItemHolder.java @@ -37,7 +37,6 @@ public class PlayQueueItemHolder extends RecyclerView.ViewHolder { public final TextView itemDurationView; final TextView itemAdditionalDetailsView; - final ImageView itemSelected; public final ImageView itemThumbnailView; final ImageView itemHandle; @@ -49,7 +48,6 @@ public class PlayQueueItemHolder extends RecyclerView.ViewHolder { itemVideoTitleView = v.findViewById(R.id.itemVideoTitleView); itemDurationView = v.findViewById(R.id.itemDurationView); itemAdditionalDetailsView = v.findViewById(R.id.itemAdditionalDetails); - itemSelected = v.findViewById(R.id.itemSelected); itemThumbnailView = v.findViewById(R.id.itemThumbnailView); itemHandle = v.findViewById(R.id.itemHandle); } diff --git a/app/src/main/res/layout/play_queue_item.xml b/app/src/main/res/layout/play_queue_item.xml index a5be55c94e8..05e7213cc2f 100644 --- a/app/src/main/res/layout/play_queue_item.xml +++ b/app/src/main/res/layout/play_queue_item.xml @@ -1,102 +1,99 @@ - - - + android:foreground="?attr/selectableItemBackground"> - - + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintBottom_toTopOf="@+id/itemAdditionalDetails" + app:layout_constraintEnd_toStartOf="@+id/itemHandle" + app:layout_constraintStart_toEndOf="@+id/itemThumbnailView" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_chainStyle="packed" + tools:text="Lorem ipsum dolor sit amet, consectetur adipisci elit. " /> + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toStartOf="@+id/itemHandle" + app:layout_constraintStart_toEndOf="@+id/itemThumbnailView" + app:layout_constraintTop_toBottomOf="@+id/itemVideoTitleView" + tools:text="Uploader uploader uploader uploader uploader ยท Youtube" /> + + - + diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index 80572e14ecf..01dbfce155f 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -1,8 +1,5 @@ - - - diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index ea26be57e15..b55ad781cd6 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -114,9 +114,9 @@ 24dp 28dp - + 62dp - 40dp + 35dp 30sp