mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-17 09:59:16 +01:00
Don't hide menu when scrolling through with ReaderSeekBar (#5611)
This commit is contained in:
parent
78b9ac4766
commit
7660751f7f
@ -137,6 +137,9 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||
|
||||
private val windowInsetsController by lazy { WindowInsetsControllerCompat(window, binding.root) }
|
||||
|
||||
var isScrollingThroughPages = false
|
||||
private set
|
||||
|
||||
/**
|
||||
* Called when the activity is created. Initializes the presenter and configuration.
|
||||
*/
|
||||
@ -329,6 +332,16 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||
// Init listeners on bottom menu
|
||||
binding.pageSeekbar.setOnSeekBarChangeListener(
|
||||
object : SimpleSeekBarListener() {
|
||||
override fun onStartTrackingTouch(seekBar: SeekBar) {
|
||||
super.onStartTrackingTouch(seekBar)
|
||||
isScrollingThroughPages = true
|
||||
}
|
||||
|
||||
override fun onStopTrackingTouch(seekBar: SeekBar) {
|
||||
super.onStopTrackingTouch(seekBar)
|
||||
isScrollingThroughPages = false
|
||||
}
|
||||
|
||||
override fun onProgressChanged(seekBar: SeekBar, value: Int, fromUser: Boolean) {
|
||||
if (viewer != null && fromUser) {
|
||||
moveToPageIndex(value)
|
||||
|
@ -100,28 +100,31 @@ class PagerPageHolder(
|
||||
*/
|
||||
private var readImageHeaderSubscription: Subscription? = null
|
||||
|
||||
val stateChangedListener = object : SubsamplingScaleImageView.OnStateChangedListener {
|
||||
override fun onScaleChanged(newScale: Float, origin: Int) {
|
||||
viewer.activity.hideMenu()
|
||||
}
|
||||
|
||||
override fun onCenterChanged(newCenter: PointF?, origin: Int) {
|
||||
viewer.activity.hideMenu()
|
||||
}
|
||||
}
|
||||
private var visibilityListener = ActionBar.OnMenuVisibilityListener { isVisible ->
|
||||
if (isVisible.not()) {
|
||||
subsamplingImageView?.setOnStateChangedListener(null)
|
||||
return@OnMenuVisibilityListener
|
||||
}
|
||||
subsamplingImageView?.setOnStateChangedListener(
|
||||
object : SubsamplingScaleImageView.OnStateChangedListener {
|
||||
override fun onScaleChanged(newScale: Float, origin: Int) {
|
||||
viewer.activity.hideMenu()
|
||||
}
|
||||
|
||||
override fun onCenterChanged(newCenter: PointF?, origin: Int) {
|
||||
viewer.activity.hideMenu()
|
||||
}
|
||||
}
|
||||
)
|
||||
subsamplingImageView?.setOnStateChangedListener(stateChangedListener)
|
||||
}
|
||||
|
||||
init {
|
||||
addView(progressIndicator)
|
||||
observeStatus()
|
||||
viewer.activity.addOnMenuVisibilityListener(visibilityListener)
|
||||
if (viewer.activity.menuVisible) {
|
||||
// Listener will not be available if user changed page with seek bar
|
||||
subsamplingImageView?.setOnStateChangedListener(stateChangedListener)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -81,6 +81,9 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
|
||||
pager.addOnPageChangeListener(
|
||||
object : ViewPager.SimpleOnPageChangeListener() {
|
||||
override fun onPageSelected(position: Int) {
|
||||
if (activity.isScrollingThroughPages.not()) {
|
||||
activity.hideMenu()
|
||||
}
|
||||
onPageChange(position)
|
||||
}
|
||||
|
||||
@ -97,6 +100,7 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
|
||||
|
||||
val pos = PointF(event.rawX / pager.width, event.rawY / pager.height)
|
||||
val navigator = config.navigator
|
||||
|
||||
when (navigator.getAction(pos)) {
|
||||
NavigationRegion.MENU -> activity.toggleMenu()
|
||||
NavigationRegion.NEXT -> moveToNext()
|
||||
@ -153,7 +157,6 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
|
||||
* Called when a new page (either a [ReaderPage] or [ChapterTransition]) is marked as active
|
||||
*/
|
||||
private fun onPageChange(position: Int) {
|
||||
activity.hideMenu()
|
||||
val page = adapter.items.getOrNull(position)
|
||||
if (page != null && currentPage != page) {
|
||||
val allowPreload = checkAllowPreload(page as? ReaderPage)
|
||||
|
@ -81,6 +81,10 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
|
||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||
onScrolled()
|
||||
|
||||
if ((dy > 37 || dy < -37) && activity.menuVisible) {
|
||||
activity.hideMenu()
|
||||
}
|
||||
|
||||
if (dy < 0) {
|
||||
val firstIndex = layoutManager.findFirstVisibleItemPosition()
|
||||
val firstItem = adapter.items.getOrNull(firstIndex)
|
||||
@ -98,14 +102,12 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
|
||||
}
|
||||
|
||||
val pos = PointF(event.rawX / recycler.width, event.rawY / recycler.height)
|
||||
if (!config.tappingEnabled) activity.toggleMenu()
|
||||
else {
|
||||
val navigator = config.navigator
|
||||
when (navigator.getAction(pos)) {
|
||||
NavigationRegion.MENU -> activity.toggleMenu()
|
||||
NavigationRegion.NEXT, NavigationRegion.RIGHT -> scrollDown()
|
||||
NavigationRegion.PREV, NavigationRegion.LEFT -> scrollUp()
|
||||
}
|
||||
val navigator = config.navigator
|
||||
|
||||
when (navigator.getAction(pos)) {
|
||||
NavigationRegion.MENU -> activity.toggleMenu()
|
||||
NavigationRegion.NEXT, NavigationRegion.RIGHT -> scrollDown()
|
||||
NavigationRegion.PREV, NavigationRegion.LEFT -> scrollUp()
|
||||
}
|
||||
}
|
||||
recycler.longTapListener = f@{ event ->
|
||||
@ -235,7 +237,7 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
|
||||
if (position != -1) {
|
||||
recycler.scrollToPosition(position)
|
||||
if (layoutManager.findLastEndVisibleItemPosition() == -1) {
|
||||
onScrolled(position)
|
||||
onScrolled(pos = position)
|
||||
}
|
||||
} else {
|
||||
Timber.d("Page $page not found in adapter")
|
||||
@ -243,7 +245,6 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
|
||||
}
|
||||
|
||||
fun onScrolled(pos: Int? = null) {
|
||||
activity.hideMenu()
|
||||
val position = pos ?: layoutManager.findLastEndVisibleItemPosition()
|
||||
val item = adapter.items.getOrNull(position)
|
||||
val allowPreload = checkAllowPreload(item as? ReaderPage)
|
||||
|
Loading…
Reference in New Issue
Block a user