From 4329b764486668efa649a021f3b44ff0d1017cca Mon Sep 17 00:00:00 2001 From: Jarne Demeulemeester Date: Mon, 28 Jun 2021 13:08:04 +0200 Subject: [PATCH] Add header to SeasonFragment --- .../dev/jdtech/jellyfin/BindingAdapters.kt | 26 ++++++ .../jellyfin/fragments/MediaInfoFragment.kt | 1 + .../jellyfin/fragments/SeasonFragment.kt | 4 + .../main/res/layout/fragment_media_info.xml | 3 +- app/src/main/res/layout/fragment_season.xml | 90 ++++++++++++++++--- .../main/res/navigation/main_navigation.xml | 5 ++ 6 files changed, 117 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/dev/jdtech/jellyfin/BindingAdapters.kt b/app/src/main/java/dev/jdtech/jellyfin/BindingAdapters.kt index 97944df5..c0579674 100644 --- a/app/src/main/java/dev/jdtech/jellyfin/BindingAdapters.kt +++ b/app/src/main/java/dev/jdtech/jellyfin/BindingAdapters.kt @@ -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?) { @@ -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?) { val adapter = recyclerView.adapter as CollectionListAdapter @@ -120,4 +134,16 @@ fun bindEpisodeImage(imageView: ImageView, episode: BaseItemDto) { .into(imageView) 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) } \ No newline at end of file diff --git a/app/src/main/java/dev/jdtech/jellyfin/fragments/MediaInfoFragment.kt b/app/src/main/java/dev/jdtech/jellyfin/fragments/MediaInfoFragment.kt index 4c542db0..3664814c 100644 --- a/app/src/main/java/dev/jdtech/jellyfin/fragments/MediaInfoFragment.kt +++ b/app/src/main/java/dev/jdtech/jellyfin/fragments/MediaInfoFragment.kt @@ -64,6 +64,7 @@ class MediaInfoFragment : Fragment() { MediaInfoFragmentDirections.actionMediaInfoFragmentToSeasonFragment( it.seriesId!!, it.id, + it.seriesName, it.name ) ) diff --git a/app/src/main/java/dev/jdtech/jellyfin/fragments/SeasonFragment.kt b/app/src/main/java/dev/jdtech/jellyfin/fragments/SeasonFragment.kt index f05cae83..3273a59c 100644 --- a/app/src/main/java/dev/jdtech/jellyfin/fragments/SeasonFragment.kt +++ b/app/src/main/java/dev/jdtech/jellyfin/fragments/SeasonFragment.kt @@ -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 } } \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_media_info.xml b/app/src/main/res/layout/fragment_media_info.xml index ad79160e..2e5dc00d 100644 --- a/app/src/main/res/layout/fragment_media_info.xml +++ b/app/src/main/res/layout/fragment_media_info.xml @@ -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"/> + + + + + + + + + + + + + + + + + + + + app:layout_constraintTop_toBottomOf="@id/header"> - - +