Add header with image to MediaInfoFragment
This commit is contained in:
parent
bc5a6f0723
commit
d361e60850
4 changed files with 81 additions and 19 deletions
|
@ -47,6 +47,21 @@ fun bindItemImage(imageView: ImageView, item: BaseItemDto) {
|
||||||
imageView.contentDescription = "${item.name} poster"
|
imageView.contentDescription = "${item.name} poster"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@BindingAdapter("itemBackdropImage")
|
||||||
|
fun bindItemBackdropImage(imageView: ImageView, item: BaseItemDto?) {
|
||||||
|
if (item != null) {
|
||||||
|
val jellyfinApi = JellyfinApi.getInstance(imageView.context.applicationContext, "")
|
||||||
|
|
||||||
|
Glide
|
||||||
|
.with(imageView.context)
|
||||||
|
.load(jellyfinApi.api.baseUrl.plus("/items/${item.id}/Images/Backdrop"))
|
||||||
|
.transition(DrawableTransitionOptions.withCrossFade())
|
||||||
|
.into(imageView)
|
||||||
|
|
||||||
|
imageView.contentDescription = "${item.name} backdrop"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@BindingAdapter("collections")
|
@BindingAdapter("collections")
|
||||||
fun bindCollections(recyclerView: RecyclerView, data: List<BaseItemDto>?) {
|
fun bindCollections(recyclerView: RecyclerView, data: List<BaseItemDto>?) {
|
||||||
val adapter = recyclerView.adapter as CollectionListAdapter
|
val adapter = recyclerView.adapter as CollectionListAdapter
|
||||||
|
|
5
app/src/main/res/drawable-night/header_gradient.xml
Normal file
5
app/src/main/res/drawable-night/header_gradient.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<gradient android:angle="90"
|
||||||
|
android:startColor="@color/neutral_900"/>
|
||||||
|
</shape>
|
5
app/src/main/res/drawable/header_gradient.xml
Normal file
5
app/src/main/res/drawable/header_gradient.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<gradient android:angle="90"
|
||||||
|
android:startColor="@color/neutral_100"/>
|
||||||
|
</shape>
|
|
@ -22,14 +22,51 @@
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:context=".fragments.MediaInfoFragment">
|
tools:context=".fragments.MediaInfoFragment">
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="200dp"
|
||||||
|
android:layout_marginBottom="8dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/item_banner"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="200dp"
|
||||||
|
app:itemBackdropImage="@{viewModel.item}"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:background="@drawable/header_gradient"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/name"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="24dp"
|
||||||
|
android:text="@{viewModel.item.name}"
|
||||||
|
android:textAppearance="@style/TextAppearance.MaterialComponents.Headline5"
|
||||||
|
app:layout_constraintBottom_toTopOf="@id/original_title"
|
||||||
|
app:layout_constraintStart_toStartOf="parent" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/original_title"
|
android:id="@+id/original_title"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginHorizontal="24dp"
|
android:layout_marginHorizontal="24dp"
|
||||||
android:layout_marginBottom="12dp"
|
|
||||||
android:text="@{viewModel.item.originalTitle}"
|
android:text="@{viewModel.item.originalTitle}"
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
|
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -77,8 +114,8 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="24dp"
|
android:layout_marginHorizontal="24dp"
|
||||||
android:layout_marginHorizontal="24dp">
|
android:layout_marginBottom="24dp">
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/play_button"
|
android:id="@+id/play_button"
|
||||||
|
@ -86,10 +123,10 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="12dp"
|
android:layout_marginEnd="12dp"
|
||||||
android:background="@drawable/button_setup_background"
|
android:background="@drawable/button_setup_background"
|
||||||
|
android:contentDescription="@string/play_button_description"
|
||||||
android:paddingHorizontal="24dp"
|
android:paddingHorizontal="24dp"
|
||||||
android:paddingVertical="12dp"
|
android:paddingVertical="12dp"
|
||||||
android:src="@drawable/ic_play"
|
android:src="@drawable/ic_play" />
|
||||||
android:contentDescription="@string/play_button_description" />
|
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/trailer_button"
|
android:id="@+id/trailer_button"
|
||||||
|
@ -97,9 +134,9 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="12dp"
|
android:layout_marginEnd="12dp"
|
||||||
android:background="@drawable/button_accent_background"
|
android:background="@drawable/button_accent_background"
|
||||||
|
android:contentDescription="@string/trailer_button_description"
|
||||||
android:padding="12dp"
|
android:padding="12dp"
|
||||||
android:src="@drawable/ic_film"
|
android:src="@drawable/ic_film" />
|
||||||
android:contentDescription="@string/trailer_button_description" />
|
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/shuffle_button"
|
android:id="@+id/shuffle_button"
|
||||||
|
@ -107,9 +144,9 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="12dp"
|
android:layout_marginEnd="12dp"
|
||||||
android:background="@drawable/button_accent_background"
|
android:background="@drawable/button_accent_background"
|
||||||
|
android:contentDescription="@string/shuffle_button_description"
|
||||||
android:padding="12dp"
|
android:padding="12dp"
|
||||||
android:src="@drawable/ic_shuffle"
|
android:src="@drawable/ic_shuffle" />
|
||||||
android:contentDescription="@string/shuffle_button_description" />
|
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/check_button"
|
android:id="@+id/check_button"
|
||||||
|
@ -117,18 +154,18 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="12dp"
|
android:layout_marginEnd="12dp"
|
||||||
android:background="@drawable/button_accent_background"
|
android:background="@drawable/button_accent_background"
|
||||||
|
android:contentDescription="@string/check_button_description"
|
||||||
android:padding="12dp"
|
android:padding="12dp"
|
||||||
android:src="@drawable/ic_check"
|
android:src="@drawable/ic_check" />
|
||||||
android:contentDescription="@string/check_button_description" />
|
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/favorite_button"
|
android:id="@+id/favorite_button"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@drawable/button_accent_background"
|
android:background="@drawable/button_accent_background"
|
||||||
|
android:contentDescription="@string/favorite_button_description"
|
||||||
android:padding="12dp"
|
android:padding="12dp"
|
||||||
android:src="@drawable/ic_heart"
|
android:src="@drawable/ic_heart" />
|
||||||
android:contentDescription="@string/favorite_button_description" />
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|
Loading…
Reference in a new issue