mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
Some fixes to the app bar when changing controllers
This commit is contained in:
parent
1040eccd7e
commit
4048811e7a
2 changed files with 11 additions and 6 deletions
|
@ -26,6 +26,7 @@ import eu.kanade.tachiyomi.util.system.dpToPx
|
|||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
import eu.kanade.tachiyomi.util.system.isTablet
|
||||
import eu.kanade.tachiyomi.util.view.backgroundColor
|
||||
import eu.kanade.tachiyomi.util.view.isControllerVisible
|
||||
import eu.kanade.tachiyomi.util.view.setTextColorAlpha
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import kotlin.math.abs
|
||||
|
@ -369,7 +370,7 @@ class ExpandedAppBarLayout@JvmOverloads constructor(context: Context, attrs: Att
|
|||
* @param callback closure updates along with snapping the appbar, use if something needs to
|
||||
* update alongside the appbar
|
||||
*/
|
||||
fun snapAppBarY(recyclerView: RecyclerView, callback: (() -> Unit)?): Float {
|
||||
fun snapAppBarY(controller: Controller?, recyclerView: RecyclerView, callback: (() -> Unit)?): Float {
|
||||
yAnimator?.cancel()
|
||||
val halfWay = compactAppBarHeight / 2
|
||||
val shortAnimationDuration = resources?.getInteger(
|
||||
|
@ -393,8 +394,10 @@ class ExpandedAppBarLayout@JvmOverloads constructor(context: Context, attrs: Att
|
|||
yAnimator = animate().y(lastY)
|
||||
.setDuration(shortAnimationDuration.toLong())
|
||||
yAnimator?.setUpdateListener {
|
||||
updateAppBarAfterY(recyclerView, false)
|
||||
callback?.invoke()
|
||||
if (controller?.isControllerVisible == true) {
|
||||
updateAppBarAfterY(recyclerView, false)
|
||||
callback?.invoke()
|
||||
}
|
||||
}
|
||||
yAnimator?.start()
|
||||
useSearchToolbarForMenu(true)
|
||||
|
|
|
@ -230,7 +230,7 @@ fun Controller.scrollViewWith(
|
|||
swipeRefreshLayout?.setDistanceToTriggerSync(150.dpToPx)
|
||||
val swipeCircle = swipeRefreshLayout?.findChild<ImageView>()
|
||||
activityBinding!!.appBar.doOnLayout {
|
||||
if (fullAppBarHeight!! > 0) {
|
||||
if (fullAppBarHeight!! > 0 && isControllerVisible) {
|
||||
appBarHeight = fullAppBarHeight!!
|
||||
recycler.requestApplyInsets()
|
||||
}
|
||||
|
@ -485,7 +485,7 @@ fun Controller.scrollViewWith(
|
|||
if (activityBinding!!.bottomNav?.isVisible == true &&
|
||||
preferences.hideBottomNavOnScroll().get()
|
||||
) closerToBottom else closerToTop
|
||||
lastY = activityBinding!!.appBar.snapAppBarY(recycler) {
|
||||
lastY = activityBinding!!.appBar.snapAppBarY(this@scrollViewWith, recycler) {
|
||||
val activityBinding = activityBinding ?: return@snapAppBarY
|
||||
swipeCircle?.translationY = max(
|
||||
activityBinding.appBar.y,
|
||||
|
@ -531,7 +531,9 @@ fun Controller.setItemAnimatorForAppBar(recycler: RecyclerView) {
|
|||
val duration = (recycler.itemAnimator?.changeDuration ?: 250) * 2
|
||||
itemAppBarAnimator = ValueAnimator.ofFloat(0f, 1f).apply {
|
||||
addUpdateListener {
|
||||
activityBinding?.appBar?.updateAppBarAfterY(recycler)
|
||||
if (isControllerVisible) {
|
||||
activityBinding?.appBar?.updateAppBarAfterY(recycler)
|
||||
}
|
||||
}
|
||||
}
|
||||
itemAppBarAnimator?.duration = duration
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue