Add header to SeasonFragment
This commit is contained in:
parent
d361e60850
commit
4329b76448
6 changed files with 117 additions and 12 deletions
|
@ -12,6 +12,7 @@ import dev.jdtech.jellyfin.models.View
|
|||
import dev.jdtech.jellyfin.models.ViewItem
|
||||
import org.jellyfin.sdk.model.api.BaseItemDto
|
||||
import org.jellyfin.sdk.model.api.BaseItemPerson
|
||||
import java.util.*
|
||||
|
||||
@BindingAdapter("servers")
|
||||
fun bindServers(recyclerView: RecyclerView, data: List<Server>?) {
|
||||
|
@ -62,6 +63,19 @@ fun bindItemBackdropImage(imageView: ImageView, item: BaseItemDto?) {
|
|||
}
|
||||
}
|
||||
|
||||
@BindingAdapter("itemBackdropById")
|
||||
fun bindItemBackdropById(imageView: ImageView, itemId: UUID) {
|
||||
if (itemId != null) {
|
||||
val jellyfinApi = JellyfinApi.getInstance(imageView.context.applicationContext, "")
|
||||
|
||||
Glide
|
||||
.with(imageView.context)
|
||||
.load(jellyfinApi.api.baseUrl.plus("/items/${itemId}/Images/Backdrop"))
|
||||
.transition(DrawableTransitionOptions.withCrossFade())
|
||||
.into(imageView)
|
||||
}
|
||||
}
|
||||
|
||||
@BindingAdapter("collections")
|
||||
fun bindCollections(recyclerView: RecyclerView, data: List<BaseItemDto>?) {
|
||||
val adapter = recyclerView.adapter as CollectionListAdapter
|
||||
|
@ -121,3 +135,15 @@ fun bindEpisodeImage(imageView: ImageView, episode: BaseItemDto) {
|
|||
|
||||
imageView.contentDescription = "${episode.name} poster"
|
||||
}
|
||||
|
||||
@BindingAdapter("seasonPoster")
|
||||
fun bindSeasonPoster(imageView: ImageView, seasonId: UUID) {
|
||||
val jellyfinApi = JellyfinApi.getInstance(imageView.context.applicationContext, "")
|
||||
|
||||
Glide
|
||||
.with(imageView.context)
|
||||
.load(jellyfinApi.api.baseUrl.plus("/items/${seasonId}/Images/Primary"))
|
||||
.transition(DrawableTransitionOptions.withCrossFade())
|
||||
.placeholder(R.color.neutral_800)
|
||||
.into(imageView)
|
||||
}
|
|
@ -64,6 +64,7 @@ class MediaInfoFragment : Fragment() {
|
|||
MediaInfoFragmentDirections.actionMediaInfoFragmentToSeasonFragment(
|
||||
it.seriesId!!,
|
||||
it.id,
|
||||
it.seriesName,
|
||||
it.name
|
||||
)
|
||||
)
|
||||
|
|
|
@ -38,6 +38,10 @@ class SeasonFragment : Fragment() {
|
|||
viewModel = ViewModelProvider(this, viewModelFactory).get(SeasonViewModel::class.java)
|
||||
binding.viewModel = viewModel
|
||||
binding.episodesRecyclerView.adapter = EpisodeListAdapter()
|
||||
binding.seriesName.text = args.seriesName
|
||||
binding.seasonName.text = args.seasonName
|
||||
binding.seriesId = args.seriesId
|
||||
binding.seasonId = args.seasonId
|
||||
}
|
||||
|
||||
}
|
|
@ -55,7 +55,8 @@
|
|||
android:text="@{viewModel.item.name}"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Headline5"
|
||||
app:layout_constraintBottom_toTopOf="@id/original_title"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
tools:text="Alita: Battle Angel"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/original_title"
|
||||
|
|
|
@ -9,21 +9,99 @@
|
|||
<variable
|
||||
name="viewModel"
|
||||
type="dev.jdtech.jellyfin.viewmodels.SeasonViewModel" />
|
||||
|
||||
<variable
|
||||
name="seriesId"
|
||||
type="java.util.UUID" />
|
||||
|
||||
<variable
|
||||
name="seasonId"
|
||||
type="java.util.UUID" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="200dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/item_banner"
|
||||
itemBackdropById="@{seriesId}"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="200dp"
|
||||
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" />
|
||||
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
android:id="@+id/season_poster"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="24dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:elevation="8dp"
|
||||
android:scaleType="centerCrop"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintDimensionRatio="H,3:2"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:seasonPoster="@{seasonId}"
|
||||
app:shapeAppearanceOverlay="@style/roundedImageView" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/series_name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="24dp"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Body1"
|
||||
app:layout_constraintBottom_toTopOf="@id/season_name"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/season_poster"
|
||||
tools:text="Attack on Titan" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/season_name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="24dp"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Headline5"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/season_poster"
|
||||
tools:text="Season 1" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/buttons"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="24dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:layout_marginBottom="24dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
app:layout_constraintTop_toBottomOf="@id/header">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/play_button"
|
||||
|
@ -36,16 +114,6 @@
|
|||
android:paddingVertical="12dp"
|
||||
android:src="@drawable/ic_play" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/trailer_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:background="@drawable/button_accent_background"
|
||||
android:contentDescription="@string/trailer_button_description"
|
||||
android:padding="12dp"
|
||||
android:src="@drawable/ic_film" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/shuffle_button"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
@ -94,6 +94,11 @@
|
|||
<argument
|
||||
android:name="seasonId"
|
||||
app:argType="java.util.UUID" />
|
||||
<argument
|
||||
android:name="seriesName"
|
||||
app:argType="string"
|
||||
app:nullable="true"
|
||||
android:defaultValue="Series" />
|
||||
<argument
|
||||
android:name="seasonName"
|
||||
android:defaultValue="Season"
|
||||
|
|
Loading…
Reference in a new issue