playback: fix stepper in carousel
This commit is contained in:
@@ -20,10 +20,13 @@ package org.oxycblt.auxio.playback.ui.swiper
|
||||
|
||||
import android.graphics.RectF
|
||||
import android.view.View
|
||||
import androidx.core.view.isInvisible
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
import com.google.android.material.carousel.MaskableFrameLayout
|
||||
|
||||
class CarouselTransformer : ViewPager2.PageTransformer {
|
||||
private val hiddenRect = RectF()
|
||||
|
||||
override fun transformPage(page: View, position: Float) {
|
||||
// drafted by codex mostly due to the insane complexity of abusing a viewpager2
|
||||
// into a m3 carousel like thing
|
||||
@@ -32,6 +35,11 @@ class CarouselTransformer : ViewPager2.PageTransformer {
|
||||
val width = page.width.toFloat()
|
||||
val height = page.height.toFloat()
|
||||
|
||||
if (width <= 0f || height <= 0f) {
|
||||
//
|
||||
return
|
||||
}
|
||||
|
||||
// pin the page
|
||||
// normally the page's layout is controlled by linearlayoutmanager which we dont
|
||||
// like since it means we cant arrange them in the carousel
|
||||
@@ -39,6 +47,12 @@ class CarouselTransformer : ViewPager2.PageTransformer {
|
||||
// we want to create our effect
|
||||
page.translationX = -position * width
|
||||
|
||||
// Make sure despite the pinning offscreen pages are noninteractable
|
||||
// Otherwise funky android touch logic kicks in and breaks the playback stepper
|
||||
page.isInvisible = position <= -1f || position >= 1f
|
||||
|
||||
page.alpha = 1f
|
||||
|
||||
val p =
|
||||
when {
|
||||
// prev page, just abs
|
||||
|
||||
Reference in New Issue
Block a user