Skip to content

Commit

Permalink
Episodes: show play count if watched more than once
Browse files Browse the repository at this point in the history
  • Loading branch information
UweTrottmann committed Mar 14, 2024
1 parent cdd044f commit 1d259ec
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ interface SgEpisode2Helper {
@Query("SELECT _id, episode_tmdb_id, season_id, series_id, episode_number, episode_season_number, episode_plays FROM sg_episode WHERE _id = :episodeId")
fun getEpisodeNumbers(episodeId: Long): SgEpisode2Numbers?

@Query("SELECT _id, season_id, series_id, episode_tvdb_id, episode_title, episode_number, episode_absolute_number, episode_season_number, episode_dvd_number, episode_firstairedms, episode_watched, episode_collected FROM sg_episode WHERE _id = :episodeId")
@Query("SELECT _id, season_id, series_id, episode_tvdb_id, episode_title, episode_number, episode_absolute_number, episode_season_number, episode_dvd_number, episode_firstairedms, episode_watched, episode_plays, episode_collected FROM sg_episode WHERE _id = :episodeId")
fun getEpisodeInfo(episodeId: Long): SgEpisode2Info?

@RawQuery
Expand Down Expand Up @@ -127,7 +127,7 @@ interface SgEpisode2Helper {
* Get the watched or skipped episode with the latest release date, if multiple highest season,
* if multiple highest number. Or null if none found.
*/
@Query("SELECT _id, season_id, series_id, episode_tvdb_id, episode_title, episode_number, episode_absolute_number, episode_season_number, episode_dvd_number, episode_firstairedms, episode_watched, episode_collected FROM sg_episode WHERE series_id = :showId AND episode_watched != ${EpisodeFlags.UNWATCHED} ORDER BY episode_firstairedms DESC, episode_season_number DESC, episode_number DESC LIMIT 1")
@Query("SELECT _id, season_id, series_id, episode_tvdb_id, episode_title, episode_number, episode_absolute_number, episode_season_number, episode_dvd_number, episode_firstairedms, episode_watched, episode_plays, episode_collected FROM sg_episode WHERE series_id = :showId AND episode_watched != ${EpisodeFlags.UNWATCHED} ORDER BY episode_firstairedms DESC, episode_season_number DESC, episode_number DESC LIMIT 1")
fun getNewestWatchedEpisodeOfShow(showId: Long): SgEpisode2Info?

@Query(
Expand Down Expand Up @@ -199,7 +199,7 @@ interface SgEpisode2Helper {
/**
* WAIT, just for compile time validation of [SgEpisode2Info.buildQuery]
*/
@Query("SELECT _id, season_id, series_id, episode_tvdb_id, episode_title, episode_number, episode_absolute_number, episode_season_number, episode_dvd_number, episode_firstairedms, episode_watched, episode_collected FROM sg_episode WHERE season_id = :seasonId")
@Query("SELECT _id, season_id, series_id, episode_tvdb_id, episode_title, episode_number, episode_absolute_number, episode_season_number, episode_dvd_number, episode_firstairedms, episode_watched, episode_plays, episode_collected FROM sg_episode WHERE season_id = :seasonId")
fun dummyToValidateSgEpisode2Info(seasonId: Long): List<SgEpisode2Info>

@RawQuery(observedEntities = [SgEpisode2::class])
Expand Down Expand Up @@ -668,6 +668,7 @@ data class SgEpisode2Info(
@ColumnInfo(name = SgEpisode2Columns.SEASON) val season: Int,
@ColumnInfo(name = SgEpisode2Columns.DVDNUMBER) val dvdNumber: Double,
@ColumnInfo(name = SgEpisode2Columns.WATCHED) val watched: Int,
@ColumnInfo(name = SgEpisode2Columns.PLAYS) val plays: Int,
@ColumnInfo(name = SgEpisode2Columns.COLLECTED) val collected: Boolean = false,
@ColumnInfo(name = SgEpisode2Columns.FIRSTAIREDMS) val firstReleasedMs: Long
) {
Expand All @@ -679,7 +680,7 @@ data class SgEpisode2Info(
fun buildQuery(seasonId: Long, order: EpisodesSettings.EpisodeSorting): SimpleSQLiteQuery {
val orderClause = order.query()
return SimpleSQLiteQuery(
"SELECT _id, season_id, series_id, episode_tvdb_id, episode_title, episode_number, episode_absolute_number, episode_season_number, episode_dvd_number, episode_firstairedms, episode_watched, episode_collected FROM sg_episode WHERE season_id = $seasonId ORDER BY $orderClause"
"SELECT _id, season_id, series_id, episode_tvdb_id, episode_title, episode_number, episode_absolute_number, episode_season_number, episode_dvd_number, episode_firstairedms, episode_watched, episode_plays, episode_collected FROM sg_episode WHERE season_id = $seasonId ORDER BY $orderClause"
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,12 @@ class EpisodeViewHolder(
val dvdNumberText: String? = if (dvdNumber > 0) {
"${context.getString(R.string.episode_number_disk)} $dvdNumber"
} else null
val watchedCounter = if (episode.plays > 1) {
TextTools.getWatchedButtonText(context, true, episode.plays)
} else null
binding.textViewEpisodeAlternativeNumbers.text =
TextTools.dotSeparate(absoluteNumberText, dvdNumberText)
TextTools.dotSeparate(watchedCounter,
TextTools.dotSeparate(absoluteNumberText, dvdNumberText))

// release time
val isReleased: Boolean
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/item_episode.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
android:paddingTop="@dimen/inline_padding"
android:paddingBottom="@dimen/large_padding"
android:textAppearance="@style/TextAppearance.SeriesGuide.Caption.Dim"
tools:text="42 · DVD 2.0" />
tools:text="Watched (2) · 42 · DVD 2.0" />

<ImageView
android:id="@+id/imageViewCollected"
Expand Down

0 comments on commit 1d259ec

Please sign in to comment.