diff --git a/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt b/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt index 1bcdf422..6565b144 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt @@ -237,7 +237,6 @@ object APIHolder { } private fun Context.getHasTrailers(): Boolean { - if (isTvSettings()) return false val settingsManager = PreferenceManager.getDefaultSharedPreferences(this) return settingsManager.getBoolean(this.getString(R.string.show_trailers_key), true) } diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/ExtractorLinkGenerator.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/ExtractorLinkGenerator.kt new file mode 100644 index 00000000..7c19e97d --- /dev/null +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/ExtractorLinkGenerator.kt @@ -0,0 +1,52 @@ +package com.lagradost.cloudstream3.ui.player + +import com.lagradost.cloudstream3.utils.ExtractorLink +import com.lagradost.cloudstream3.utils.ExtractorUri + +class ExtractorLinkGenerator( + private val links: List, + private val subtitles: List, +) : IGenerator { + override val hasCache = false + + override fun getCurrentId(): Int? { + return null + } + + override fun hasNext(): Boolean { + return false + } + + override fun getAll(): List? { + return null + } + + override fun hasPrev(): Boolean { + return false + } + + override fun getCurrent(offset: Int): Any? { + return null + } + + override fun goto(index: Int) {} + + override fun next() {} + + override fun prev() {} + + override suspend fun generateLinks( + clearCache: Boolean, + isCasting: Boolean, + callback: (Pair) -> Unit, + subtitleCallback: (SubtitleData) -> Unit, + offset: Int + ): Boolean { + subtitles.forEach(subtitleCallback) + links.forEach { + callback.invoke(it to null) + } + + return true + } +} \ No newline at end of file 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 30ea889e..3efaeff8 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 @@ -83,6 +83,8 @@ import kotlinx.android.synthetic.main.fragment_result.result_next_airing import kotlinx.android.synthetic.main.fragment_result.result_next_airing_time import kotlinx.android.synthetic.main.fragment_result.result_no_episodes import kotlinx.android.synthetic.main.fragment_result.result_play_movie +import kotlinx.android.synthetic.main.fragment_result.result_poster +import kotlinx.android.synthetic.main.fragment_result.result_poster_holder import kotlinx.android.synthetic.main.fragment_result.result_reload_connection_open_in_browser import kotlinx.android.synthetic.main.fragment_result.result_reload_connectionerror import kotlinx.android.synthetic.main.fragment_result.result_resume_parent 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 0e3ee53e..d5cab1a6 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 @@ -3,30 +3,28 @@ package com.lagradost.cloudstream3.ui.result import android.app.Dialog import android.os.Bundle import android.view.View -import android.widget.LinearLayout import androidx.core.view.isGone import androidx.core.view.isVisible import androidx.recyclerview.widget.RecyclerView import com.google.android.material.bottomsheet.BottomSheetDialog +import com.lagradost.cloudstream3.APIHolder.updateHasTrailers import com.lagradost.cloudstream3.DubStatus +import com.lagradost.cloudstream3.LoadResponse import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.SearchResponse import com.lagradost.cloudstream3.mvvm.ResourceSome import com.lagradost.cloudstream3.mvvm.Some import com.lagradost.cloudstream3.mvvm.observe +import com.lagradost.cloudstream3.ui.player.ExtractorLinkGenerator +import com.lagradost.cloudstream3.ui.player.GeneratorPlayer import com.lagradost.cloudstream3.ui.search.SearchAdapter import com.lagradost.cloudstream3.ui.search.SearchHelper -import com.lagradost.cloudstream3.utils.AppUtils.setMaxViewPoolSize +import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showBottomDialogInstant import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe +import com.lagradost.cloudstream3.utils.UIHelper.navigate import com.lagradost.cloudstream3.utils.UIHelper.popCurrentPage -import kotlinx.android.synthetic.main.fragment_home.* -import kotlinx.android.synthetic.main.fragment_result.* import kotlinx.android.synthetic.main.fragment_result_tv.* -import kotlinx.android.synthetic.main.fragment_result_tv.result_episodes -import kotlinx.android.synthetic.main.fragment_result_tv.result_episodes_text -import kotlinx.android.synthetic.main.fragment_result_tv.result_play_movie -import kotlinx.android.synthetic.main.fragment_result_tv.result_root class ResultFragmentTv : ResultFragment() { override val resultLayout = R.layout.fragment_result_tv @@ -85,6 +83,24 @@ class ResultFragmentTv : ResultFragment() { } } + override fun setTrailers(trailers: List?) { + context?.updateHasTrailers() + if (!LoadResponse.isTrailersEnabled) return + + result_play_trailer?.isGone = trailers.isNullOrEmpty() + result_play_trailer?.setOnClickListener { + if (trailers.isNullOrEmpty()) return@setOnClickListener + activity.navigate( + R.id.global_to_navigation_player, GeneratorPlayer.newInstance( + ExtractorLinkGenerator( + trailers, + emptyList() + ) + ) + ) + } + } + override fun setRecommendations(rec: List?, validApiName: String?) { currentRecommendations = rec ?: emptyList() val isInvalid = rec.isNullOrEmpty() @@ -110,7 +126,7 @@ class ResultFragmentTv : ResultFragment() { super.onViewCreated(view, savedInstanceState) result_episodes?.layoutManager = - //LinearListLayout(result_episodes ?: return, result_episodes?.context).apply { + //LinearListLayout(result_episodes ?: return, result_episodes?.context).apply { LinearListLayout(result_episodes?.context).apply { setHorizontal() } diff --git a/app/src/main/res/layout/fragment_result_tv.xml b/app/src/main/res/layout/fragment_result_tv.xml index 15e25b51..f6786196 100644 --- a/app/src/main/res/layout/fragment_result_tv.xml +++ b/app/src/main/res/layout/fragment_result_tv.xml @@ -227,61 +227,91 @@ tools:text="The Perfect Run The Perfect Run" /> - - + android:orientation="horizontal"> - + - + + - + - + - + + + + + + + + + + + + + + + + - - - - @@ -354,7 +384,7 @@ android:visibility="gone" /> - @@ -392,6 +422,7 @@ + + + None Rewatching Play Movie + Play Trailer Play Livestream Stream Torrent Sources