|
@@ -23,9 +23,6 @@ import eu.kanade.tachiyomi.ui.manga.MangaController
|
|
|
import eu.kanade.tachiyomi.util.system.copyToClipboard
|
|
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
|
|
import eu.kanade.tachiyomi.util.view.setChips
|
|
|
-import kotlinx.coroutines.CoroutineScope
|
|
|
-import kotlinx.coroutines.Dispatchers
|
|
|
-import kotlinx.coroutines.Job
|
|
|
import kotlinx.coroutines.flow.launchIn
|
|
|
import kotlinx.coroutines.flow.merge
|
|
|
import kotlinx.coroutines.flow.onEach
|
|
@@ -47,7 +44,6 @@ class MangaInfoHeaderAdapter(
|
|
|
private var source: Source = controller.presenter.source
|
|
|
private var trackCount: Int = 0
|
|
|
|
|
|
- private val scope = CoroutineScope(Job() + Dispatchers.Main)
|
|
|
private lateinit var binding: MangaInfoHeaderBinding
|
|
|
|
|
|
private var initialLoad: Boolean = true
|
|
@@ -90,12 +86,12 @@ class MangaInfoHeaderAdapter(
|
|
|
|
|
|
binding.btnFavorite.clicks()
|
|
|
.onEach { controller.onFavoriteClick() }
|
|
|
- .launchIn(scope)
|
|
|
+ .launchIn(controller.viewScope)
|
|
|
|
|
|
if (controller.presenter.manga.favorite && controller.presenter.getCategories().isNotEmpty()) {
|
|
|
binding.btnFavorite.longClicks()
|
|
|
.onEach { controller.onCategoriesClick() }
|
|
|
- .launchIn(scope)
|
|
|
+ .launchIn(controller.viewScope)
|
|
|
}
|
|
|
|
|
|
with(binding.btnTracking) {
|
|
@@ -118,7 +114,7 @@ class MangaInfoHeaderAdapter(
|
|
|
|
|
|
clicks()
|
|
|
.onEach { controller.onTrackingClick() }
|
|
|
- .launchIn(scope)
|
|
|
+ .launchIn(controller.viewScope)
|
|
|
} else {
|
|
|
isVisible = false
|
|
|
}
|
|
@@ -128,7 +124,7 @@ class MangaInfoHeaderAdapter(
|
|
|
binding.btnWebview.isVisible = true
|
|
|
binding.btnWebview.clicks()
|
|
|
.onEach { controller.openMangaInWebView() }
|
|
|
- .launchIn(scope)
|
|
|
+ .launchIn(controller.viewScope)
|
|
|
}
|
|
|
|
|
|
binding.mangaFullTitle.longClicks()
|
|
@@ -138,13 +134,13 @@ class MangaInfoHeaderAdapter(
|
|
|
binding.mangaFullTitle.text.toString()
|
|
|
)
|
|
|
}
|
|
|
- .launchIn(scope)
|
|
|
+ .launchIn(controller.viewScope)
|
|
|
|
|
|
binding.mangaFullTitle.clicks()
|
|
|
.onEach {
|
|
|
controller.performGlobalSearch(binding.mangaFullTitle.text.toString())
|
|
|
}
|
|
|
- .launchIn(scope)
|
|
|
+ .launchIn(controller.viewScope)
|
|
|
|
|
|
binding.mangaAuthor.longClicks()
|
|
|
.onEach {
|
|
@@ -153,13 +149,13 @@ class MangaInfoHeaderAdapter(
|
|
|
binding.mangaAuthor.text.toString()
|
|
|
)
|
|
|
}
|
|
|
- .launchIn(scope)
|
|
|
+ .launchIn(controller.viewScope)
|
|
|
|
|
|
binding.mangaAuthor.clicks()
|
|
|
.onEach {
|
|
|
controller.performGlobalSearch(binding.mangaAuthor.text.toString())
|
|
|
}
|
|
|
- .launchIn(scope)
|
|
|
+ .launchIn(controller.viewScope)
|
|
|
|
|
|
binding.mangaArtist.longClicks()
|
|
|
.onEach {
|
|
@@ -168,13 +164,13 @@ class MangaInfoHeaderAdapter(
|
|
|
binding.mangaArtist.text.toString()
|
|
|
)
|
|
|
}
|
|
|
- .launchIn(scope)
|
|
|
+ .launchIn(controller.viewScope)
|
|
|
|
|
|
binding.mangaArtist.clicks()
|
|
|
.onEach {
|
|
|
controller.performGlobalSearch(binding.mangaArtist.text.toString())
|
|
|
}
|
|
|
- .launchIn(scope)
|
|
|
+ .launchIn(controller.viewScope)
|
|
|
|
|
|
binding.mangaSummaryText.longClicks()
|
|
|
.onEach {
|
|
@@ -183,7 +179,7 @@ class MangaInfoHeaderAdapter(
|
|
|
binding.mangaSummaryText.text.toString()
|
|
|
)
|
|
|
}
|
|
|
- .launchIn(scope)
|
|
|
+ .launchIn(controller.viewScope)
|
|
|
|
|
|
binding.mangaCover.longClicks()
|
|
|
.onEach {
|
|
@@ -192,7 +188,7 @@ class MangaInfoHeaderAdapter(
|
|
|
controller.presenter.manga.title
|
|
|
)
|
|
|
}
|
|
|
- .launchIn(scope)
|
|
|
+ .launchIn(controller.viewScope)
|
|
|
|
|
|
setMangaInfo(manga, source)
|
|
|
}
|
|
@@ -300,7 +296,7 @@ class MangaInfoHeaderAdapter(
|
|
|
binding.mangaInfoToggleLess.clicks()
|
|
|
)
|
|
|
.onEach { toggleMangaInfo() }
|
|
|
- .launchIn(scope)
|
|
|
+ .launchIn(controller.viewScope)
|
|
|
|
|
|
// Expand manga info if navigated from source listing
|
|
|
if (initialLoad && fromSource) {
|