From aa86fd1d550c5eb86900be92c689757fb6757372 Mon Sep 17 00:00:00 2001 From: Evgeny Nizamiev Date: Wed, 6 May 2020 01:21:14 +0300 Subject: [PATCH] small fixes --- app-tv/src/main/AndroidManifest.xml | 1 - .../ru/radiationx/anilibria/common/CardsDataConverter.kt | 3 ++- .../ru/radiationx/anilibria/common/DetailDataConverter.kt | 3 ++- .../java/ru/radiationx/anilibria/common/LibriaDetails.kt | 1 + .../anilibria/screen/details/DetailHeaderViewModel.kt | 7 ++++--- .../anilibria/ui/presenter/ReleaseDetailsPresenter.kt | 1 + 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app-tv/src/main/AndroidManifest.xml b/app-tv/src/main/AndroidManifest.xml index e75ca5a1d..03e5b7041 100644 --- a/app-tv/src/main/AndroidManifest.xml +++ b/app-tv/src/main/AndroidManifest.xml @@ -61,7 +61,6 @@ diff --git a/app-tv/src/main/java/ru/radiationx/anilibria/common/CardsDataConverter.kt b/app-tv/src/main/java/ru/radiationx/anilibria/common/CardsDataConverter.kt index 4037e3de1..ddc63fbcf 100644 --- a/app-tv/src/main/java/ru/radiationx/anilibria/common/CardsDataConverter.kt +++ b/app-tv/src/main/java/ru/radiationx/anilibria/common/CardsDataConverter.kt @@ -16,7 +16,8 @@ class CardsDataConverter( id, title.orEmpty(), "${seasons.firstOrNull()} год • ${genres.firstOrNull() - ?.capitalize()} • Серии: ${series} • Обновлен ${Date(torrentUpdate * 1000L).relativeDate(context).decapitalize()}", + ?.capitalize()} • Серии: ${series?.trim() ?: "Не доступно"} • Обновлен ${Date(torrentUpdate * 1000L).relativeDate(context) + .decapitalize()}", poster.orEmpty(), LibriaCard.Type.RELEASE ).apply { diff --git a/app-tv/src/main/java/ru/radiationx/anilibria/common/DetailDataConverter.kt b/app-tv/src/main/java/ru/radiationx/anilibria/common/DetailDataConverter.kt index e0c0787e4..7ebae9ea7 100644 --- a/app-tv/src/main/java/ru/radiationx/anilibria/common/DetailDataConverter.kt +++ b/app-tv/src/main/java/ru/radiationx/anilibria/common/DetailDataConverter.kt @@ -23,7 +23,7 @@ class DetailDataConverter( genres.firstOrNull()?.capitalize()?.trim(), "${seasons.firstOrNull()} год", types.firstOrNull()?.trim(), - "Серии: ${series?.trim()}" + "Серии: ${series?.trim() ?: "Не доступно"}" ).joinToString(" • "), Html.fromHtml(description.orEmpty()).toString().trim().trim('"')/*.replace('\n', ' ')*/, getAnnounce(), @@ -31,6 +31,7 @@ class DetailDataConverter( NumberFormat.getNumberInstance().format(favoriteInfo.rating), (releaseItem as? ReleaseFull)?.episodes?.any { it.urlFullHd != null } ?: false, favoriteInfo.isAdded, + (releaseItem as? ReleaseFull)?.episodes?.isNotEmpty() ?: false, (releaseItem as? ReleaseFull)?.episodes?.any { it.isViewed } ?: false, false && (releaseItem as? ReleaseFull)?.moonwalkLink != null ) diff --git a/app-tv/src/main/java/ru/radiationx/anilibria/common/LibriaDetails.kt b/app-tv/src/main/java/ru/radiationx/anilibria/common/LibriaDetails.kt index 247c20976..04fb8655f 100644 --- a/app-tv/src/main/java/ru/radiationx/anilibria/common/LibriaDetails.kt +++ b/app-tv/src/main/java/ru/radiationx/anilibria/common/LibriaDetails.kt @@ -13,6 +13,7 @@ data class LibriaDetails( val favoriteCount: String, val hasFullHd: Boolean, val isFavorite: Boolean, + val hasEpisodes: Boolean, val hasViewed: Boolean, val hasWebPlayer: Boolean ) diff --git a/app-tv/src/main/java/ru/radiationx/anilibria/screen/details/DetailHeaderViewModel.kt b/app-tv/src/main/java/ru/radiationx/anilibria/screen/details/DetailHeaderViewModel.kt index d587dec69..7748e17c5 100644 --- a/app-tv/src/main/java/ru/radiationx/anilibria/screen/details/DetailHeaderViewModel.kt +++ b/app-tv/src/main/java/ru/radiationx/anilibria/screen/details/DetailHeaderViewModel.kt @@ -90,11 +90,12 @@ class DetailHeaderViewModel( fun onPlayClick() { val release = currentRelease as? ReleaseFull ?: return - if (release.episodes.size > 1) { + if (release.episodes.isEmpty()) return + if (release.episodes.size == 1) { + router.navigateTo(PlayerScreen(releaseId)) + } else { val episodeId = releaseInteractor.getEpisodes(releaseId).maxBy { it.lastAccess }?.id ?: -1 guidedRouter.open(PlayerEpisodesGuidedScreen(releaseId, episodeId)) - } else { - router.navigateTo(PlayerScreen(releaseId)) } } diff --git a/app-tv/src/main/java/ru/radiationx/anilibria/ui/presenter/ReleaseDetailsPresenter.kt b/app-tv/src/main/java/ru/radiationx/anilibria/ui/presenter/ReleaseDetailsPresenter.kt index 013b9bcd3..acaa59f24 100644 --- a/app-tv/src/main/java/ru/radiationx/anilibria/ui/presenter/ReleaseDetailsPresenter.kt +++ b/app-tv/src/main/java/ru/radiationx/anilibria/ui/presenter/ReleaseDetailsPresenter.kt @@ -138,6 +138,7 @@ class LibriaReleaseViewHolder( ) rowReleaseHQMarker.isVisible = details.hasFullHd + rowReleaseActionPlay.isVisible = details.hasEpisodes rowReleaseActionContinue.isVisible = details.hasViewed rowReleaseActionPlayWeb.isVisible = details.hasWebPlayer rowReleaseActionFavorite.text = if (details.isFavorite) {