Browse Source

Info shows last chapter instead of chapter count. Resolves #765

len 8 years ago
parent
commit
0da2f91771

+ 1 - 1
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<Int> = BehaviorRelay.create()
+    val chapterCountRelay: BehaviorRelay<Float> = BehaviorRelay.create()
 
     val mangaFavoriteRelay: PublishRelay<Boolean> = PublishRelay.create()
 

+ 3 - 2
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<Int>,
+        private val chapterCountRelay: BehaviorRelay<Float>,
         private val mangaFavoriteRelay: PublishRelay<Boolean>,
         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) })
     }

+ 3 - 2
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<MangaInfoPresenter>(),
      *
      * @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)
     }
 
     /**

+ 1 - 1
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<Int>,
+        private val chapterCountRelay: BehaviorRelay<Float>,
         private val mangaFavoriteRelay: PublishRelay<Boolean>,
         private val db: DatabaseHelper = Injekt.get(),
         private val downloadManager: DownloadManager = Injekt.get(),

+ 1 - 1
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"/>

+ 1 - 0
app/src/main/res/values/strings.xml

@@ -289,6 +289,7 @@
     <string name="manga_info_author_label">Author</string>
     <string name="manga_info_artist_label">Artist</string>
     <string name="manga_info_chapters_label">Chapters</string>
+    <string name="manga_info_last_chapter_label">Last chapter</string>
     <string name="manga_info_status_label">Status</string>
     <string name="manga_info_source_label">Source</string>
     <string name="manga_info_genres_label">Genres</string>