diff --git a/app/src/main/java/com/battlelancer/seriesguide/shows/database/SgEpisode2Helper.kt b/app/src/main/java/com/battlelancer/seriesguide/shows/database/SgEpisode2Helper.kt index 3ab359b7d6..720edb6172 100644 --- a/app/src/main/java/com/battlelancer/seriesguide/shows/database/SgEpisode2Helper.kt +++ b/app/src/main/java/com/battlelancer/seriesguide/shows/database/SgEpisode2Helper.kt @@ -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 @@ -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( @@ -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 @RawQuery(observedEntities = [SgEpisode2::class]) @@ -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 ) { @@ -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" ) } } diff --git a/app/src/main/java/com/battlelancer/seriesguide/shows/episodes/EpisodesAdapter.kt b/app/src/main/java/com/battlelancer/seriesguide/shows/episodes/EpisodesAdapter.kt index 844d2faab4..2859777125 100644 --- a/app/src/main/java/com/battlelancer/seriesguide/shows/episodes/EpisodesAdapter.kt +++ b/app/src/main/java/com/battlelancer/seriesguide/shows/episodes/EpisodesAdapter.kt @@ -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 diff --git a/app/src/main/res/layout/item_episode.xml b/app/src/main/res/layout/item_episode.xml index 22ca7db560..9f75f60a48 100644 --- a/app/src/main/res/layout/item_episode.xml +++ b/app/src/main/res/layout/item_episode.xml @@ -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" />