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)) {
episodePoster.setOnClickListener {
clickCallback.invoke(EpisodeClickEvent(ACTION_CLICK_DEFAULT, card))
@ -302,7 +304,7 @@ class EpisodeAdapter(
fun bind(card: ResultEpisode) {
binding.episodeHolder.layoutParams.apply {
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 {
@ -355,6 +357,8 @@ class EpisodeAdapter(
episodeProgress.isVisible = displayPos > 0L
}
episodeUpcoming.isVisible = card.isUpcoming == true
itemView.setOnClickListener {
clickCallback.invoke(EpisodeClickEvent(ACTION_CLICK_DEFAULT, card))
}

View file

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

View file

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

View file

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

View file

@ -100,6 +100,13 @@
android:layout_height="wrap_content"
android:textColor="?attr/grayTextColor"
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>
<com.lagradost.cloudstream3.ui.download.button.PieFetchButton

View file

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