Fix toolbar not staying hidden when autohide bottom is disabled
This commit is contained in:
parent
2c6156c061
commit
4e9a1721d4
@ -33,6 +33,7 @@ import eu.kanade.tachiyomi.util.system.toast
|
|||||||
import kotlinx.android.synthetic.main.main_activity.*
|
import kotlinx.android.synthetic.main.main_activity.*
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
|
import uy.kohesive.injekt.injectLazy
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
import kotlin.random.Random
|
import kotlin.random.Random
|
||||||
|
|
||||||
@ -157,6 +158,7 @@ fun Controller.scrollViewWith(
|
|||||||
var elevationAnim: ValueAnimator? = null
|
var elevationAnim: ValueAnimator? = null
|
||||||
var elevate = false
|
var elevate = false
|
||||||
var isInView = true
|
var isInView = true
|
||||||
|
val preferences: PreferencesHelper by injectLazy()
|
||||||
val elevateFunc: (Boolean) -> Unit = { el ->
|
val elevateFunc: (Boolean) -> Unit = { el ->
|
||||||
elevate = el
|
elevate = el
|
||||||
if (liftOnScroll != null) {
|
if (liftOnScroll != null) {
|
||||||
@ -321,12 +323,18 @@ fun Controller.scrollViewWith(
|
|||||||
val halfWayBottom = activity!!.bottom_nav.height.toFloat() / 2
|
val halfWayBottom = activity!!.bottom_nav.height.toFloat() / 2
|
||||||
val closerToBottom = activity!!.bottom_nav.translationY > halfWayBottom
|
val closerToBottom = activity!!.bottom_nav.translationY > halfWayBottom
|
||||||
val atTop = !recycler.canScrollVertically(-1)
|
val atTop = !recycler.canScrollVertically(-1)
|
||||||
val closerToEdge = if (activity!!.bottom_nav.isVisible) closerToBottom else closerToTop
|
val closerToEdge =
|
||||||
lastY = if (closerToEdge && !atTop) (-activity!!.appbar.height.toFloat()) else 0f
|
if (activity!!.bottom_nav.isVisible &&
|
||||||
activity!!.appbar.animate().y(lastY).setDuration(shortAnimationDuration.toLong()).start()
|
preferences.hideBottomNavOnScroll().get()
|
||||||
if (activity!!.bottom_nav.isVisible && isInView) {
|
) closerToBottom else closerToTop
|
||||||
|
lastY =
|
||||||
|
if (closerToEdge && !atTop) (-activity!!.appbar.height.toFloat()) else 0f
|
||||||
|
activity!!.appbar.animate().y(lastY)
|
||||||
|
.setDuration(shortAnimationDuration.toLong()).start()
|
||||||
|
if (activity!!.bottom_nav.isVisible && isInView && preferences.hideBottomNavOnScroll().get()) {
|
||||||
activity!!.bottom_nav?.let {
|
activity!!.bottom_nav?.let {
|
||||||
val lastBottomY = if (closerToEdge && !atTop) it.height.toFloat() else 0f
|
val lastBottomY =
|
||||||
|
if (closerToEdge && !atTop) it.height.toFloat() else 0f
|
||||||
val animator = it.animate()?.translationY(lastBottomY)
|
val animator = it.animate()?.translationY(lastBottomY)
|
||||||
?.setDuration(shortAnimationDuration.toLong())
|
?.setDuration(shortAnimationDuration.toLong())
|
||||||
animator?.setUpdateListener {
|
animator?.setUpdateListener {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user