Fix some layout sizes
This commit is contained in:
parent
f4207a88f5
commit
30587099de
6 changed files with 36 additions and 16 deletions
|
@ -6,18 +6,25 @@ import android.view.ViewGroup
|
||||||
import androidx.recyclerview.widget.DiffUtil
|
import androidx.recyclerview.widget.DiffUtil
|
||||||
import androidx.recyclerview.widget.ListAdapter
|
import androidx.recyclerview.widget.ListAdapter
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import dev.jdtech.jellyfin.R
|
||||||
import dev.jdtech.jellyfin.databinding.BaseItemBinding
|
import dev.jdtech.jellyfin.databinding.BaseItemBinding
|
||||||
import org.jellyfin.sdk.model.api.BaseItemDto
|
import org.jellyfin.sdk.model.api.BaseItemDto
|
||||||
|
|
||||||
class ViewItemListAdapter :
|
class ViewItemListAdapter(private val fixedWidth: Boolean = false) :
|
||||||
ListAdapter<BaseItemDto, ViewItemListAdapter.ItemViewHolder>(DiffCallback) {
|
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) {
|
RecyclerView.ViewHolder(binding.root) {
|
||||||
fun bind(item: BaseItemDto) {
|
fun bind(item: BaseItemDto, fixedWidth: Boolean) {
|
||||||
binding.item = item
|
binding.item = item
|
||||||
binding.itemName.text = if (item.type == "Episode") item.seriesName else item.name
|
binding.itemName.text = if (item.type == "Episode") item.seriesName else item.name
|
||||||
binding.itemCount.visibility =
|
binding.itemCount.visibility =
|
||||||
if (item.userData?.unplayedItemCount != null && item.userData?.unplayedItemCount!! > 0) View.VISIBLE else View.GONE
|
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()
|
binding.executePendingBindings()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,12 +45,12 @@ class ViewItemListAdapter :
|
||||||
LayoutInflater.from(parent.context),
|
LayoutInflater.from(parent.context),
|
||||||
parent,
|
parent,
|
||||||
false
|
false
|
||||||
)
|
), parent
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: ItemViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: ItemViewHolder, position: Int) {
|
||||||
val item = getItem(position)
|
val item = getItem(position)
|
||||||
holder.bind(item)
|
holder.bind(item, fixedWidth)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -14,7 +14,7 @@ class ViewListAdapter : ListAdapter<View, ViewListAdapter.ViewViewHolder>(DiffCa
|
||||||
binding.view = view
|
binding.view = view
|
||||||
// TODO: Change to string placeholder
|
// TODO: Change to string placeholder
|
||||||
binding.viewName.text = "Latest ${view.name}"
|
binding.viewName.text = "Latest ${view.name}"
|
||||||
binding.itemsRecyclerView.adapter = ViewItemListAdapter()
|
binding.itemsRecyclerView.adapter = ViewItemListAdapter(fixedWidth = true)
|
||||||
binding.executePendingBindings()
|
binding.executePendingBindings()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,20 +11,23 @@
|
||||||
</data>
|
</data>
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<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_height="wrap_content"
|
||||||
android:layout_marginHorizontal="12dp"
|
android:layout_marginHorizontal="12dp"
|
||||||
|
android:layout_marginBottom="24dp"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<com.google.android.material.imageview.ShapeableImageView
|
<com.google.android.material.imageview.ShapeableImageView
|
||||||
android:id="@+id/item_image"
|
android:id="@+id/item_image"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="0dp"
|
||||||
android:layout_height="220dp"
|
android:layout_height="0dp"
|
||||||
android:scaleType="centerCrop"
|
android:scaleType="centerCrop"
|
||||||
app:itemImage="@{item}"
|
app:itemImage="@{item}"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintDimensionRatio="H,2:3"
|
||||||
app:shapeAppearanceOverlay="@style/roundedImageView" />
|
app:shapeAppearanceOverlay="@style/roundedImageView" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
type="org.jellyfin.sdk.model.api.BaseItemDto" />
|
type="org.jellyfin.sdk.model.api.BaseItemDto" />
|
||||||
</data>
|
</data>
|
||||||
|
|
||||||
<LinearLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginHorizontal="12dp"
|
android:layout_marginHorizontal="12dp"
|
||||||
|
@ -19,19 +19,28 @@
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<com.google.android.material.imageview.ShapeableImageView
|
<com.google.android.material.imageview.ShapeableImageView
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/collection_image"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="0dp"
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_height="0dp"
|
||||||
android:adjustViewBounds="true"
|
android:adjustViewBounds="true"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
app:collectionImage="@{collection}"
|
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" />
|
app:shapeAppearanceOverlay="@style/roundedImageView" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
android:text="@{collection.name}"
|
android:text="@{collection.name}"
|
||||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1"
|
android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/collection_image"
|
||||||
tools:text="Movies" />
|
tools:text="Movies" />
|
||||||
</LinearLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
</layout>
|
</layout>
|
|
@ -13,7 +13,7 @@
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="36dp">
|
android:layout_marginBottom="12dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/view_name"
|
android:id="@+id/view_name"
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
<item name="match_parent" type="dimen">-1</item>
|
<item name="match_parent" type="dimen">-1</item>
|
||||||
<item name="wrap_content" type="dimen">-2</item>
|
<item name="wrap_content" type="dimen">-2</item>
|
||||||
<dimen name="setup_container_width">@dimen/match_parent</dimen>
|
<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="server_colums" type="integer">3</item>
|
||||||
<item name="collection_colums" type="integer">1</item>
|
<item name="collection_colums" type="integer">1</item>
|
||||||
<item name="library_colums" type="integer">2</item>
|
<item name="library_colums" type="integer">2</item>
|
||||||
|
|
Loading…
Reference in a new issue