mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-13 01:15:06 +01:00
Category recycler puts active category center of view if list is scrollable
Also removed scrolling logic for opening/closing the sheet
This commit is contained in:
parent
511fa31798
commit
75d4d274f6
@ -749,30 +749,10 @@ class LibraryController(
|
||||
val translateY = if (show) full else 0f
|
||||
recycler.animate().translationY(translateY).start()
|
||||
category_hopper_frame.animate().translationY(translateY).start()
|
||||
if (scroll) {
|
||||
// Smooth scroll the recycler to hide the hidden content blocked by the app bar
|
||||
val vA = ValueAnimator.ofInt(recycler.translationY.roundToInt(), translateY
|
||||
.roundToInt()).apply {
|
||||
var start = 0f
|
||||
var last = recycler.translationY.roundToInt()
|
||||
val distance = abs(recycler.translationY.roundToInt() - translateY.roundToInt())
|
||||
addUpdateListener {
|
||||
val diff = abs(it.animatedValue as Int - last)
|
||||
last = it.animatedValue as Int
|
||||
start += diff.toFloat() / distance * recycler.paddingTop.toFloat()
|
||||
if (start > 1) {
|
||||
recycler.scrollBy(0, start.toInt() * if (show) 1 else -1)
|
||||
start %= 1
|
||||
}
|
||||
}
|
||||
addListener(EndAnimatorListener {
|
||||
fast_scroller?.hideScrollbar()
|
||||
})
|
||||
}.start()
|
||||
}
|
||||
recycler_cover.animate().translationY(translateY).start()
|
||||
recycler_cover.animate().alpha(if (show) 0.75f else 0f).start()
|
||||
if (show) {
|
||||
category_recycler.scrollToCategory(activeCategory)
|
||||
fast_scroller?.hideScrollbar()
|
||||
activity?.appbar?.y = 0f
|
||||
elevateFunc(false)
|
||||
|
@ -10,6 +10,7 @@ import com.mikepenz.fastadapter.adapters.ItemAdapter
|
||||
import com.mikepenz.fastadapter.listeners.OnBindViewHolderListenerImpl
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.models.Category
|
||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||
import eu.kanade.tachiyomi.util.view.marginBottom
|
||||
|
||||
class CategoryRecyclerView @JvmOverloads constructor(
|
||||
@ -51,6 +52,16 @@ class CategoryRecyclerView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
fun scrollToCategory(order: Int) {
|
||||
val index = itemAdapter.adapterItems.indexOfFirst { it.category.order == order }
|
||||
if (index > -1) {
|
||||
manager.scrollToPositionWithOffset(
|
||||
index,
|
||||
(height - 38.dpToPx) / 2
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun setCategories(selected: Int) {
|
||||
selectedCategory = selected
|
||||
for (i in 0..manager.itemCount) {
|
||||
|
Loading…
Reference in New Issue
Block a user