tv layout fixed

This commit is contained in:
reduplicated 2022-08-06 18:08:20 +02:00
parent 3a2041c52f
commit f063a4b3a1
3 changed files with 119 additions and 35 deletions

View File

@ -243,7 +243,7 @@ open class ResultFragment : ResultTrailerPlayer() {
private var updateUIListener: (() -> Unit)? = null
}
open fun setTrailers(trailers: List<ExtractorLink>?) { }
open fun setTrailers(trailers: List<ExtractorLink>?) {}
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<Pair<UiText, ResultEpisode>>) {
open fun updateMovie(data: ResourceSome<Pair<UiText, ResultEpisode>>) {
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<List<ResultEpisode>>) {
open fun updateEpisodes(episodes: ResourceSome<List<ResultEpisode>>) {
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()

View File

@ -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<SearchResponse> = 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<SearchResponse>?, 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(

View File

@ -189,16 +189,42 @@
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/result_title"
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:maxLines="2"
android:textColor="?attr/textColor"
android:textSize="20sp"
android:textStyle="bold"
tools:text="The Perfect Run The Perfect Run" />
android:layout_marginBottom="10dp"
android:layout_height="30dp">
<ImageView
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:layout_marginEnd="10dp"
android:nextFocusDown="@id/result_description"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:id="@+id/result_back"
android:clickable="true"
android:focusable="true"
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/ic_baseline_arrow_back_24"
android:contentDescription="@string/go_back"
app:tint="?attr/white" />
<TextView
android:id="@+id/result_title"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:gravity="center_vertical"
android:layout_marginBottom="5dp"
android:maxLines="1"
android:textColor="?attr/textColor"
android:textSize="20sp"
android:textStyle="bold"
tools:text="The Perfect Run The Perfect Run" />
</LinearLayout>
<com.lagradost.cloudstream3.widget.FlowLayout
android:layout_width="match_parent"
@ -687,6 +713,7 @@
<androidx.recyclerview.widget.RecyclerView
android:nextFocusUp="@id/result_dub_selection"
android:nextFocusDown="@id/result_recommendations_filter_selection"
android:id="@+id/result_episodes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -696,8 +723,49 @@
tools:listitem="@layout/result_episode" />
</LinearLayout>
</LinearLayout>
<include layout="@layout/result_recommendations" />
<LinearLayout
android:id="@+id/result_recommendations_holder"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.recyclerview.widget.RecyclerView
tools:itemCount="2"
android:nextFocusUp="@id/result_episodes"
android:nextFocusDown="@id/result_recommendations"
android:id="@+id/result_recommendations_filter_selection"
android:layout_marginEnd="10dp"
tools:listitem="@layout/result_selection"
android:orientation="horizontal"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:gravity="center_vertical"
android:layout_gravity="center_vertical"
android:textSize="17sp"
android:textColor="?attr/textColor"
android:text="@string/recommended"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<com.lagradost.cloudstream3.ui.AutofitRecyclerView
android:nextFocusUp="@id/result_recommendations_filter_selection"
android:descendantFocusability="afterDescendants"
android:background="?attr/primaryBlackBackground"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
app:spanCount="8"
android:id="@+id/result_recommendations"
tools:listitem="@layout/search_result_grid"
android:orientation="vertical" />
</LinearLayout>
</LinearLayout>