mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 14:37:59 +01:00
removing some redundant ScaleListener code
This commit is contained in:
parent
b916f0c619
commit
8cee888dc6
3 changed files with 56 additions and 104 deletions
|
@ -793,9 +793,13 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onScale(detector: ScaleGestureDetector): Boolean {
|
override fun onScale(detector: ScaleGestureDetector): Boolean {
|
||||||
var scaleFactor = detector.scaleFactor
|
|
||||||
val width = video_surface.width
|
val width = video_surface.width
|
||||||
val height = video_surface.height
|
val height = video_surface.height
|
||||||
|
if (width <= 0 || height <= 0) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
var scaleFactor = detector.scaleFactor
|
||||||
val origScale = mSaveScale
|
val origScale = mSaveScale
|
||||||
mSaveScale *= scaleFactor
|
mSaveScale *= scaleFactor
|
||||||
|
|
||||||
|
@ -809,44 +813,24 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen
|
||||||
|
|
||||||
mRight = width * mSaveScale - width
|
mRight = width * mSaveScale - width
|
||||||
mBottom = height * mSaveScale - height
|
mBottom = height * mSaveScale - height
|
||||||
if (0 <= width || 0 <= height) {
|
mMatrix.postScale(scaleFactor, scaleFactor, detector.focusX, detector.focusY)
|
||||||
mMatrix.postScale(scaleFactor, scaleFactor, detector.focusX, detector.focusY)
|
if (scaleFactor < 1) {
|
||||||
if (scaleFactor < 1) {
|
|
||||||
mMatrix.getValues(mMatrices)
|
|
||||||
val x = mMatrices[Matrix.MTRANS_X]
|
|
||||||
val y = mMatrices[Matrix.MTRANS_Y]
|
|
||||||
if (scaleFactor < 1) {
|
|
||||||
if (0 < width) {
|
|
||||||
if (y < -mBottom) {
|
|
||||||
mMatrix.postTranslate(0f, -(y + mBottom))
|
|
||||||
} else if (y > 0) {
|
|
||||||
mMatrix.postTranslate(0f, -y)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (x < -mRight) {
|
|
||||||
mMatrix.postTranslate(-(x + mRight), 0f)
|
|
||||||
} else if (x > 0) {
|
|
||||||
mMatrix.postTranslate(-x, 0f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
mMatrix.postScale(scaleFactor, scaleFactor, detector.focusX, detector.focusY)
|
|
||||||
mMatrix.getValues(mMatrices)
|
mMatrix.getValues(mMatrices)
|
||||||
val x = mMatrices[Matrix.MTRANS_X]
|
val x = mMatrices[Matrix.MTRANS_X]
|
||||||
val y = mMatrices[Matrix.MTRANS_Y]
|
val y = mMatrices[Matrix.MTRANS_Y]
|
||||||
if (scaleFactor < 1) {
|
if (scaleFactor < 1) {
|
||||||
if (x < -mRight) {
|
if (width > 0) {
|
||||||
mMatrix.postTranslate(-(x + mRight), 0f)
|
if (y < -mBottom) {
|
||||||
} else if (x > 0) {
|
mMatrix.postTranslate(0f, -(y + mBottom))
|
||||||
mMatrix.postTranslate(-x, 0f)
|
} else if (y > 0) {
|
||||||
}
|
mMatrix.postTranslate(0f, -y)
|
||||||
|
}
|
||||||
if (y < -mBottom) {
|
} else {
|
||||||
mMatrix.postTranslate(0f, -(y + mBottom))
|
if (x < -mRight) {
|
||||||
} else if (y > 0) {
|
mMatrix.postTranslate(-(x + mRight), 0f)
|
||||||
mMatrix.postTranslate(0f, -y)
|
} else if (x > 0) {
|
||||||
|
mMatrix.postTranslate(-x, 0f)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -777,9 +777,13 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onScale(detector: ScaleGestureDetector): Boolean {
|
override fun onScale(detector: ScaleGestureDetector): Boolean {
|
||||||
var scaleFactor = detector.scaleFactor
|
|
||||||
val width = mTextureView.width
|
val width = mTextureView.width
|
||||||
val height = mTextureView.height
|
val height = mTextureView.height
|
||||||
|
if (width <= 0 || height <= 0) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
var scaleFactor = detector.scaleFactor
|
||||||
val origScale = mSaveScale
|
val origScale = mSaveScale
|
||||||
mSaveScale *= scaleFactor
|
mSaveScale *= scaleFactor
|
||||||
|
|
||||||
|
@ -793,44 +797,24 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
||||||
|
|
||||||
mRight = width * mSaveScale - width
|
mRight = width * mSaveScale - width
|
||||||
mBottom = height * mSaveScale - height
|
mBottom = height * mSaveScale - height
|
||||||
if (0 <= width || 0 <= height) {
|
mMatrix.postScale(scaleFactor, scaleFactor, detector.focusX, detector.focusY)
|
||||||
mMatrix.postScale(scaleFactor, scaleFactor, detector.focusX, detector.focusY)
|
if (scaleFactor < 1) {
|
||||||
if (scaleFactor < 1) {
|
|
||||||
mMatrix.getValues(mMatrices)
|
|
||||||
val x = mMatrices[Matrix.MTRANS_X]
|
|
||||||
val y = mMatrices[Matrix.MTRANS_Y]
|
|
||||||
if (scaleFactor < 1) {
|
|
||||||
if (0 < width) {
|
|
||||||
if (y < -mBottom) {
|
|
||||||
mMatrix.postTranslate(0f, -(y + mBottom))
|
|
||||||
} else if (y > 0) {
|
|
||||||
mMatrix.postTranslate(0f, -y)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (x < -mRight) {
|
|
||||||
mMatrix.postTranslate(-(x + mRight), 0f)
|
|
||||||
} else if (x > 0) {
|
|
||||||
mMatrix.postTranslate(-x, 0f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
mMatrix.postScale(scaleFactor, scaleFactor, detector.focusX, detector.focusY)
|
|
||||||
mMatrix.getValues(mMatrices)
|
mMatrix.getValues(mMatrices)
|
||||||
val x = mMatrices[Matrix.MTRANS_X]
|
val x = mMatrices[Matrix.MTRANS_X]
|
||||||
val y = mMatrices[Matrix.MTRANS_Y]
|
val y = mMatrices[Matrix.MTRANS_Y]
|
||||||
if (scaleFactor < 1) {
|
if (scaleFactor < 1) {
|
||||||
if (x < -mRight) {
|
if (width > 0) {
|
||||||
mMatrix.postTranslate(-(x + mRight), 0f)
|
if (y < -mBottom) {
|
||||||
} else if (x > 0) {
|
mMatrix.postTranslate(0f, -(y + mBottom))
|
||||||
mMatrix.postTranslate(-x, 0f)
|
} else if (y > 0) {
|
||||||
}
|
mMatrix.postTranslate(0f, -y)
|
||||||
|
}
|
||||||
if (y < -mBottom) {
|
} else {
|
||||||
mMatrix.postTranslate(0f, -(y + mBottom))
|
if (x < -mRight) {
|
||||||
} else if (y > 0) {
|
mMatrix.postTranslate(-(x + mRight), 0f)
|
||||||
mMatrix.postTranslate(0f, -y)
|
} else if (x > 0) {
|
||||||
|
mMatrix.postTranslate(-x, 0f)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,6 +132,10 @@ class MyZoomableGifTextureView(context: Context, attrs: AttributeSet) : GifTextu
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onScale(detector: ScaleGestureDetector): Boolean {
|
override fun onScale(detector: ScaleGestureDetector): Boolean {
|
||||||
|
if (width <= 0 || height <= 0) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
mLastFocusX = detector.focusX
|
mLastFocusX = detector.focusX
|
||||||
mLastFocusY = detector.focusY
|
mLastFocusY = detector.focusY
|
||||||
var scaleFactor = detector.scaleFactor
|
var scaleFactor = detector.scaleFactor
|
||||||
|
@ -148,44 +152,24 @@ class MyZoomableGifTextureView(context: Context, attrs: AttributeSet) : GifTextu
|
||||||
|
|
||||||
mRight = width * mSaveScale - width
|
mRight = width * mSaveScale - width
|
||||||
mBottom = height * mSaveScale - height
|
mBottom = height * mSaveScale - height
|
||||||
if (0 <= width || 0 <= height) {
|
mMatrix.postScale(scaleFactor, scaleFactor, detector.focusX, detector.focusY)
|
||||||
mMatrix.postScale(scaleFactor, scaleFactor, detector.focusX, detector.focusY)
|
if (scaleFactor < 1) {
|
||||||
if (scaleFactor < 1) {
|
|
||||||
mMatrix.getValues(mMatrices)
|
|
||||||
val x = mMatrices[Matrix.MTRANS_X]
|
|
||||||
val y = mMatrices[Matrix.MTRANS_Y]
|
|
||||||
if (scaleFactor < 1) {
|
|
||||||
if (0 < width) {
|
|
||||||
if (y < -mBottom) {
|
|
||||||
mMatrix.postTranslate(0f, -(y + mBottom))
|
|
||||||
} else if (y > 0) {
|
|
||||||
mMatrix.postTranslate(0f, -y)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (x < -mRight) {
|
|
||||||
mMatrix.postTranslate(-(x + mRight), 0f)
|
|
||||||
} else if (x > 0) {
|
|
||||||
mMatrix.postTranslate(-x, 0f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
mMatrix.postScale(scaleFactor, scaleFactor, detector.focusX, detector.focusY)
|
|
||||||
mMatrix.getValues(mMatrices)
|
mMatrix.getValues(mMatrices)
|
||||||
val x = mMatrices[Matrix.MTRANS_X]
|
val x = mMatrices[Matrix.MTRANS_X]
|
||||||
val y = mMatrices[Matrix.MTRANS_Y]
|
val y = mMatrices[Matrix.MTRANS_Y]
|
||||||
if (scaleFactor < 1) {
|
if (scaleFactor < 1) {
|
||||||
if (x < -mRight) {
|
if (width > 0) {
|
||||||
mMatrix.postTranslate(-(x + mRight), 0f)
|
if (y < -mBottom) {
|
||||||
} else if (x > 0) {
|
mMatrix.postTranslate(0f, -(y + mBottom))
|
||||||
mMatrix.postTranslate(-x, 0f)
|
} else if (y > 0) {
|
||||||
}
|
mMatrix.postTranslate(0f, -y)
|
||||||
|
}
|
||||||
if (y < -mBottom) {
|
} else {
|
||||||
mMatrix.postTranslate(0f, -(y + mBottom))
|
if (x < -mRight) {
|
||||||
} else if (y > 0) {
|
mMatrix.postTranslate(-(x + mRight), 0f)
|
||||||
mMatrix.postTranslate(0f, -y)
|
} else if (x > 0) {
|
||||||
|
mMatrix.postTranslate(-x, 0f)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue