|
@@ -38,6 +38,7 @@ import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchController
|
|
|
import eu.kanade.tachiyomi.ui.library.ChangeMangaCategoriesDialog
|
|
|
import eu.kanade.tachiyomi.ui.library.setting.DisplayModeSetting
|
|
|
import eu.kanade.tachiyomi.ui.main.MainActivity
|
|
|
+import eu.kanade.tachiyomi.ui.manga.AddDuplicateMangaDialog
|
|
|
import eu.kanade.tachiyomi.ui.manga.MangaController
|
|
|
import eu.kanade.tachiyomi.ui.more.MoreController
|
|
|
import eu.kanade.tachiyomi.ui.webview.WebViewActivity
|
|
@@ -591,6 +592,7 @@ open class BrowseSourceController(bundle: Bundle) :
|
|
|
override fun onItemLongClick(position: Int) {
|
|
|
val activity = activity ?: return
|
|
|
val manga = (adapter?.getItem(position) as? SourceItem?)?.manga ?: return
|
|
|
+ val duplicateManga = presenter.getDuplicateLibraryManga(manga)
|
|
|
|
|
|
if (manga.favorite) {
|
|
|
MaterialAlertDialogBuilder(activity)
|
|
@@ -606,43 +608,53 @@ open class BrowseSourceController(bundle: Bundle) :
|
|
|
}
|
|
|
.show()
|
|
|
} else {
|
|
|
- val categories = presenter.getCategories()
|
|
|
- val defaultCategoryId = preferences.defaultCategory()
|
|
|
- val defaultCategory = categories.find { it.id == defaultCategoryId }
|
|
|
-
|
|
|
- when {
|
|
|
- // Default category set
|
|
|
- defaultCategory != null -> {
|
|
|
- presenter.moveMangaToCategory(manga, defaultCategory)
|
|
|
-
|
|
|
- presenter.changeMangaFavorite(manga)
|
|
|
- adapter?.notifyItemChanged(position)
|
|
|
- activity.toast(activity.getString(R.string.manga_added_library))
|
|
|
- }
|
|
|
+ if (duplicateManga != null) {
|
|
|
+ AddDuplicateMangaDialog(this, duplicateManga) { addToLibrary(manga, position) }
|
|
|
+ .showDialog(router)
|
|
|
+ } else {
|
|
|
+ addToLibrary(manga, position)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- // Automatic 'Default' or no categories
|
|
|
- defaultCategoryId == 0 || categories.isEmpty() -> {
|
|
|
- presenter.moveMangaToCategory(manga, null)
|
|
|
+ private fun addToLibrary(newManga: Manga, position: Int) {
|
|
|
+ val activity = activity ?: return
|
|
|
+ val categories = presenter.getCategories()
|
|
|
+ val defaultCategoryId = preferences.defaultCategory()
|
|
|
+ val defaultCategory = categories.find { it.id == defaultCategoryId }
|
|
|
+
|
|
|
+ when {
|
|
|
+ // Default category set
|
|
|
+ defaultCategory != null -> {
|
|
|
+ presenter.moveMangaToCategory(newManga, defaultCategory)
|
|
|
+
|
|
|
+ presenter.changeMangaFavorite(newManga)
|
|
|
+ adapter?.notifyItemChanged(position)
|
|
|
+ activity.toast(activity.getString(R.string.manga_added_library))
|
|
|
+ }
|
|
|
|
|
|
- presenter.changeMangaFavorite(manga)
|
|
|
- adapter?.notifyItemChanged(position)
|
|
|
- activity.toast(activity.getString(R.string.manga_added_library))
|
|
|
- }
|
|
|
+ // Automatic 'Default' or no categories
|
|
|
+ defaultCategoryId == 0 || categories.isEmpty() -> {
|
|
|
+ presenter.moveMangaToCategory(newManga, null)
|
|
|
|
|
|
- // Choose a category
|
|
|
- else -> {
|
|
|
- val ids = presenter.getMangaCategoryIds(manga)
|
|
|
- val preselected = categories.map {
|
|
|
- if (it.id in ids) {
|
|
|
- QuadStateTextView.State.CHECKED.ordinal
|
|
|
- } else {
|
|
|
- QuadStateTextView.State.UNCHECKED.ordinal
|
|
|
- }
|
|
|
- }.toTypedArray()
|
|
|
+ presenter.changeMangaFavorite(newManga)
|
|
|
+ adapter?.notifyItemChanged(position)
|
|
|
+ activity.toast(activity.getString(R.string.manga_added_library))
|
|
|
+ }
|
|
|
|
|
|
- ChangeMangaCategoriesDialog(this, listOf(manga), categories, preselected)
|
|
|
- .showDialog(router)
|
|
|
- }
|
|
|
+ // Choose a category
|
|
|
+ else -> {
|
|
|
+ val ids = presenter.getMangaCategoryIds(newManga)
|
|
|
+ val preselected = categories.map {
|
|
|
+ if (it.id in ids) {
|
|
|
+ QuadStateTextView.State.CHECKED.ordinal
|
|
|
+ } else {
|
|
|
+ QuadStateTextView.State.UNCHECKED.ordinal
|
|
|
+ }
|
|
|
+ }.toTypedArray()
|
|
|
+
|
|
|
+ ChangeMangaCategoriesDialog(this, listOf(newManga), categories, preselected)
|
|
|
+ .showDialog(router)
|
|
|
}
|
|
|
}
|
|
|
}
|