From f063a4b3a1275ab612cb204f4ee001531855f772 Mon Sep 17 00:00:00 2001 From: reduplicated <110570621+reduplicated@users.noreply.github.com> Date: Sat, 6 Aug 2022 18:08:20 +0200 Subject: [PATCH] tv layout fixed --- .../cloudstream3/ui/result/ResultFragment.kt | 36 +++++--- .../ui/result/ResultFragmentTv.kt | 30 ++++--- .../main/res/layout/fragment_result_tv.xml | 88 ++++++++++++++++--- 3 files changed, 119 insertions(+), 35 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt index 8b1c5c0a..3e060d67 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt @@ -243,7 +243,7 @@ open class ResultFragment : ResultTrailerPlayer() { private var updateUIListener: (() -> Unit)? = null } - open fun setTrailers(trailers: List?) { } + open fun setTrailers(trailers: List?) {} protected lateinit var viewModel: ResultViewModel2 //by activityViewModels() protected lateinit var syncModel: SyncViewModel @@ -328,7 +328,7 @@ open class ResultFragment : ResultTrailerPlayer() { viewModel.reloadEpisodes() } - open fun updateMovie(data : ResourceSome>) { + open fun updateMovie(data: ResourceSome>) { when (data) { is ResourceSome.Success -> { data.value.let { (text, ep) -> @@ -381,7 +381,7 @@ open class ResultFragment : ResultTrailerPlayer() { System.currentTimeMillis(), ) ) { click -> - when(click.action) { + when (click.action) { DOWNLOAD_ACTION_DOWNLOAD -> { viewModel.handleAction( activity, @@ -402,7 +402,7 @@ open class ResultFragment : ResultTrailerPlayer() { } } - open fun updateEpisodes(episodes : ResourceSome>) { + open fun updateEpisodes(episodes: ResourceSome>) { when (episodes) { is ResourceSome.None -> { result_episode_loading?.isVisible = false @@ -462,7 +462,12 @@ open class ResultFragment : ResultTrailerPlayer() { arguments?.remove(START_VALUE_BUNDLE) arguments?.remove(START_ACTION_BUNDLE) - AutoResume(startAction = action, id = startValue, episode = resumeEpisode, season = resumeSeason) + AutoResume( + startAction = action, + id = startValue, + episode = resumeEpisode, + season = resumeSeason + ) } syncModel.addFromUrl(url) @@ -845,15 +850,16 @@ open class ResultFragment : ResultTrailerPlayer() { } result_description.setTextHtml(d.plotText) - result_description?.setOnClickListener { view -> - view.context?.let { ctx -> - val builder: AlertDialog.Builder = - AlertDialog.Builder(ctx, R.style.AlertDialogCustom) - builder.setMessage(d.plotText.asString(ctx).html()) - .setTitle(d.plotHeaderText.asString(ctx)) - .show() + if (this !is ResultFragmentTv) // dont want this clickable on tv layout + result_description?.setOnClickListener { view -> + view.context?.let { ctx -> + val builder: AlertDialog.Builder = + AlertDialog.Builder(ctx, R.style.AlertDialogCustom) + builder.setMessage(d.plotText.asString(ctx).html()) + .setTitle(d.plotHeaderText.asString(ctx)) + .show() + } } - } result_tag?.removeAllViews() @@ -889,7 +895,9 @@ open class ResultFragment : ResultTrailerPlayer() { } context?.let { ctx -> - val dubStatus = if(ctx.getApiDubstatusSettings().contains(DubStatus.Dubbed)) DubStatus.Dubbed else DubStatus.Subbed + val dubStatus = if (ctx.getApiDubstatusSettings() + .contains(DubStatus.Dubbed) + ) DubStatus.Dubbed else DubStatus.Subbed result_bookmark_button?.isVisible = ctx.isTvSettings() diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentTv.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentTv.kt index eae5250b..bdb84402 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentTv.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentTv.kt @@ -2,11 +2,9 @@ package com.lagradost.cloudstream3.ui.result import android.os.Bundle import android.view.View -import androidx.core.view.children import androidx.core.view.isGone import androidx.core.view.isVisible import androidx.recyclerview.widget.RecyclerView -import com.discord.panels.OverlappingPanelsLayout import com.lagradost.cloudstream3.DubStatus import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.SearchResponse @@ -14,14 +12,14 @@ import com.lagradost.cloudstream3.mvvm.ResourceSome import com.lagradost.cloudstream3.mvvm.observe import com.lagradost.cloudstream3.ui.search.SearchAdapter import com.lagradost.cloudstream3.ui.search.SearchHelper -import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showBottomDialog -import kotlinx.android.synthetic.main.fragment_result_swipe.* +import com.lagradost.cloudstream3.utils.UIHelper.popCurrentPage import kotlinx.android.synthetic.main.fragment_result_tv.* -import kotlinx.android.synthetic.main.result_recommendations.* class ResultFragmentTv : ResultFragment() { override val resultLayout = R.layout.fragment_result_tv + private var currentRecommendations: List = emptyList() + private fun handleSelection(data: Any) { when (data) { is EpisodeRange -> { @@ -33,6 +31,9 @@ class ResultFragmentTv : ResultFragment() { is DubStatus -> { viewModel.changeDubStatus(data) } + is String -> { + setRecommendations(currentRecommendations, data) + } } } @@ -72,19 +73,21 @@ class ResultFragmentTv : ResultFragment() { } override fun setRecommendations(rec: List?, validApiName: String?) { + currentRecommendations = rec ?: emptyList() val isInvalid = rec.isNullOrEmpty() result_recommendations?.isGone = isInvalid - result_recommendations_btt?.isGone = isInvalid + result_recommendations_holder?.isGone = isInvalid val matchAgainst = validApiName ?: rec?.firstOrNull()?.apiName - (result_recommendations?.adapter as SearchAdapter?)?.updateList(rec?.filter { it.apiName == matchAgainst } ?: emptyList()) + (result_recommendations?.adapter as SearchAdapter?)?.updateList(rec?.filter { it.apiName == matchAgainst } + ?: emptyList()) rec?.map { it.apiName }?.distinct()?.let { apiNames -> // very dirty selection - result_recommendations_filter_button?.isVisible = apiNames.size > 1 - result_recommendations_filter_button?.text = matchAgainst - + result_recommendations_filter_selection?.isVisible = apiNames.size > 1 + result_recommendations_filter_selection?.update(apiNames.map { txt(it) to it }) + result_recommendations_filter_selection?.select(apiNames.indexOf(matchAgainst)) } ?: run { - result_recommendations_filter_button?.isVisible = false + result_recommendations_filter_selection?.isVisible = false } } @@ -97,6 +100,7 @@ class ResultFragmentTv : ResultFragment() { result_season_selection.setAdapter() result_range_selection.setAdapter() result_dub_selection.setAdapter() + result_recommendations_filter_selection.setAdapter() observe(viewModel.selectedRangeIndex) { selected -> result_range_selection.select(selected) @@ -117,6 +121,10 @@ class ResultFragmentTv : ResultFragment() { result_season_selection.update(it) } + result_back?.setOnClickListener { + activity?.popCurrentPage() + } + result_recommendations?.spanCount = 8 result_recommendations?.adapter = SearchAdapter( diff --git a/app/src/main/res/layout/fragment_result_tv.xml b/app/src/main/res/layout/fragment_result_tv.xml index 6e740271..37f0375c 100644 --- a/app/src/main/res/layout/fragment_result_tv.xml +++ b/app/src/main/res/layout/fragment_result_tv.xml @@ -189,16 +189,42 @@ android:layout_height="match_parent" android:orientation="vertical"> - + android:layout_marginBottom="10dp" + android:layout_height="30dp"> + + + + - + + + + + + +