Skip to content

Commit 7f6ddd5

Browse files
author
deano2390
committed
fix click behavior, stop it consuming touch events when it shouldn't
1 parent 04d3565 commit 7f6ddd5

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

flowtextview/src/main/java/uk/co/deanwild/flowtextview/helpers/ClickHandler.java

+10-9
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,18 @@ public boolean onTouch(View view, MotionEvent event) {
4040
distance = getPointDistance(x1, y1, x2, y2);
4141
}
4242

43-
if(distance < 10){
44-
45-
if(event_code == MotionEvent.ACTION_UP){
46-
onClick(event.getX(), event.getY());
43+
if(distance < 10) { // my random guess at an acceptable drift distance to regard this as a click
44+
if (event_code == MotionEvent.ACTION_UP) {
45+
// if the event is an "up" and we havn't moved far since the "down", then it's a click
46+
return onClick(event.getX(), event.getY()); // process the click and say whether we consumed it
4747
}
48-
4948
return true;
50-
}else{
51-
return false;
5249
}
50+
51+
return false;
5352
}
5453

55-
private void onClick(float x, float y){
54+
private boolean onClick(float x, float y){
5655

5756
ArrayList<HtmlLink> links = mSpanParser.getLinks();
5857

@@ -66,10 +65,12 @@ private void onClick(float x, float y){
6665
if(y > tlY && y < brY){
6766
// collision
6867
onLinkClick(link.url);
69-
return;
68+
return true; // the click was consumed
7069
}
7170
}
7271
}
72+
73+
return false;
7374
}
7475

7576
private void onLinkClick(String url){

0 commit comments

Comments
 (0)