Revert "Make controllers responsible for showing/hiding FAB"

This reverts commit 8ef548032f.
This commit is contained in:
arkon
2020-07-18 16:37:36 -04:00
parent a443dc3040
commit 0cef05dd89
5 changed files with 46 additions and 38 deletions
@@ -68,7 +68,6 @@ import eu.kanade.tachiyomi.util.view.shrinkOnScroll
import eu.kanade.tachiyomi.util.view.snack
import eu.kanade.tachiyomi.util.view.visible
import kotlinx.android.synthetic.main.main_activity.root_coordinator
import kotlinx.android.synthetic.main.main_activity.root_fab
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import reactivecircus.flowbinding.android.view.clicks
@@ -128,6 +127,7 @@ class MangaController :
*/
private var settingsSheet: ChaptersSettingsSheet? = null
private var actionFab: ExtendedFloatingActionButton? = null
private var actionFabScrollListener: RecyclerView.OnScrollListener? = null
/**
@@ -191,8 +191,7 @@ class MangaController :
binding.recycler.setHasFixedSize(true)
chaptersAdapter?.fastScroller = binding.fastScroller
activity!!.root_fab.visible()
actionFabScrollListener = activity!!.root_fab.shrinkOnScroll(binding.recycler)
actionFabScrollListener = actionFab?.shrinkOnScroll(binding.recycler)
// Skips directly to chapters list if navigated to from the library
binding.recycler.post {
@@ -225,6 +224,7 @@ class MangaController :
}
override fun configureFab(fab: ExtendedFloatingActionButton) {
actionFab = fab
fab.setText(R.string.action_start)
fab.setIconResource(R.drawable.ic_play_arrow_24dp)
fab.clicks()
@@ -239,14 +239,15 @@ class MangaController :
}
// Get coordinates and start animation
val coordinates = fab.getCoordinates()
if (!binding.revealView.showRevealEffect(
coordinates.x,
coordinates.y,
revealAnimationListener
)
) {
openChapter(item.chapter)
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)
@@ -257,12 +258,12 @@ class MangaController :
override fun cleanupFab(fab: ExtendedFloatingActionButton) {
actionFabScrollListener?.let { binding.recycler.removeOnScrollListener(it) }
actionFab = null
}
override fun onDestroyView(view: View) {
destroyActionModeIfNeeded()
binding.actionToolbar.destroy()
activity!!.root_fab.gone()
mangaInfoAdapter = null
chaptersHeaderAdapter = null
chaptersAdapter = null
@@ -276,8 +277,9 @@ class MangaController :
// Check if animation view is visible
if (binding.revealView.visibility == View.VISIBLE) {
// Show the unreveal effect
val coordinates = activity.root_fab.getCoordinates()
binding.revealView.hideRevealEffect(coordinates.x, coordinates.y, 1920)
actionFab?.getCoordinates()?.let { coordinates ->
binding.revealView.hideRevealEffect(coordinates.x, coordinates.y, 1920)
}
}
super.onActivityResumed(activity)
@@ -619,7 +621,7 @@ class MangaController :
val context = view?.context
if (context != null && chapters.any { it.read }) {
activity!!.root_fab.text = context.getString(R.string.action_resume)
actionFab?.text = context.getString(R.string.action_resume)
}
}
@@ -759,8 +761,8 @@ class MangaController :
binding.actionToolbar.findItem(R.id.action_mark_as_unread)?.isVisible = chapters.all { it.chapter.read }
// Hide FAB to avoid interfering with the bottom action toolbar
// activity!!.root_fab.hide()
activity!!.root_fab.gone()
// actionFab?.hide()
actionFab?.gone()
}
return false
}
@@ -794,8 +796,8 @@ class MangaController :
// TODO: there seems to be a bug in MaterialComponents where the [ExtendedFloatingActionButton]
// fails to show up properly
// activity!!.root_fab.show()
activity!!.root_fab.visible()
// actionFab?.show()
actionFab?.visible()
}
override fun onDetach(view: View) {