From 199cfd4d326649f2677067b46fb503199c29db7b Mon Sep 17 00:00:00 2001 From: Kanguk Lee Date: Thu, 20 Apr 2017 09:09:30 +0900 Subject: [PATCH 1/2] Update PolygonView.java added invalidate method. It will be more natural by preventing the square twist. --- .../java/com/scanlibrary/PolygonView.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/ScanDemoExample/scanlibrary/src/main/java/com/scanlibrary/PolygonView.java b/ScanDemoExample/scanlibrary/src/main/java/com/scanlibrary/PolygonView.java index 362e4c76..3efd940b 100644 --- a/ScanDemoExample/scanlibrary/src/main/java/com/scanlibrary/PolygonView.java +++ b/ScanDemoExample/scanlibrary/src/main/java/com/scanlibrary/PolygonView.java @@ -292,5 +292,57 @@ public boolean onTouch(View v, MotionEvent event) { } + public void invalidate() { + if (pointer1.getX() > pointer4.getX() && pointer1.getY() > pointer4.getY()) { + ImageView tempImageView = pointer4; + pointer4 = pointer1; + pointer1 = tempImageView; + } + + if (pointer2.getY() > pointer3.getY() && pointer2.getX() < pointer3.getX()) { + ImageView tempImageView = pointer3; + pointer3 = pointer2; + pointer2 = tempImageView; + } + + if (pointer1.getX() > pointer4.getX()) { + ImageView tempImageView = pointer4; + pointer4 = pointer3; + pointer3 = tempImageView; + } + + if (pointer1.getY() > pointer3.getY()) { + ImageView tempImageView = pointer3; + pointer3 = pointer1; + pointer1 = tempImageView; + } + + if (pointer2.getY() > pointer4.getY()) { + ImageView tempImageView = pointer4; + pointer4 = pointer2; + pointer2 = tempImageView; + } + + + if (pointer1.getX() > pointer2.getX()) { + ImageView tempImageView = pointer2; + pointer2 = pointer1; + pointer1 = tempImageView; + } + + if (pointer3.getX() > pointer4.getX()) { + ImageView tempImageView = pointer4; + pointer4 = pointer3; + pointer3 = tempImageView; + } + + + midPointer13.setOnTouchListener(new MidPointTouchListenerImpl(pointer1, pointer3)); + midPointer12.setOnTouchListener(new MidPointTouchListenerImpl(pointer1, pointer2)); + midPointer34.setOnTouchListener(new MidPointTouchListenerImpl(pointer3, pointer4)); + midPointer24.setOnTouchListener(new MidPointTouchListenerImpl(pointer2, pointer4)); + + super.invalidate(); + } } From 83087a7edbf4d1f51719fe827ad3ca9422b7e416 Mon Sep 17 00:00:00 2001 From: Kanguk Lee Date: Thu, 20 Apr 2017 13:54:47 +0900 Subject: [PATCH 2/2] Update PolygonView.java Added superInvalidate() method That's just the original invalidate method. Used to move the midpointer. --- .../src/main/java/com/scanlibrary/PolygonView.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ScanDemoExample/scanlibrary/src/main/java/com/scanlibrary/PolygonView.java b/ScanDemoExample/scanlibrary/src/main/java/com/scanlibrary/PolygonView.java index 3efd940b..4f61bf2d 100644 --- a/ScanDemoExample/scanlibrary/src/main/java/com/scanlibrary/PolygonView.java +++ b/ScanDemoExample/scanlibrary/src/main/java/com/scanlibrary/PolygonView.java @@ -238,7 +238,11 @@ public boolean onTouch(View v, MotionEvent event) { default: break; } - polygonView.invalidate(); + if (eid == MotionEvent.ACTION_MOVE) { + polygonView.superInvalidate(); + }else { + polygonView.invalidate(); + } return true; } } @@ -345,4 +349,8 @@ public void invalidate() { super.invalidate(); } + + public void superInvalidate() { + super.invalidate(); + } }