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

[TIMOB-25186] Android: Validate Ti.UI.Label onTouchEvent #9340

Merged
merged 3 commits into from
Aug 23, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -186,24 +186,26 @@ public boolean onTouchEvent(MotionEvent event) {
y += textView.getScrollY();

Layout layout = textView.getLayout();
int line = layout.getLineForVertical(y);
int off = layout.getOffsetForHorizontal(line, x);

ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class);

if (link.length != 0) {
ClickableSpan cSpan = link[0];
if (action == MotionEvent.ACTION_UP) {
TiViewProxy proxy = getProxy();
if(proxy.hasListeners("link") && (cSpan instanceof URLSpan)) {
KrollDict evnt = new KrollDict();
evnt.put("url", ((URLSpan)cSpan).getURL());
proxy.fireEvent("link", evnt, false);
} else {
cSpan.onClick(textView);
if (layout != null) {
int line = layout.getLineForVertical(y);
int off = layout.getOffsetForHorizontal(line, x);

ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class);

if (link.length != 0) {
ClickableSpan cSpan = link[0];
if (action == MotionEvent.ACTION_UP) {
TiViewProxy proxy = getProxy();
if(proxy.hasListeners("link") && (cSpan instanceof URLSpan)) {
KrollDict evnt = new KrollDict();
evnt.put("url", ((URLSpan)cSpan).getURL());
proxy.fireEvent("link", evnt, false);
} else {
cSpan.onClick(textView);
}
} else if (action == MotionEvent.ACTION_DOWN) {
Selection.setSelection(buffer, buffer.getSpanStart(cSpan), buffer.getSpanEnd(cSpan));
}
} else if (action == MotionEvent.ACTION_DOWN) {
Selection.setSelection(buffer, buffer.getSpanStart(cSpan), buffer.getSpanEnd(cSpan));
}
}
}
Expand Down