|
@@ -38,30 +38,17 @@ class WebtoonRecyclerView @JvmOverloads constructor(
|
|
|
private var mNestedPreScrollListener: IComicPreScroll? = null
|
|
private var mNestedPreScrollListener: IComicPreScroll? = null
|
|
|
private val listener = GestureListener()
|
|
private val listener = GestureListener()
|
|
|
private val detector = Detector()
|
|
private val detector = Detector()
|
|
|
- private val mcRect = RectF()
|
|
|
|
|
- private val blRect = RectF()
|
|
|
|
|
- private val brRect = RectF()
|
|
|
|
|
|
|
|
|
|
var doubleTapZoom = true
|
|
var doubleTapZoom = true
|
|
|
var tapListener: ((MotionEvent) -> Unit)? = null
|
|
var tapListener: ((MotionEvent) -> Unit)? = null
|
|
|
var longTapListener: ((MotionEvent) -> Boolean)? = null
|
|
var longTapListener: ((MotionEvent) -> Boolean)? = null
|
|
|
var disableMangaScaling = false
|
|
var disableMangaScaling = false
|
|
|
- var disabledClickScroller = false
|
|
|
|
|
-
|
|
|
|
|
- private var mTouchMiddle: (() -> Unit)? = null
|
|
|
|
|
- fun onTouchMiddle(init: () -> Unit) = apply { this.mTouchMiddle = init }
|
|
|
|
|
- private var mNextPage: (() -> Unit)? = null
|
|
|
|
|
- fun onNextPage(init: () -> Unit) = apply { this.mNextPage = init }
|
|
|
|
|
- private var mPrevPage: (() -> Unit)? = null
|
|
|
|
|
- fun onPrevPage(init: () -> Unit) = apply { this.mPrevPage = init }
|
|
|
|
|
|
|
|
|
|
override fun onMeasure(widthSpec: Int, heightSpec: Int) {
|
|
override fun onMeasure(widthSpec: Int, heightSpec: Int) {
|
|
|
halfWidth = MeasureSpec.getSize(widthSpec) / 2
|
|
halfWidth = MeasureSpec.getSize(widthSpec) / 2
|
|
|
halfHeight = MeasureSpec.getSize(heightSpec) / 2
|
|
halfHeight = MeasureSpec.getSize(heightSpec) / 2
|
|
|
if (!heightSet) {
|
|
if (!heightSet) {
|
|
|
originalHeight = MeasureSpec.getSize(heightSpec)
|
|
originalHeight = MeasureSpec.getSize(heightSpec)
|
|
|
- val width = MeasureSpec.getSize(widthSpec)
|
|
|
|
|
- setClickArea(width, originalHeight)
|
|
|
|
|
heightSet = true
|
|
heightSet = true
|
|
|
}
|
|
}
|
|
|
super.onMeasure(widthSpec, heightSpec)
|
|
super.onMeasure(widthSpec, heightSpec)
|
|
@@ -105,12 +92,6 @@ class WebtoonRecyclerView @JvmOverloads constructor(
|
|
|
return super.dispatchNestedPreScroll(dx, dy, consumed, offsetInWindow, type)
|
|
return super.dispatchNestedPreScroll(dx, dy, consumed, offsetInWindow, type)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private fun setClickArea(width: Int, height: Int) {
|
|
|
|
|
- mcRect.set(width * 0.33f, height * 0.33f, width * 0.66f, height * 0.66f)
|
|
|
|
|
- blRect.set(0f, height * 0.66f, width * 0.33f, height.toFloat())
|
|
|
|
|
- brRect.set(width * 0.66f, height * 0.66f, width.toFloat(), height.toFloat())
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
private fun getPositionX(positionX: Float): Float {
|
|
private fun getPositionX(positionX: Float): Float {
|
|
|
if (currentScale < 1) {
|
|
if (currentScale < 1) {
|
|
|
return 0f
|
|
return 0f
|
|
@@ -250,24 +231,7 @@ class WebtoonRecyclerView @JvmOverloads constructor(
|
|
|
inner class GestureListener : GestureDetectorWithLongTap.Listener() {
|
|
inner class GestureListener : GestureDetectorWithLongTap.Listener() {
|
|
|
|
|
|
|
|
override fun onSingleTapConfirmed(ev: MotionEvent): Boolean {
|
|
override fun onSingleTapConfirmed(ev: MotionEvent): Boolean {
|
|
|
- when {
|
|
|
|
|
- mcRect.contains(ev.rawX, ev.rawY) -> {
|
|
|
|
|
- mTouchMiddle?.invoke()
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- blRect.contains(ev.rawX, ev.rawY) && !disabledClickScroller -> {
|
|
|
|
|
- mPrevPage?.invoke()
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- brRect.contains(ev.rawX, ev.rawY) && !disabledClickScroller-> {
|
|
|
|
|
- mNextPage?.invoke()
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- else -> {
|
|
|
|
|
- tapListener?.invoke(ev)
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ tapListener?.invoke(ev)
|
|
|
return false
|
|
return false
|
|
|
}
|
|
}
|
|
|
|
|
|