Created
May 8, 2020 19:52
-
-
Save mohosyny/980f42dbb653cfa16392c2a664f5619d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public double distanceBetweenPoints(float x, float y, float a, float b) { | |
return Math.sqrt((x - a) * (x - a) + (y - b) * (y - b)); | |
} | |
public float deltaX(float x1, float x2) { | |
return x2 - x1; | |
} | |
public float deltaY(float y1, float y2) { | |
return y2 - y1; | |
} | |
public float getAverage(float a, float b) { | |
return (a + b) / 2; | |
} | |
private void getCoordinates() { | |
// get Center of View | |
x1 = viewAvali.getX() + viewAvali.getWidth() / 2f; | |
y1 = viewAvali.getY() + viewAvali.getHeight() / 2f; | |
// get Center of View | |
x2 = viewDovomi.getX() + (viewDovomi.getWidth() / 2f); | |
y2 = viewDovomi.getY() + viewDovomi.getHeight() / 2f; | |
} | |
public boolean onTouch(View v, MotionEvent event) { | |
if (event.getAction() == MotionEvent.ACTION_MOVE) { | |
if (util.distanceBetweenPoints(x1, y1, event.getX(), event.getY()) <= 50) { | |
// touch is in view | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment