Fix some layout sizes

This commit is contained in:
Jarne Demeulemeester 2021-06-20 12:07:36 +02:00
parent f4207a88f5
commit 30587099de
No known key found for this signature in database
GPG key ID: 60884A0C1EBA43E5
6 changed files with 36 additions and 16 deletions

View file

@ -6,18 +6,25 @@ import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import dev.jdtech.jellyfin.R
import dev.jdtech.jellyfin.databinding.BaseItemBinding
import org.jellyfin.sdk.model.api.BaseItemDto
class ViewItemListAdapter :
class ViewItemListAdapter(private val fixedWidth: Boolean = false) :
ListAdapter<BaseItemDto, ViewItemListAdapter.ItemViewHolder>(DiffCallback) {
class ItemViewHolder(private var binding: BaseItemBinding) :
class ItemViewHolder(private var binding: BaseItemBinding, private val parent: ViewGroup) :
RecyclerView.ViewHolder(binding.root) {
fun bind(item: BaseItemDto) {
fun bind(item: BaseItemDto, fixedWidth: Boolean) {
binding.item = item
binding.itemName.text = if (item.type == "Episode") item.seriesName else item.name
binding.itemCount.visibility =
if (item.userData?.unplayedItemCount != null && item.userData?.unplayedItemCount!! > 0) View.VISIBLE else View.GONE
if (fixedWidth) {
binding.itemLayout.layoutParams.width =
parent.resources.getDimension(R.dimen.overview_media_width).toInt()
(binding.itemLayout.layoutParams as ViewGroup.MarginLayoutParams).bottomMargin = 0
}
binding.executePendingBindings()
}
}
@ -38,12 +45,12 @@ class ViewItemListAdapter :
LayoutInflater.from(parent.context),
parent,
false
)
), parent
)
}
override fun onBindViewHolder(holder: ItemViewHolder, position: Int) {
val item = getItem(position)
holder.bind(item)
holder.bind(item, fixedWidth)
}
}

View file

@ -14,7 +14,7 @@ class ViewListAdapter : ListAdapter<View, ViewListAdapter.ViewViewHolder>(DiffCa
binding.view = view
// TODO: Change to string placeholder
binding.viewName.text = "Latest ${view.name}"
binding.itemsRecyclerView.adapter = ViewItemListAdapter()
binding.itemsRecyclerView.adapter = ViewItemListAdapter(fixedWidth = true)
binding.executePendingBindings()
}
}

View file

@ -11,20 +11,23 @@
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="150dp"
android:id="@+id/item_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="12dp"
android:layout_marginBottom="24dp"
android:orientation="vertical">
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/item_image"
android:layout_width="match_parent"
android:layout_height="220dp"
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="centerCrop"
app:itemImage="@{item}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintDimensionRatio="H,2:3"
app:shapeAppearanceOverlay="@style/roundedImageView" />
<TextView

View file

@ -10,7 +10,7 @@
type="org.jellyfin.sdk.model.api.BaseItemDto" />
</data>
<LinearLayout
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="12dp"
@ -19,19 +19,28 @@
android:orientation="vertical">
<com.google.android.material.imageview.ShapeableImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:id="@+id/collection_image"
android:layout_width="0dp"
android:layout_height="0dp"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
app:collectionImage="@{collection}"
app:layout_constraintDimensionRatio="H,16:9"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:shapeAppearanceOverlay="@style/roundedImageView" />
<TextView
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@{collection.name}"
android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/collection_image"
tools:text="Movies" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

View file

@ -13,7 +13,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="36dp">
android:layout_marginBottom="12dp">
<TextView
android:id="@+id/view_name"

View file

@ -3,6 +3,7 @@
<item name="match_parent" type="dimen">-1</item>
<item name="wrap_content" type="dimen">-2</item>
<dimen name="setup_container_width">@dimen/match_parent</dimen>
<dimen name="overview_media_width">150dp</dimen>
<item name="server_colums" type="integer">3</item>
<item name="collection_colums" type="integer">1</item>
<item name="library_colums" type="integer">2</item>