Skip to content

Commit

Permalink
#9: avoid starting a long-press timer if touch does not start on a Cl…
Browse files Browse the repository at this point in the history
…ickableSpan
  • Loading branch information
saket committed Feb 18, 2018
1 parent a1bf651 commit 068976d
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ public boolean onTouchEvent(final TextView textView, Spannable text, MotionEvent
}

final ClickableSpan clickableSpanUnderTouch = findClickableSpanUnderTouch(textView, text, event);
if (event.getAction() == MotionEvent.ACTION_DOWN) {
clickableSpanUnderTouchOnActionDown = clickableSpanUnderTouch;
}
final boolean touchStartedOverALink = clickableSpanUnderTouchOnActionDown != null;

switch (event.getAction()) {
Expand All @@ -234,8 +237,6 @@ public void onTimerReached() {
};
startTimerForRegisteringLongClick(textView, longClickListener);
}

clickableSpanUnderTouchOnActionDown = clickableSpanUnderTouch;
return touchStartedOverALink;

case MotionEvent.ACTION_UP:
Expand Down Expand Up @@ -278,6 +279,7 @@ public void onTimerReached() {

private void cleanupOnTouchUp(TextView textView) {
wasLongPressRegistered = false;
clickableSpanUnderTouchOnActionDown = null;
removeUrlHighlightColor(textView);
removeLongPressCallback(textView);
}
Expand Down

0 comments on commit 068976d

Please sign in to comment.