forked from recloudstream/cloudstream
Added trailers and poster to TV
This commit is contained in:
parent
b6b7cceea5
commit
5b26c998b4
6 changed files with 176 additions and 59 deletions
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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<ExtractorLink>,
|
||||
private val subtitles: List<SubtitleData>,
|
||||
) : IGenerator {
|
||||
override val hasCache = false
|
||||
|
||||
override fun getCurrentId(): Int? {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun hasNext(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun getAll(): List<Any>? {
|
||||
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<ExtractorLink?, ExtractorUri?>) -> Unit,
|
||||
subtitleCallback: (SubtitleData) -> Unit,
|
||||
offset: Int
|
||||
): Boolean {
|
||||
subtitles.forEach(subtitleCallback)
|
||||
links.forEach {
|
||||
callback.invoke(it to null)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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<ExtractorLink>?) {
|
||||
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<SearchResponse>?, validApiName: String?) {
|
||||
currentRecommendations = rec ?: emptyList()
|
||||
val isInvalid = rec.isNullOrEmpty()
|
||||
|
|
|
@ -227,6 +227,33 @@
|
|||
tools:text="The Perfect Run The Perfect Run" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/result_poster_holder"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="10dp"
|
||||
app:cardCornerRadius="@dimen/rounded_image_radius">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/result_poster"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="140dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:contentDescription="@string/result_poster_img_des"
|
||||
android:foreground="@drawable/outline_drawable"
|
||||
android:scaleType="centerCrop"
|
||||
tools:src="@drawable/example_poster" />
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.lagradost.cloudstream3.widget.FlowLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -264,7 +291,6 @@
|
|||
style="@style/ResultInfoText"
|
||||
tools:text="121min" />
|
||||
</com.lagradost.cloudstream3.widget.FlowLayout>
|
||||
|
||||
<!--
|
||||
This has half margin and half padding to make TV focus on description look better.
|
||||
The focus outline now settles between the poster and text.
|
||||
|
@ -285,6 +311,10 @@
|
|||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/result_cast_text"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -392,6 +422,7 @@
|
|||
|
||||
|
||||
<LinearLayout
|
||||
android:animateLayoutChanges="true"
|
||||
android:id="@+id/result_movie_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -409,7 +440,7 @@
|
|||
android:layout_marginBottom="10dp"
|
||||
android:layout_weight="1"
|
||||
android:minWidth="250dp"
|
||||
android:nextFocusRight="@id/result_download_movie"
|
||||
android:nextFocusRight="@id/result_play_trailer"
|
||||
android:nextFocusUp="@id/result_cast_items"
|
||||
android:nextFocusDown="@id/result_resume_series_button_play"
|
||||
android:text="@string/play_movie_button"
|
||||
|
@ -418,6 +449,22 @@
|
|||
|
||||
</com.google.android.material.button.MaterialButton>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/result_play_trailer"
|
||||
style="@style/WhiteButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_marginStart="0dp"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_weight="1"
|
||||
android:minWidth="250dp"
|
||||
android:nextFocusUp="@id/result_cast_items"
|
||||
android:nextFocusDown="@id/result_resume_series_button_play"
|
||||
android:text="@string/play_trailer_button"
|
||||
android:visibility="gone"
|
||||
app:icon="@drawable/ic_baseline_play_arrow_24">
|
||||
|
||||
</com.google.android.material.button.MaterialButton>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/result_movie_progress_downloaded_holder"
|
||||
|
@ -440,7 +487,7 @@
|
|||
android:layout_marginEnd="0dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:nextFocusLeft="@id/result_play_movie"
|
||||
android:nextFocusLeft="@id/result_play_trailer"
|
||||
android:nextFocusUp="@id/result_cast_items"
|
||||
android:nextFocusDown="@id/result_resume_series_button_play"
|
||||
|
||||
|
|
|
@ -119,6 +119,7 @@
|
|||
<string name="type_none">None</string>
|
||||
<string name="type_re_watching">Rewatching</string>
|
||||
<string name="play_movie_button">Play Movie</string>
|
||||
<string name="play_trailer_button">Play Trailer</string>
|
||||
<string name="play_livestream_button">Play Livestream</string>
|
||||
<string name="play_torrent_button">Stream Torrent</string>
|
||||
<string name="pick_source">Sources</string>
|
||||
|
|
Loading…
Reference in a new issue