|
@@ -1,5 +1,6 @@
|
|
|
package com.sduduzog.slimlauncher.ui.main.notes
|
|
package com.sduduzog.slimlauncher.ui.main.notes
|
|
|
|
|
|
|
|
|
|
+import android.annotation.SuppressLint
|
|
|
import android.content.Context
|
|
import android.content.Context
|
|
|
import android.util.AttributeSet
|
|
import android.util.AttributeSet
|
|
|
import android.view.MotionEvent
|
|
import android.view.MotionEvent
|
|
@@ -7,6 +8,7 @@ import android.view.View
|
|
|
import androidx.viewpager.widget.ViewPager
|
|
import androidx.viewpager.widget.ViewPager
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+@Suppress("unused")
|
|
|
class VerticalViewPager @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : ViewPager(context, attrs) {
|
|
class VerticalViewPager @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : ViewPager(context, attrs) {
|
|
|
|
|
|
|
|
init {
|
|
init {
|
|
@@ -32,6 +34,7 @@ class VerticalViewPager @JvmOverloads constructor(context: Context, attrs: Attri
|
|
|
return toIntercept
|
|
return toIntercept
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @SuppressLint("ClickableViewAccessibility")
|
|
|
override fun onTouchEvent(ev: MotionEvent): Boolean {
|
|
override fun onTouchEvent(ev: MotionEvent): Boolean {
|
|
|
val toHandle = super.onTouchEvent(flipXY(ev))
|
|
val toHandle = super.onTouchEvent(flipXY(ev))
|
|
|
flipXY(ev)
|
|
flipXY(ev)
|
|
@@ -49,17 +52,17 @@ class VerticalViewPager @JvmOverloads constructor(context: Context, attrs: Attri
|
|
|
|
|
|
|
|
private class VerticalPageTransformer : ViewPager.PageTransformer {
|
|
private class VerticalPageTransformer : ViewPager.PageTransformer {
|
|
|
override fun transformPage(view: View, position: Float) {
|
|
override fun transformPage(view: View, position: Float) {
|
|
|
- val pageWidth = view.getWidth()
|
|
|
|
|
- val pageHeight = view.getHeight()
|
|
|
|
|
- if (position < -1) {
|
|
|
|
|
- view.setAlpha(0F)
|
|
|
|
|
- } else if (position <= 1) {
|
|
|
|
|
- view.setAlpha(1F)
|
|
|
|
|
- view.setTranslationX(pageWidth * -position)
|
|
|
|
|
- val yPosition = position * pageHeight
|
|
|
|
|
- view.setTranslationY(yPosition)
|
|
|
|
|
- } else {
|
|
|
|
|
- view.setAlpha(0F)
|
|
|
|
|
|
|
+ val pageWidth = view.width
|
|
|
|
|
+ val pageHeight = view.height
|
|
|
|
|
+ when {
|
|
|
|
|
+ position < -1 -> view.alpha = 0F
|
|
|
|
|
+ position <= 1 -> {
|
|
|
|
|
+ view.alpha = 1F
|
|
|
|
|
+ view.translationX = pageWidth * -position
|
|
|
|
|
+ val yPosition = position * pageHeight
|
|
|
|
|
+ view.translationY = yPosition
|
|
|
|
|
+ }
|
|
|
|
|
+ else -> view.alpha = 0F
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|