Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update PolygonView.java #37

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,11 @@ public boolean onTouch(View v, MotionEvent event) {
default:
break;
}
polygonView.invalidate();
if (eid == MotionEvent.ACTION_MOVE) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR. Could you please help me understand the reason behind these changes.

polygonView.superInvalidate();
}else {
polygonView.invalidate();
}
return true;
}
}
Expand Down Expand Up @@ -292,5 +296,61 @@ 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();
}

public void superInvalidate() {
super.invalidate();
}
}