From 0da2f91771f8b0b5310596b1f900bc8f28bf7c48 Mon Sep 17 00:00:00 2001 From: len Date: Sun, 14 May 2017 19:55:48 +0200 Subject: [PATCH] Info shows last chapter instead of chapter count. Resolves #765 --- .../java/eu/kanade/tachiyomi/ui/manga/MangaController.kt | 2 +- .../kanade/tachiyomi/ui/manga/chapter/ChaptersPresenter.kt | 5 +++-- .../eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt | 5 +++-- .../eu/kanade/tachiyomi/ui/manga/info/MangaInfoPresenter.kt | 2 +- app/src/main/res/layout/fragment_manga_info.xml | 2 +- app/src/main/res/values/strings.xml | 1 + 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt index 4e3ad1e39..0eb3147ea 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt @@ -63,7 +63,7 @@ class MangaController : RxController, TabbedController { val fromCatalogue = args.getBoolean(FROM_CATALOGUE_EXTRA, false) - val chapterCountRelay: BehaviorRelay = BehaviorRelay.create() + val chapterCountRelay: BehaviorRelay = BehaviorRelay.create() val mangaFavoriteRelay: PublishRelay = PublishRelay.create() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersPresenter.kt index 254b9f991..71283739d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersPresenter.kt @@ -28,7 +28,7 @@ import uy.kohesive.injekt.api.get class ChaptersPresenter( val manga: Manga, val source: Source, - private val chapterCountRelay: BehaviorRelay, + private val chapterCountRelay: BehaviorRelay, private val mangaFavoriteRelay: PublishRelay, val preferences: PreferencesHelper = Injekt.get(), private val db: DatabaseHelper = Injekt.get(), @@ -92,7 +92,8 @@ class ChaptersPresenter( observeDownloads() // Emit the number of chapters to the info tab. - chapterCountRelay.call(chapters.size) + chapterCountRelay.call(chapters.maxBy { it.chapter_number }?.chapter_number + ?: 0f) } .subscribe { chaptersRelay.call(it) }) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt index eb7a5553c..9dcef5aea 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt @@ -38,6 +38,7 @@ import rx.android.schedulers.AndroidSchedulers import rx.schedulers.Schedulers import rx.subscriptions.Subscriptions import uy.kohesive.injekt.injectLazy +import java.text.DecimalFormat /** * Fragment that shows manga information. @@ -171,8 +172,8 @@ class MangaInfoController : NucleusController(), * * @param count number of chapters. */ - fun setChapterCount(count: Int) { - view?.manga_chapters?.text = count.toString() + fun setChapterCount(count: Float) { + view?.manga_chapters?.text = DecimalFormat("#.#").format(count) } /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoPresenter.kt index 337dc1cfe..40bd97b48 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoPresenter.kt @@ -27,7 +27,7 @@ import uy.kohesive.injekt.api.get class MangaInfoPresenter( val manga: Manga, val source: Source, - private val chapterCountRelay: BehaviorRelay, + private val chapterCountRelay: BehaviorRelay, private val mangaFavoriteRelay: PublishRelay, private val db: DatabaseHelper = Injekt.get(), private val downloadManager: DownloadManager = Injekt.get(), diff --git a/app/src/main/res/layout/fragment_manga_info.xml b/app/src/main/res/layout/fragment_manga_info.xml index 4a94f0f2b..3183d9925 100644 --- a/app/src/main/res/layout/fragment_manga_info.xml +++ b/app/src/main/res/layout/fragment_manga_info.xml @@ -134,7 +134,7 @@ style="@style/TextAppearance.Medium.Body2" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="@string/manga_info_chapters_label" + android:text="@string/manga_info_last_chapter_label" android:textIsSelectable="false" app:layout_constraintTop_toBottomOf="@+id/manga_artist_label" app:layout_constraintLeft_toLeftOf="parent"/> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1864327fe..8a92406cc 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -289,6 +289,7 @@ Author Artist Chapters + Last chapter Status Source Genres