mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 13:51:50 +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) }
|
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.
|
* 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
|
// Init listeners on bottom menu
|
||||||
binding.pageSeekbar.setOnSeekBarChangeListener(
|
binding.pageSeekbar.setOnSeekBarChangeListener(
|
||||||
object : SimpleSeekBarListener() {
|
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) {
|
override fun onProgressChanged(seekBar: SeekBar, value: Int, fromUser: Boolean) {
|
||||||
if (viewer != null && fromUser) {
|
if (viewer != null && fromUser) {
|
||||||
moveToPageIndex(value)
|
moveToPageIndex(value)
|
||||||
|
@ -100,28 +100,31 @@ class PagerPageHolder(
|
|||||||
*/
|
*/
|
||||||
private var readImageHeaderSubscription: Subscription? = null
|
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 ->
|
private var visibilityListener = ActionBar.OnMenuVisibilityListener { isVisible ->
|
||||||
if (isVisible.not()) {
|
if (isVisible.not()) {
|
||||||
subsamplingImageView?.setOnStateChangedListener(null)
|
subsamplingImageView?.setOnStateChangedListener(null)
|
||||||
return@OnMenuVisibilityListener
|
return@OnMenuVisibilityListener
|
||||||
}
|
}
|
||||||
subsamplingImageView?.setOnStateChangedListener(
|
subsamplingImageView?.setOnStateChangedListener(stateChangedListener)
|
||||||
object : SubsamplingScaleImageView.OnStateChangedListener {
|
|
||||||
override fun onScaleChanged(newScale: Float, origin: Int) {
|
|
||||||
viewer.activity.hideMenu()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCenterChanged(newCenter: PointF?, origin: Int) {
|
|
||||||
viewer.activity.hideMenu()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
addView(progressIndicator)
|
addView(progressIndicator)
|
||||||
observeStatus()
|
observeStatus()
|
||||||
viewer.activity.addOnMenuVisibilityListener(visibilityListener)
|
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(
|
pager.addOnPageChangeListener(
|
||||||
object : ViewPager.SimpleOnPageChangeListener() {
|
object : ViewPager.SimpleOnPageChangeListener() {
|
||||||
override fun onPageSelected(position: Int) {
|
override fun onPageSelected(position: Int) {
|
||||||
|
if (activity.isScrollingThroughPages.not()) {
|
||||||
|
activity.hideMenu()
|
||||||
|
}
|
||||||
onPageChange(position)
|
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 pos = PointF(event.rawX / pager.width, event.rawY / pager.height)
|
||||||
val navigator = config.navigator
|
val navigator = config.navigator
|
||||||
|
|
||||||
when (navigator.getAction(pos)) {
|
when (navigator.getAction(pos)) {
|
||||||
NavigationRegion.MENU -> activity.toggleMenu()
|
NavigationRegion.MENU -> activity.toggleMenu()
|
||||||
NavigationRegion.NEXT -> moveToNext()
|
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
|
* Called when a new page (either a [ReaderPage] or [ChapterTransition]) is marked as active
|
||||||
*/
|
*/
|
||||||
private fun onPageChange(position: Int) {
|
private fun onPageChange(position: Int) {
|
||||||
activity.hideMenu()
|
|
||||||
val page = adapter.items.getOrNull(position)
|
val page = adapter.items.getOrNull(position)
|
||||||
if (page != null && currentPage != page) {
|
if (page != null && currentPage != page) {
|
||||||
val allowPreload = checkAllowPreload(page as? ReaderPage)
|
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) {
|
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||||
onScrolled()
|
onScrolled()
|
||||||
|
|
||||||
|
if ((dy > 37 || dy < -37) && activity.menuVisible) {
|
||||||
|
activity.hideMenu()
|
||||||
|
}
|
||||||
|
|
||||||
if (dy < 0) {
|
if (dy < 0) {
|
||||||
val firstIndex = layoutManager.findFirstVisibleItemPosition()
|
val firstIndex = layoutManager.findFirstVisibleItemPosition()
|
||||||
val firstItem = adapter.items.getOrNull(firstIndex)
|
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)
|
val pos = PointF(event.rawX / recycler.width, event.rawY / recycler.height)
|
||||||
if (!config.tappingEnabled) activity.toggleMenu()
|
val navigator = config.navigator
|
||||||
else {
|
|
||||||
val navigator = config.navigator
|
when (navigator.getAction(pos)) {
|
||||||
when (navigator.getAction(pos)) {
|
NavigationRegion.MENU -> activity.toggleMenu()
|
||||||
NavigationRegion.MENU -> activity.toggleMenu()
|
NavigationRegion.NEXT, NavigationRegion.RIGHT -> scrollDown()
|
||||||
NavigationRegion.NEXT, NavigationRegion.RIGHT -> scrollDown()
|
NavigationRegion.PREV, NavigationRegion.LEFT -> scrollUp()
|
||||||
NavigationRegion.PREV, NavigationRegion.LEFT -> scrollUp()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
recycler.longTapListener = f@{ event ->
|
recycler.longTapListener = f@{ event ->
|
||||||
@ -235,7 +237,7 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
|
|||||||
if (position != -1) {
|
if (position != -1) {
|
||||||
recycler.scrollToPosition(position)
|
recycler.scrollToPosition(position)
|
||||||
if (layoutManager.findLastEndVisibleItemPosition() == -1) {
|
if (layoutManager.findLastEndVisibleItemPosition() == -1) {
|
||||||
onScrolled(position)
|
onScrolled(pos = position)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Timber.d("Page $page not found in adapter")
|
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) {
|
fun onScrolled(pos: Int? = null) {
|
||||||
activity.hideMenu()
|
|
||||||
val position = pos ?: layoutManager.findLastEndVisibleItemPosition()
|
val position = pos ?: layoutManager.findLastEndVisibleItemPosition()
|
||||||
val item = adapter.items.getOrNull(position)
|
val item = adapter.items.getOrNull(position)
|
||||||
val allowPreload = checkAllowPreload(item as? ReaderPage)
|
val allowPreload = checkAllowPreload(item as? ReaderPage)
|
||||||
|
Loading…
Reference in New Issue
Block a user