Skip to content

Commit 5b6f2cf

Browse files
authored
Merge pull request #514 from MikeOrtiz/zoom
Revert "SetZoom update the method to calculate the trans"
2 parents 2796c2d + 5bbcb08 commit 5b6f2cf

File tree

7 files changed

+4
-3
lines changed

7 files changed

+4
-3
lines changed

app/src/androidTest/java/info/touchimage/demo/MainSmokeTest.kt

+1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ class MainSmokeTest {
100100
fun testChangeSize() {
101101
Espresso.onView(withId(R.id.resize_button)).perform(ViewActions.click())
102102
Intents.intended(hasComponent(ChangeSizeExampleActivity::class.java.name))
103+
Thread.sleep(500)
103104
Espresso.onView(isRoot())
104105
.captureToBitmap()
105106
.writeToTestStorage("${javaClass.simpleName}_${nameRule.methodName}")

app/src/androidTest/java/info/touchimage/demo/TouchTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class TouchTest {
3232
.writeToTestStorage("${javaClass.simpleName}_${nameRule.methodName}-touch1")
3333
onView(withId(R.id.imageSingle)).perform(TouchAction(40f, 80f))
3434
Thread.sleep(300)
35-
takeScreenshot()
35+
onView(withId(R.id.imageSingle)).captureToBitmap()
3636
.writeToTestStorage("${javaClass.simpleName}_${nameRule.methodName}-touch2")
3737
}
3838

Loading
Loading
-6 KB
Loading
5.52 KB
Loading

touchview/src/main/java/com/ortiz/touchview/TouchImageView.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,8 @@ open class TouchImageView @JvmOverloads constructor(context: Context, attrs: Att
394394
resetZoom()
395395
scaleImage(scale.toDouble(), viewWidth / 2.toFloat(), viewHeight / 2.toFloat(), true)
396396
touchMatrix.getValues(floatMatrix)
397-
floatMatrix[Matrix.MTRANS_X] = (viewWidth - matchViewWidth) / 2 - focusX * (scale - 1) * matchViewWidth
398-
floatMatrix[Matrix.MTRANS_Y] = (viewHeight - matchViewHeight) / 2 - focusY * (scale - 1) * matchViewHeight
397+
floatMatrix[Matrix.MTRANS_X] = -(focusX * imageWidth - viewWidth * 0.5f)
398+
floatMatrix[Matrix.MTRANS_Y] = -(focusY * imageHeight - viewHeight * 0.5f)
399399
touchMatrix.setValues(floatMatrix)
400400
fixTrans()
401401
savePreviousImageValues()

0 commit comments

Comments
 (0)