New TV UI bug fixes (#983)

This commit is contained in:
KingLucius 2024-03-16 04:50:49 +02:00 committed by GitHub
parent 4817b29b9c
commit 638cc4fee9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 28 additions and 32 deletions

View file

@ -309,9 +309,10 @@ class ResultFragmentTv : Fragment() {
resultEpisodesShowButton to resultEpisodesShowText resultEpisodesShowButton to resultEpisodesShowText
).forEach { (button , text) -> ).forEach { (button , text) ->
button.setOnFocusChangeListener { _, hasFocus -> button.setOnFocusChangeListener { view, hasFocus ->
if (!hasFocus) { if (!hasFocus) {
text.isSelected = false text.isSelected = false
if (view.id == R.id.result_episodes_show_button) toggleEpisodes(false)
return@setOnFocusChangeListener return@setOnFocusChangeListener
} }
@ -377,10 +378,6 @@ class ResultFragmentTv : Fragment() {
resultMetaSite.isFocusable = false resultMetaSite.isFocusable = false
//resultReloadConnectionOpenInBrowser.setOnClickListener {view ->
// view.context?.openBrowser(storedData?.url ?: return@setOnClickListener, fallbackWebview = true)
//}
resultSeasonSelection.setAdapter() resultSeasonSelection.setAdapter()
resultRangeSelection.setAdapter() resultRangeSelection.setAdapter()
resultDubSelection.setAdapter() resultDubSelection.setAdapter()
@ -458,11 +455,12 @@ class ResultFragmentTv : Fragment() {
observeNullable(viewModel.resumeWatching) { resume -> observeNullable(viewModel.resumeWatching) { resume ->
binding?.apply { binding?.apply {
// > resultResumeSeries is visible when not null
if (resume == null) { if (resume == null) {
resultResumeSeries.isVisible = false
return@observeNullable return@observeNullable
} }
resultResumeSeries.isVisible = true
resultPlayMovie.isVisible = false
resultPlaySeries.isVisible = false
// show progress no matter if series or movie // show progress no matter if series or movie
resume.progress?.let { progress -> resume.progress?.let { progress ->
@ -477,10 +475,6 @@ class ResultFragmentTv : Fragment() {
resultResumeProgressHolder.isVisible = false resultResumeProgressHolder.isVisible = false
} }
resultPlayMovie.isVisible = false
resultPlaySeries.isVisible = false
resultResumeSeries.isVisible = true
focusPlayButton() focusPlayButton()
// Stops last button right focus if it is a movie // Stops last button right focus if it is a movie
if (resume.isMovie) if (resume.isMovie)
@ -491,7 +485,7 @@ class ResultFragmentTv : Fragment() {
resume.isMovie -> context?.getString(R.string.resume) resume.isMovie -> context?.getString(R.string.resume)
resume.result.season != null -> resume.result.season != null ->
"${getString(R.string.season_short)}${resume.result.season}:${getString(R.string.episode_short)}${resume.result.episode}" "${getString(R.string.season_short)}${resume.result.season}:${getString(R.string.episode_short)}${resume.result.episode}"
else -> "${getString(R.string.episode)}${resume.result.episode}" else -> "${getString(R.string.episode)} ${resume.result.episode}"
} }
resultResumeSeriesButton.setOnClickListener { resultResumeSeriesButton.setOnClickListener {
@ -647,15 +641,14 @@ class ResultFragmentTv : Fragment() {
} }
observeNullable(viewModel.movie) { data -> observeNullable(viewModel.movie) { data ->
if (data == null) return@observeNullable if (data == null ) {
return@observeNullable
}
binding?.apply { binding?.apply {
resultPlayMovie.isVisible = (data is Resource.Success) && !comingSoon
resultPlaySeries.isVisible = false
resultEpisodesShow.isVisible = false
(data as? Resource.Success)?.value?.let { (text, ep) -> (data as? Resource.Success)?.value?.let { (text, ep) ->
//resultPlayMovieText.setText(text)
resultPlayMovieButton.setOnClickListener { resultPlayMovieButton.setOnClickListener {
viewModel.handleAction( viewModel.handleAction(
EpisodeClickEvent(ACTION_CLICK_DEFAULT, ep) EpisodeClickEvent(ACTION_CLICK_DEFAULT, ep)
@ -667,14 +660,17 @@ class ResultFragmentTv : Fragment() {
) )
return@setOnLongClickListener true return@setOnLongClickListener true
} }
//focusPlayButton()
resultPlayMovieButton.requestFocus() resultPlayMovie.isVisible = !comingSoon && resultResumeSeries.isGone
if (comingSoon)
resultBookmarkButton.requestFocus()
else
resultPlayMovieButton.requestFocus()
// Stops last button right focus // Stops last button right focus
resultSearchButton.nextFocusRightId = R.id.result_search_Button resultSearchButton.nextFocusRightId = R.id.result_search_Button
} }
} }
//focusPlayButton()
} }
observeNullable(viewModel.selectPopup) { popup -> observeNullable(viewModel.selectPopup) { popup ->
@ -778,16 +774,14 @@ class ResultFragmentTv : Fragment() {
binding?.apply { binding?.apply {
resultPlayMovie.isVisible = false if (comingSoon)
resultPlaySeries.isVisible = true && !comingSoon resultBookmarkButton.requestFocus()
resultEpisodes.isVisible = true && !comingSoon
resultEpisodesShow.isVisible = true && !comingSoon
// resultEpisodeLoading.isVisible = episodes is Resource.Loading // resultEpisodeLoading.isVisible = episodes is Resource.Loading
if (episodes is Resource.Success) { if (episodes is Resource.Success) {
val first = episodes.value.firstOrNull() val first = episodes.value.firstOrNull()
if (first != null) { if (first != null) {
resultPlaySeriesText.text = //"${getString(R.string.season_short)}${first.season}:${getString(R.string.episode_short)}${first.episode}" resultPlaySeriesText.text =
when { when {
first.season != null -> first.season != null ->
"${getString(R.string.season_short)}${first.season}:${getString(R.string.episode_short)}${first.episode}" "${getString(R.string.season_short)}${first.season}:${getString(R.string.episode_short)}${first.episode}"
@ -809,8 +803,9 @@ class ResultFragmentTv : Fragment() {
} }
if (!hasLoadedEpisodesOnce) { if (!hasLoadedEpisodesOnce) {
hasLoadedEpisodesOnce = true hasLoadedEpisodesOnce = true
focusPlayButton() resultPlaySeries.isVisible = resultResumeSeries.isGone && !comingSoon
resultPlaySeries.requestFocus() resultEpisodesShow.isVisible = true && !comingSoon
resultPlaySeriesButton.requestFocus()
} }
} }
@ -919,9 +914,6 @@ class ResultFragmentTv : Fragment() {
) )
comingSoon = d.comingSoon comingSoon = d.comingSoon
resultTvComingSoon.isVisible = d.comingSoon resultTvComingSoon.isVisible = d.comingSoon
resultPlayMovie.isGone = d.comingSoon
resultPlaySeries.isGone = d.comingSoon
resultDataHolder.isGone = d.comingSoon
UIHelper.populateChips(resultTag, d.tags) UIHelper.populateChips(resultTag, d.tags)
resultCastItems.isGone = d.actors.isNullOrEmpty() resultCastItems.isGone = d.actors.isNullOrEmpty()

View file

@ -271,7 +271,9 @@ https://developer.android.com/design/ui/tv/samples/jet-fit
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:id="@+id/result_play_movie" android:id="@+id/result_play_movie"
android:orientation="vertical"> android:orientation="vertical"
android:visibility="gone"
tools:visibility="visible">
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
android:id="@+id/result_play_movie_button" android:id="@+id/result_play_movie_button"
@ -323,7 +325,9 @@ https://developer.android.com/design/ui/tv/samples/jet-fit
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:orientation="vertical"> android:orientation="vertical"
android:visibility="gone"
tools:visibility="visible">
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
android:id="@+id/result_resume_series_button" android:id="@+id/result_resume_series_button"