mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-30 00:17:58 +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 {
|
||||
var scaleFactor = detector.scaleFactor
|
||||
val width = video_surface.width
|
||||
val height = video_surface.height
|
||||
if (width <= 0 || height <= 0) {
|
||||
return true
|
||||
}
|
||||
|
||||
var scaleFactor = detector.scaleFactor
|
||||
val origScale = mSaveScale
|
||||
mSaveScale *= scaleFactor
|
||||
|
||||
|
@ -809,14 +813,13 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen
|
|||
|
||||
mRight = width * mSaveScale - width
|
||||
mBottom = height * mSaveScale - height
|
||||
if (0 <= width || 0 <= height) {
|
||||
mMatrix.postScale(scaleFactor, scaleFactor, detector.focusX, detector.focusY)
|
||||
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 (width > 0) {
|
||||
if (y < -mBottom) {
|
||||
mMatrix.postTranslate(0f, -(y + mBottom))
|
||||
} else if (y > 0) {
|
||||
|
@ -831,25 +834,6 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen
|
|||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mMatrix.postScale(scaleFactor, scaleFactor, detector.focusX, detector.focusY)
|
||||
mMatrix.getValues(mMatrices)
|
||||
val x = mMatrices[Matrix.MTRANS_X]
|
||||
val y = mMatrices[Matrix.MTRANS_Y]
|
||||
if (scaleFactor < 1) {
|
||||
if (x < -mRight) {
|
||||
mMatrix.postTranslate(-(x + mRight), 0f)
|
||||
} else if (x > 0) {
|
||||
mMatrix.postTranslate(-x, 0f)
|
||||
}
|
||||
|
||||
if (y < -mBottom) {
|
||||
mMatrix.postTranslate(0f, -(y + mBottom))
|
||||
} else if (y > 0) {
|
||||
mMatrix.postTranslate(0f, -y)
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -777,9 +777,13 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
|||
}
|
||||
|
||||
override fun onScale(detector: ScaleGestureDetector): Boolean {
|
||||
var scaleFactor = detector.scaleFactor
|
||||
val width = mTextureView.width
|
||||
val height = mTextureView.height
|
||||
if (width <= 0 || height <= 0) {
|
||||
return true
|
||||
}
|
||||
|
||||
var scaleFactor = detector.scaleFactor
|
||||
val origScale = mSaveScale
|
||||
mSaveScale *= scaleFactor
|
||||
|
||||
|
@ -793,14 +797,13 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
|||
|
||||
mRight = width * mSaveScale - width
|
||||
mBottom = height * mSaveScale - height
|
||||
if (0 <= width || 0 <= height) {
|
||||
mMatrix.postScale(scaleFactor, scaleFactor, detector.focusX, detector.focusY)
|
||||
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 (width > 0) {
|
||||
if (y < -mBottom) {
|
||||
mMatrix.postTranslate(0f, -(y + mBottom))
|
||||
} else if (y > 0) {
|
||||
|
@ -815,25 +818,6 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
|||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mMatrix.postScale(scaleFactor, scaleFactor, detector.focusX, detector.focusY)
|
||||
mMatrix.getValues(mMatrices)
|
||||
val x = mMatrices[Matrix.MTRANS_X]
|
||||
val y = mMatrices[Matrix.MTRANS_Y]
|
||||
if (scaleFactor < 1) {
|
||||
if (x < -mRight) {
|
||||
mMatrix.postTranslate(-(x + mRight), 0f)
|
||||
} else if (x > 0) {
|
||||
mMatrix.postTranslate(-x, 0f)
|
||||
}
|
||||
|
||||
if (y < -mBottom) {
|
||||
mMatrix.postTranslate(0f, -(y + mBottom))
|
||||
} else if (y > 0) {
|
||||
mMatrix.postTranslate(0f, -y)
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,6 +132,10 @@ class MyZoomableGifTextureView(context: Context, attrs: AttributeSet) : GifTextu
|
|||
}
|
||||
|
||||
override fun onScale(detector: ScaleGestureDetector): Boolean {
|
||||
if (width <= 0 || height <= 0) {
|
||||
return true
|
||||
}
|
||||
|
||||
mLastFocusX = detector.focusX
|
||||
mLastFocusY = detector.focusY
|
||||
var scaleFactor = detector.scaleFactor
|
||||
|
@ -148,14 +152,13 @@ class MyZoomableGifTextureView(context: Context, attrs: AttributeSet) : GifTextu
|
|||
|
||||
mRight = width * mSaveScale - width
|
||||
mBottom = height * mSaveScale - height
|
||||
if (0 <= width || 0 <= height) {
|
||||
mMatrix.postScale(scaleFactor, scaleFactor, detector.focusX, detector.focusY)
|
||||
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 (width > 0) {
|
||||
if (y < -mBottom) {
|
||||
mMatrix.postTranslate(0f, -(y + mBottom))
|
||||
} else if (y > 0) {
|
||||
|
@ -170,25 +173,6 @@ class MyZoomableGifTextureView(context: Context, attrs: AttributeSet) : GifTextu
|
|||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mMatrix.postScale(scaleFactor, scaleFactor, detector.focusX, detector.focusY)
|
||||
mMatrix.getValues(mMatrices)
|
||||
val x = mMatrices[Matrix.MTRANS_X]
|
||||
val y = mMatrices[Matrix.MTRANS_Y]
|
||||
if (scaleFactor < 1) {
|
||||
if (x < -mRight) {
|
||||
mMatrix.postTranslate(-(x + mRight), 0f)
|
||||
} else if (x > 0) {
|
||||
mMatrix.postTranslate(-x, 0f)
|
||||
}
|
||||
|
||||
if (y < -mBottom) {
|
||||
mMatrix.postTranslate(0f, -(y + mBottom))
|
||||
} else if (y > 0) {
|
||||
mMatrix.postTranslate(0f, -y)
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue