private string GetAnimeDetailString(MediaListDetailType detailType) { string retString = null; if (detailType == MediaListDetailType.FormatAndAiringInfo) { var stringBuilder = new StringBuilder($"{Model.Media.Format?.DisplayValue}{(Model.Media.IsAdult ? " (Hentai)" : "")}"); if (Model.Media?.NextAiringEpisode != null) { stringBuilder.Append($" (Episode {Model.Media.NextAiringEpisode.Episode}: "); stringBuilder.Append(!_displayTimeUntilAiringCountdown ? Model.Media.NextAiringEpisode.GetAiringAtDateTime().ToShortDateString() : Model.Media.NextAiringEpisode.GetExactDurationString(Model.Media.NextAiringEpisode .TimeUntilAiring)); stringBuilder.Append(")"); } retString = stringBuilder.ToString(); } else if (detailType == MediaListDetailType.EpisodeCountOrMovieLength) { if (Model.Media?.Format?.Equals(MediaFormat.Movie) == true) { retString = Model.Media.Duration.HasValue ? Model.Media.GetExactDurationString(Model.Media.Duration.Value * 60) : "Duration Unknown"; } else { // wew retString = $"{((Model.Media?.Episodes ?? 0) > 0 ? Model.Media?.Episodes?.ToString() : "?")} episode{(Model.Media?.Episodes > 1 ? "s" : "")} / {(Model.Media?.Duration.HasValue == true ? $"{Model.Media.GetExactDurationString(Model.Media.Duration.Value * 60)}" : "")}"; } } else if (detailType == MediaListDetailType.Progress) { if (Model.Progress.HasValue && Model.Progress > 0 && Model.Progress == Model.Media?.Episodes) { retString = "Status needs to be marked as Completed"; } else { retString = $"Watched {Model.Progress ?? 0} out of {((Model.Media?.Episodes ?? 0) > 0 ? Model.Media?.Episodes?.ToString() : "?")}"; } } else if (detailType == MediaListDetailType.Rating) { retString = Model.GetScoreString(_scoreFormat); } return(retString); }
private string GetDetailString(MediaType mediaType, MediaListDetailType detailType) { string retString = null; if (mediaType?.Equals(MediaType.Anime) == true) { retString = GetAnimeDetailString(detailType); } else if (mediaType?.Equals(MediaType.Manga) == true) { retString = GetMangaDetailString(detailType); } return(retString); }
public MediaListViewModel(AniList.Models.MediaModels.MediaList model, MediaListDetailType primaryMediaListDetailType, MediaListDetailType secondaryMediaListDetailType, bool displayTimeUntilAiringCountdown, MediaListRecyclerAdapter.MediaListProgressDisplayType progressDisplayType, ScoreFormat scoreFormat) : base(model) { _displayTimeUntilAiringCountdown = displayTimeUntilAiringCountdown; _scoreFormat = scoreFormat; _progressDisplayType = progressDisplayType; TitleText = model.Media?.Title?.UserPreferred; DetailPrimaryText = GetDetailString(model.Media?.Type, primaryMediaListDetailType); DetailSecondaryText = GetDetailString(model.Media?.Type, secondaryMediaListDetailType); ImageUri = model.Media?.CoverImage?.Large ?? model.Media?.CoverImage?.Medium; IsPriority = model.Priority > 0; ButtonIcon = GetEpisodeAddIcon(); ImageColor = Color.ParseColor(model.Media?.CoverImage?.Color ?? "#00000000"); WatchingStatus = GetWatchingStatus(); }
private string GetMangaDetailString(MediaListDetailType detailType) { string retString = null; if (detailType == MediaListDetailType.FormatAndAiringInfo) { retString = $"{Model.Media.Format?.DisplayValue}{(Model.Media.IsAdult ? " (Hentai)" : "")}"; } else if (detailType == MediaListDetailType.EpisodeCountOrMovieLength) { var stringBuilder = new StringBuilder( $"{((Model.Media?.Chapters ?? 0) > 0 ? Model.Media?.Chapters?.ToString() : "?")} chapter{(Model.Media?.Chapters > 1 ? "s" : "")}"); if (Model.Media?.Volumes > 0) { stringBuilder.Append($" / {Model.Media.Volumes} volume{(Model.Media.Volumes > 1 ? "s" : "")}"); } retString = stringBuilder.ToString(); } else if (detailType == MediaListDetailType.Progress) { if (Model.Progress.HasValue && Model.Progress > 0 && Model.Progress == Model.Media?.Chapters) { retString = "Status needs to be marked as Completed"; } else { retString = $"Read {Model.Progress ?? 0} out of {((Model.Media?.Chapters ?? 0) > 0 ? Model.Media?.Chapters?.ToString() : "?")}"; } } else if (detailType == MediaListDetailType.Rating) { retString = Model.GetScoreString(_scoreFormat); } return(retString); }