Confirm exit for migrations

(cherry picked from commit 640bd8d9babb3ace1d6a370adad35050271aa008)
This commit is contained in:
jobobby04 2020-04-17 01:21:16 -04:00 committed by Jobobby04
parent 3d0dc64de1
commit 949cdccbae
2 changed files with 30 additions and 1 deletions

View File

@ -130,6 +130,13 @@ class MigrationListController(bundle: Bundle? = null) : BaseController(bundle),
sourceManager.get(value) as? CatalogueSource }
if (config == null) return
for (manga in mangas) {
if (migrationsJob?.isCancelled == true) {
break
}
// in case it was removed
if (manga.mangaId !in config.mangaIds) {
continue
}
if (!manga.searchResult.initialized && manga.migrationJob.isActive) {
val mangaObj = manga.manga()
@ -246,7 +253,9 @@ class MigrationListController(bundle: Bundle? = null) : BaseController(bundle),
override fun updateCount() {
launchUI {
setTitle()
if (router.backstack.last().controller() == this@MigrationListController) {
setTitle()
}
}
}
@ -370,6 +379,24 @@ class MigrationListController(bundle: Bundle? = null) : BaseController(bundle),
}
}
override fun handleBack(): Boolean {
activity?.let {
MaterialDialog.Builder(it).title(R.string.stop_migration)
.positiveText(R.string.yes)
.negativeText(R.string.no)
.onPositive { _, _ ->
router.popCurrentController()
migrationsJob?.cancel()
}
.show()
}
return true
}
override fun onDestroyView(view: View) {
super.onDestroyView(view)
}
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
inflater.inflate(R.menu.migration_list, menu)
}

View File

@ -493,9 +493,11 @@
<string name="skipping_x">(skipping %1$d)</string>
<string name="x_migrations">%1$s manga migrated</string>
<string name="no">No</string>
<string name="yes">Yes</string>
<string name="error_fetching_migration">No chapters found, this manga cannot be used for
migration</string>
<string name="no_alternatives_found">No Alternatives Found</string>
<string name="stop_migration">Stop migrating?</string>
<!-- Tracking Screen -->
<string name="manga_tracking_tab">Tracking</string>