Skip to content

Commit

Permalink
Merge pull request #6443 from Stypox/invalid-attr
Browse files Browse the repository at this point in the history
Use constraint layout for play queue item
  • Loading branch information
TobiGr authored Jun 8, 2021
2 parents 70b9330 + a102fc9 commit 761e01c
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;

Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
}
Expand Down
93 changes: 45 additions & 48 deletions app/src/main/res/layout/play_queue_item.xml
Original file line number Diff line number Diff line change
@@ -1,102 +1,99 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/itemRoot"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_height="wrap_content"
android:background="?attr/selector"
android:clickable="true"
android:focusable="true"
android:foreground="?attr/selectableItemBackground"
android:paddingTop="6dp"
android:paddingBottom="6dp">

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/itemSelected"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_centerInParent="true"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:scaleType="fitXY"
app:srcCompat="?attr/ic_selected"
tools:ignore="ContentDescription,RtlHardcoded" />
android:foreground="?attr/selectableItemBackground">

<ImageView
android:id="@+id/itemThumbnailView"
android:layout_width="@dimen/play_queue_thumbnail_width"
android:layout_height="@dimen/play_queue_thumbnail_height"
android:layout_alignParentTop="true"
android:layout_marginRight="@dimen/video_item_search_image_right_margin"
android:layout_toEndOf="@+id/itemSelected"
android:layout_toRightOf="@+id/itemSelected"
android:layout_marginStart="@dimen/video_item_search_image_right_margin"
android:layout_marginTop="@dimen/video_item_search_image_right_margin"
android:layout_marginBottom="@dimen/video_item_search_image_right_margin"
android:contentDescription="@string/list_thumbnail_view_description"
android:scaleType="centerCrop"
android:src="@drawable/dummy_thumbnail"
tools:ignore="RtlHardcoded" />

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/itemHandle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_gravity="center_vertical"
android:padding="@dimen/video_item_search_image_right_margin"
android:scaleType="center"
app:srcCompat="@drawable/ic_drag_handle"
tools:ignore="ContentDescription,RtlHardcoded" />
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/itemDurationView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@id/itemThumbnailView"
android:layout_alignEnd="@id/itemThumbnailView"
android:layout_alignBottom="@id/itemThumbnailView"
android:layout_marginRight="@dimen/video_item_search_duration_margin"
android:layout_marginEnd="@dimen/video_item_search_duration_margin"
android:layout_marginBottom="@dimen/video_item_search_duration_margin"
android:background="@color/duration_background_color"
android:paddingLeft="@dimen/video_item_search_duration_horizontal_padding"
android:paddingStart="@dimen/video_item_search_duration_horizontal_padding"
android:paddingTop="@dimen/video_item_search_duration_vertical_padding"
android:paddingRight="@dimen/video_item_search_duration_horizontal_padding"
android:paddingEnd="@dimen/video_item_search_duration_horizontal_padding"
android:paddingBottom="@dimen/video_item_search_duration_vertical_padding"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/duration_text_color"
android:textSize="@dimen/video_item_search_duration_text_size"
tools:ignore="RtlHardcoded"
app:layout_constraintBottom_toBottomOf="@+id/itemThumbnailView"
app:layout_constraintEnd_toEndOf="@+id/itemThumbnailView"
tools:text="1:09:10" />


<TextView
android:id="@+id/itemVideoTitleView"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginStart="8dp"
android:layout_toStartOf="@id/itemHandle"
android:layout_toLeftOf="@id/itemHandle"
android:layout_toEndOf="@id/itemThumbnailView"
android:layout_toRightOf="@id/itemThumbnailView"
android:ellipsize="end"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="@dimen/video_item_search_title_text_size"
tools:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. " />
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. " />

<TextView
android:id="@+id/itemAdditionalDetails"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginStart="8dp"
android:layout_toStartOf="@id/itemHandle"
android:layout_toLeftOf="@id/itemHandle"
android:layout_toEndOf="@id/itemThumbnailView"
android:layout_toRightOf="@id/itemThumbnailView"
android:ellipsize="end"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textSize="@dimen/video_item_search_upload_date_text_size"
tools:text="Uploader" />
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" />

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/itemHandle"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_alignParentRight="true"
android:layout_gravity="center_vertical"
android:paddingHorizontal="@dimen/video_item_search_image_right_margin"
android:scaleType="center"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_drag_handle"
tools:ignore="ContentDescription,RtlHardcoded" />

</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
3 changes: 0 additions & 3 deletions app/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<attr name="ic_selected" format="reference" />

<attr name="progress_horizontal_drawable" format="reference" />
<!-- Can't refer to colors directly in drawable's xml-->
<attr name="toolbar_shadow" format="reference" />
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@
<dimen name="playlist_detail_uploader_image_size">24dp</dimen>
<dimen name="playlist_detail_uploader_layout_height">28dp</dimen>

<!-- Play Queue View Dimensions -->
<!-- Play queue thumbnail view dimensions (16:9) -->
<dimen name="play_queue_thumbnail_width">62dp</dimen>
<dimen name="play_queue_thumbnail_height">40dp</dimen>
<dimen name="play_queue_thumbnail_height">35dp</dimen>

<!-- Kiosk view Dimensions-->
<dimen name="kiosk_title_text_size">30sp</dimen>
Expand Down

0 comments on commit 761e01c

Please sign in to comment.