From 77d378ccd1559617af08a8f067d81f5028f5c7e2 Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 30 May 2020 23:16:17 -0400 Subject: [PATCH] Fix crash when opening chapter from migration --- .../manga/MigrationMangaController.kt | 21 ++++++++++++------- .../sources/MigrationSourcesController.kt | 2 +- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/manga/MigrationMangaController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/manga/MigrationMangaController.kt index 88149b7417..d34c7e92c9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/manga/MigrationMangaController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/manga/MigrationMangaController.kt @@ -8,7 +8,6 @@ import androidx.recyclerview.widget.LinearLayoutManager import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.flexibleadapter.items.IFlexible import eu.kanade.tachiyomi.databinding.MigrationMangaControllerBinding -import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.ui.base.controller.NucleusController import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction import eu.kanade.tachiyomi.ui.browse.migration.search.SearchController @@ -20,23 +19,28 @@ class MigrationMangaController : private var adapter: FlexibleAdapter>? = null - constructor(source: Source) : super( + constructor(sourceId: Long, sourceName: String?) : super( Bundle().apply { - putSerializable(SOURCE_EXTRA, source) + putLong(SOURCE_ID_EXTRA, sourceId) + putString(SOURCE_NAME_EXTRA, sourceName) } ) @Suppress("unused") - constructor(bundle: Bundle) : this(bundle.getSerializable(SOURCE_EXTRA) as Source) + constructor(bundle: Bundle) : this( + bundle.getLong(SOURCE_ID_EXTRA), + bundle.getString(SOURCE_NAME_EXTRA) + ) - private val source: Source = args.getSerializable(SOURCE_EXTRA) as Source + private val sourceId: Long = args.getLong(SOURCE_ID_EXTRA) + private val sourceName: String? = args.getString(SOURCE_NAME_EXTRA) override fun getTitle(): String? { - return source.name + return sourceName } override fun createPresenter(): MigrationMangaPresenter { - return MigrationMangaPresenter(source.id) + return MigrationMangaPresenter(sourceId) } override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View { @@ -71,6 +75,7 @@ class MigrationMangaController : } companion object { - const val SOURCE_EXTRA = "source_id_extra" + const val SOURCE_ID_EXTRA = "source_id_extra" + const val SOURCE_NAME_EXTRA = "source_name_extra" } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/sources/MigrationSourcesController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/sources/MigrationSourcesController.kt index 5cb71139ff..b458bb93e5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/sources/MigrationSourcesController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/sources/MigrationSourcesController.kt @@ -47,7 +47,7 @@ class MigrationSourcesController : override fun onItemClick(view: View, position: Int): Boolean { val item = adapter?.getItem(position) as? SourceItem ?: return false - val controller = MigrationMangaController(item.source) + val controller = MigrationMangaController(item.source.id, item.source.name) parentController!!.router.pushController(controller.withFadeTransaction()) return false }