From c87b0e77de414d3a28ef1aa7e4868edd88ccfa7e Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 28 Mar 2021 11:11:19 -0400 Subject: [PATCH] Show number of manga per source in migrate menu (#4703) --- .../migration/sources/MigrationSourcesPresenter.kt | 13 +++++++++---- .../ui/browse/migration/sources/SourceHolder.kt | 2 +- .../ui/browse/migration/sources/SourceItem.kt | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/sources/MigrationSourcesPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/sources/MigrationSourcesPresenter.kt index 61181ba2e..15ce71e07 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/sources/MigrationSourcesPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/sources/MigrationSourcesPresenter.kt @@ -27,9 +27,14 @@ class MigrationSourcesPresenter( private fun findSourcesWithManga(library: List): List { val header = SelectionHeader() - return library.asSequence().map { it.source }.toSet() - .mapNotNull { if (it != LocalSource.ID) sourceManager.getOrStub(it) else null } - .sortedBy { it.name.toLowerCase() } - .map { SourceItem(it, header) }.toList() + return library + .groupBy { it.source } + .filterKeys { it != LocalSource.ID } + .map { + val source = sourceManager.getOrStub(it.key) + SourceItem(source, it.value.size, header) + } + .sortedBy { it.source.name.toLowerCase() } + .toList() } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/sources/SourceHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/sources/SourceHolder.kt index 176ad3500..04ad60af4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/sources/SourceHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/sources/SourceHolder.kt @@ -15,7 +15,7 @@ class SourceHolder(view: View, val adapter: SourceAdapter) : fun bind(item: SourceItem) { val source = item.source - binding.title.text = source.name + binding.title.text = "${source.name} (${item.mangaCount})" binding.subtitle.isVisible = source.lang != "" binding.subtitle.text = LocaleHelper.getDisplayName(source.lang) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/sources/SourceItem.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/sources/SourceItem.kt index 5de6162a7..4494ac1db 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/sources/SourceItem.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/sources/SourceItem.kt @@ -14,7 +14,7 @@ import eu.kanade.tachiyomi.source.Source * @param source Instance of [Source] containing source information. * @param header The header for this item. */ -data class SourceItem(val source: Source, val header: SelectionHeader) : +data class SourceItem(val source: Source, val mangaCount: Int, val header: SelectionHeader) : AbstractSectionableItem(header) { /**