Upcoming Tag for Episodes

This commit is contained in:
KingLucius 2024-04-10 14:17:45 +02:00
parent 0a24661e4c
commit 6186dafe9e
7 changed files with 48 additions and 17 deletions

View file

@ -260,6 +260,8 @@ class EpisodeAdapter(
} }
} }
episodeUpcoming.isVisible = card.isUpcoming == true
if (isLayout(EMULATOR or PHONE)) { if (isLayout(EMULATOR or PHONE)) {
episodePoster.setOnClickListener { episodePoster.setOnClickListener {
clickCallback.invoke(EpisodeClickEvent(ACTION_CLICK_DEFAULT, card)) clickCallback.invoke(EpisodeClickEvent(ACTION_CLICK_DEFAULT, card))
@ -302,7 +304,7 @@ class EpisodeAdapter(
fun bind(card: ResultEpisode) { fun bind(card: ResultEpisode) {
binding.episodeHolder.layoutParams.apply { binding.episodeHolder.layoutParams.apply {
width = width =
if (isLayout(TV or EMULATOR)) TV_EP_SIZE_SMALL.toPx else ViewGroup.LayoutParams.MATCH_PARENT if (isLayout(TV or EMULATOR)) TV_EP_SIZE_LARGE.toPx else ViewGroup.LayoutParams.MATCH_PARENT
} }
binding.apply { binding.apply {
@ -355,6 +357,8 @@ class EpisodeAdapter(
episodeProgress.isVisible = displayPos > 0L episodeProgress.isVisible = displayPos > 0L
} }
episodeUpcoming.isVisible = card.isUpcoming == true
itemView.setOnClickListener { itemView.setOnClickListener {
clickCallback.invoke(EpisodeClickEvent(ACTION_CLICK_DEFAULT, card)) clickCallback.invoke(EpisodeClickEvent(ACTION_CLICK_DEFAULT, card))
} }

View file

@ -50,6 +50,7 @@ data class ResultEpisode(
val videoWatchState: VideoWatchState, val videoWatchState: VideoWatchState,
/** Sum of all previous season episode counts + episode */ /** Sum of all previous season episode counts + episode */
val totalEpisodeIndex: Int? = null, val totalEpisodeIndex: Int? = null,
val isUpcoming: Boolean? = false,
) )
fun ResultEpisode.getRealPosition(): Long { fun ResultEpisode.getRealPosition(): Long {
@ -85,6 +86,7 @@ fun buildResultEpisode(
tvType: TvType, tvType: TvType,
parentId: Int, parentId: Int,
totalEpisodeIndex: Int? = null, totalEpisodeIndex: Int? = null,
isUpcoming: Boolean? = false
): ResultEpisode { ): ResultEpisode {
val posDur = getViewPos(id) val posDur = getViewPos(id)
val videoWatchState = getVideoWatchState(id) ?: VideoWatchState.None val videoWatchState = getVideoWatchState(id) ?: VideoWatchState.None
@ -107,7 +109,8 @@ fun buildResultEpisode(
tvType, tvType,
parentId, parentId,
videoWatchState, videoWatchState,
totalEpisodeIndex totalEpisodeIndex,
isUpcoming
) )
} }

View file

@ -2252,6 +2252,8 @@ class ResultViewModel2 : ViewModel() {
val totalIndex = val totalIndex =
i.season?.let { season -> loadResponse.getTotalEpisodeIndex(episode, season) } i.season?.let { season -> loadResponse.getTotalEpisodeIndex(episode, season) }
val isUpcoming = if (i.date == null) false else (unixTimeMS < i.date!!)
if (!existingEpisodes.contains(id)) { if (!existingEpisodes.contains(id)) {
existingEpisodes.add(id) existingEpisodes.add(id)
val seasonData = loadResponse.seasonNames.getSeason(i.season) val seasonData = loadResponse.seasonNames.getSeason(i.season)
@ -2272,7 +2274,8 @@ class ResultViewModel2 : ViewModel() {
fillers.getOrDefault(episode, false), fillers.getOrDefault(episode, false),
loadResponse.type, loadResponse.type,
mainId, mainId,
totalIndex totalIndex,
isUpcoming
) )
val season = eps.seasonIndex ?: 0 val season = eps.seasonIndex ?: 0
@ -2304,6 +2307,8 @@ class ResultViewModel2 : ViewModel() {
val totalIndex = val totalIndex =
episode.season?.let { season -> loadResponse.getTotalEpisodeIndex(episodeIndex, season) } episode.season?.let { season -> loadResponse.getTotalEpisodeIndex(episodeIndex, season) }
val isUpcoming = if (episode.date == null) false else (unixTimeMS < episode.date!!)
val ep = val ep =
buildResultEpisode( buildResultEpisode(
loadResponse.name, loadResponse.name,
@ -2321,7 +2326,8 @@ class ResultViewModel2 : ViewModel() {
null, null,
loadResponse.type, loadResponse.type,
mainId, mainId,
totalIndex totalIndex,
isUpcoming,
) )
val season = ep.seasonIndex ?: 0 val season = ep.seasonIndex ?: 0

View file

@ -674,7 +674,7 @@ https://developer.android.com/design/ui/tv/samples/jet-fit
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="end" android:layout_gravity="end"
android:visibility="gone" android:visibility="gone"
tools:visibility="invisible"> tools:visibility="visible">
<!-- <!--

View file

@ -9,7 +9,7 @@
android:layout_marginBottom="5dp" android:layout_marginBottom="5dp"
android:nextFocusRight="@id/download_button" android:nextFocusRight="@id/download_button"
app:cardBackgroundColor="@color/transparent" app:cardBackgroundColor="?attr/boxItemBackground"
app:cardCornerRadius="@dimen/rounded_image_radius" app:cardCornerRadius="@dimen/rounded_image_radius"
app:cardElevation="0dp" app:cardElevation="0dp"
android:foreground="@drawable/outline_drawable" android:foreground="@drawable/outline_drawable"
@ -75,11 +75,11 @@
<TextView <TextView
android:id="@+id/episode_text" android:id="@+id/episode_text"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:layout_marginEnd="50dp"
android:ellipsize="marquee" android:ellipsize="marquee"
android:gravity="center_vertical" android:gravity="center_vertical"
@ -90,14 +90,24 @@
android:textColor="?attr/textColor" android:textColor="?attr/textColor"
tools:text="Episode 1" /> tools:text="Episode 1" />
</LinearLayout>
<com.google.android.material.button.MaterialButton
android:id="@+id/episode_upcoming"
style="@style/SmallBlackButton"
android:textColor="?attr/colorPrimary"
android:layout_marginStart="2dp"
android:layout_marginEnd="10dp"
android:layout_gravity="center_vertical|end"
android:text="@string/episode_upcoming"
android:visibility="gone"
tools:visibility="visible"/>
<com.lagradost.cloudstream3.ui.download.button.PieFetchButton <com.lagradost.cloudstream3.ui.download.button.PieFetchButton
android:id="@+id/download_button" android:id="@+id/download_button"
android:layout_width="@dimen/download_size" android:layout_width="@dimen/download_size"
android:layout_height="@dimen/download_size" android:layout_height="@dimen/download_size"
android:layout_gravity="center_vertical|end" android:layout_gravity="center_vertical|end"
android:layout_marginStart="-50dp"
android:background="?selectableItemBackgroundBorderless" android:background="?selectableItemBackgroundBorderless"
android:padding="10dp" /> android:padding="10dp" />
</LinearLayout>
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>

View file

@ -100,6 +100,13 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textColor="?attr/grayTextColor" android:textColor="?attr/grayTextColor"
tools:text="Rated: 8.8" /> tools:text="Rated: 8.8" />
<com.google.android.material.button.MaterialButton
android:id="@+id/episode_upcoming"
style="@style/SmallBlackButton"
android:textColor="?attr/colorPrimary"
android:text="@string/episode_upcoming"
android:visibility="gone"
tools:visibility="visible"/>
</LinearLayout> </LinearLayout>
<com.lagradost.cloudstream3.ui.download.button.PieFetchButton <com.lagradost.cloudstream3.ui.download.button.PieFetchButton

View file

@ -767,4 +767,5 @@
<string name="music_singlar">Music</string> <string name="music_singlar">Music</string>
<string name="audio_book_singular">Audio Book</string> <string name="audio_book_singular">Audio Book</string>
<string name="custom_media_singluar">Media</string> <string name="custom_media_singluar">Media</string>
<string name="episode_upcoming">UPCOMING</string>
</resources> </resources>