playback: attempt to fix pager being invisible
This commit is contained in:
+13
-1
@@ -20,6 +20,7 @@ package org.oxycblt.auxio.playback.ui
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.MotionEvent
|
||||
import com.google.android.material.carousel.MaskableFrameLayout
|
||||
import com.google.android.material.shape.ShapeAppearanceModel
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
@@ -27,7 +28,7 @@ import javax.inject.Inject
|
||||
import org.oxycblt.auxio.ui.UISettings
|
||||
|
||||
@AndroidEntryPoint
|
||||
class RoundModeMaskableFrameLayout
|
||||
class PlaybackMaskableFrameLayout
|
||||
@JvmOverloads
|
||||
constructor(context: Context, attrs: AttributeSet? = null, defStyleRes: Int = -1) :
|
||||
MaskableFrameLayout(context, attrs, defStyleRes) {
|
||||
@@ -40,4 +41,15 @@ constructor(context: Context, attrs: AttributeSet? = null, defStyleRes: Int = -1
|
||||
shapeAppearanceModel = ShapeAppearanceModel.builder().build()
|
||||
}
|
||||
}
|
||||
|
||||
override fun dispatchTouchEvent(event: MotionEvent): Boolean {
|
||||
// MaskableFrameLayout is weird and decides to register clicks even when masked.
|
||||
// Avoid this so that we can still have steppers work in the pager.
|
||||
if (
|
||||
event.actionMasked == MotionEvent.ACTION_DOWN && !maskRectF.contains(event.x, event.y)
|
||||
) {
|
||||
return false
|
||||
}
|
||||
return super.dispatchTouchEvent(event)
|
||||
}
|
||||
}
|
||||
@@ -20,13 +20,10 @@ 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
|
||||
@@ -47,10 +44,6 @@ 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 =
|
||||
|
||||
Reference in New Issue
Block a user