Minor fixes regarding leaks

This commit is contained in:
inorichi
2021-01-07 15:19:00 +01:00
parent 2caecc01b2
commit 36f81b4a62
16 changed files with 81 additions and 78 deletions
@@ -76,7 +76,6 @@ import eu.kanade.tachiyomi.util.view.shrinkOnScroll
import eu.kanade.tachiyomi.util.view.snack
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import reactivecircus.flowbinding.android.view.clicks
import reactivecircus.flowbinding.recyclerview.scrollEvents
import reactivecircus.flowbinding.swiperefreshlayout.refreshes
import timber.log.Timber
@@ -228,14 +227,14 @@ class MangaController :
binding.recycler.scrollEvents()
.onEach { updateToolbarTitleAlpha() }
.launchIn(scope)
.launchIn(viewScope)
binding.swipeRefresh.refreshes()
.onEach {
fetchMangaInfoFromSource(manualFetch = true)
fetchChaptersFromSource(manualFetch = true)
}
.launchIn(scope)
.launchIn(viewScope)
(activity!! as MainActivity).fixViewToBottom(binding.actionToolbar)
@@ -279,42 +278,42 @@ class MangaController :
actionFab = fab
fab.setText(R.string.action_start)
fab.setIconResource(R.drawable.ic_play_arrow_24dp)
fab.clicks()
.onEach {
val item = presenter.getNextUnreadChapter()
if (item != null) {
// Create animation listener
val revealAnimationListener: Animator.AnimatorListener = object : AnimatorListenerAdapter() {
override fun onAnimationStart(animation: Animator?) {
openChapter(item.chapter, true)
}
fab.setOnClickListener {
val item = presenter.getNextUnreadChapter()
if (item != null) {
// Create animation listener
val revealAnimationListener: Animator.AnimatorListener = object : AnimatorListenerAdapter() {
override fun onAnimationStart(animation: Animator?) {
openChapter(item.chapter, true)
}
// Get coordinates and start animation
actionFab?.getCoordinates()?.let { coordinates ->
if (!binding.revealView.showRevealEffect(
coordinates.x,
coordinates.y,
revealAnimationListener
)
) {
openChapter(item.chapter)
}
}
} else {
view?.context?.toast(R.string.no_next_chapter)
}
// Get coordinates and start animation
actionFab?.getCoordinates()?.let { coordinates ->
if (!binding.revealView.showRevealEffect(
coordinates.x,
coordinates.y,
revealAnimationListener
)
) {
openChapter(item.chapter)
}
}
} else {
view?.context?.toast(R.string.no_next_chapter)
}
.launchIn(scope)
}
}
override fun cleanupFab(fab: ExtendedFloatingActionButton) {
fab.setOnClickListener(null)
actionFabScrollListener?.let { binding.recycler.removeOnScrollListener(it) }
actionFab = null
}
override fun onDestroyView(view: View) {
destroyActionModeIfNeeded()
(activity!! as MainActivity).clearFixViewToBottom(binding.actionToolbar)
binding.actionToolbar.destroy()
mangaInfoAdapter = null
chaptersHeaderAdapter = null
@@ -77,7 +77,7 @@ class TrackController :
binding.swipeRefresh.isEnabled = false
binding.swipeRefresh.refreshes()
.onEach { presenter.refresh() }
.launchIn(scope)
.launchIn(viewScope)
}
override fun onDestroyView(view: View) {
@@ -77,7 +77,7 @@ class TrackSearchDialog : DialogController {
.onEach { position ->
selectedItem = adapter.getItem(position)
}
.launchIn(trackController.scope)
.launchIn(trackController.viewScope)
// Do an initial search based on the manga's title
if (savedState == null) {
@@ -99,7 +99,7 @@ class TrackSearchDialog : DialogController {
.debounce(TimeUnit.SECONDS.toMillis(1))
.filter { it.isNotBlank() }
.onEach { search(it.toString()) }
.launchIn(trackController.scope)
.launchIn(trackController.viewScope)
}
private fun search(query: String) {