diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/MangaInfoChaptersController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/MangaInfoChaptersController.kt index 46c60707e3..a9a8b40a1a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/MangaInfoChaptersController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/MangaInfoChaptersController.kt @@ -515,6 +515,9 @@ class MangaInfoChaptersController(private val fromSource: Boolean = false) : fetchChaptersFromSource() } + val header = headerAdapter ?: return + header.setNumChapters(chapters.size) + val adapter = chaptersAdapter ?: return adapter.updateDataSet(chapters) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/MangaInfoHeaderAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/MangaInfoHeaderAdapter.kt index d270cf979a..5c6eecc8a2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/MangaInfoHeaderAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/MangaInfoHeaderAdapter.kt @@ -41,6 +41,7 @@ class MangaInfoHeaderAdapter( private var manga: Manga? = null private var source: Source? = null + private var numChapters: Int? = null private val scope = CoroutineScope(Job() + Dispatchers.Main) private lateinit var binding: MangaInfoHeaderBinding @@ -71,6 +72,12 @@ class MangaInfoHeaderAdapter( notifyDataSetChanged() } + fun setNumChapters(numChapters: Int) { + this.numChapters = numChapters + + notifyDataSetChanged() + } + inner class HeaderViewHolder(private val view: View) : RecyclerView.ViewHolder(view) { fun bind() { if (manga == null) { @@ -155,6 +162,7 @@ class MangaInfoHeaderAdapter( .launchIn(scope) setMangaInfo(manga!!, source) + setChapterInfo() } /** @@ -316,5 +324,14 @@ class MangaInfoHeaderAdapter( isChecked = isFavorite } } + + private fun setChapterInfo() { + // Chapters heading + binding.chaptersLabel.text = if (numChapters == null) { + view.context.getString(R.string.chapters) + } else { + view.context.resources.getQuantityString(R.plurals.manga_num_chapters, numChapters!!, numChapters) + } + } } } diff --git a/app/src/main/res/layout-land/manga_info_header.xml b/app/src/main/res/layout-land/manga_info_header.xml index ea6a7842f7..1bc76b04c3 100644 --- a/app/src/main/res/layout-land/manga_info_header.xml +++ b/app/src/main/res/layout-land/manga_info_header.xml @@ -1,38 +1,36 @@ - - + - + + android:layout_width="0dp" + android:layout_height="wrap_content" + android:padding="16dp" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toEndOf="@+id/manga_cover" + app:layout_constraintTop_toTopOf="parent"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - -