More fixes to comment focus handling

This commit is contained in:
Alexander-- 2019-11-14 20:50:35 +06:59
parent 5716cf8cb2
commit 5f051a9766
1 changed files with 22 additions and 8 deletions

View File

@ -126,14 +126,28 @@ public class CommentsMiniInfoItemHolder extends InfoItemHolder {
} }
private void allowLinkFocus() { private void allowLinkFocus() {
itemContentView.setMovementMethod(LinkMovementMethod.getInstance());
}
private void denyLinkFocus() {
itemContentView.setMovementMethod(null);
}
private boolean shouldFocusLinks() {
if (itemView.isInTouchMode()) { if (itemView.isInTouchMode()) {
return; return false;
} }
URLSpan[] urls = itemContentView.getUrls(); URLSpan[] urls = itemContentView.getUrls();
if (urls != null && urls.length != 0) { return urls != null && urls.length != 0;
itemContentView.setMovementMethod(LinkMovementMethod.getInstance()); }
private void determineLinkFocus() {
if (shouldFocusLinks()) {
allowLinkFocus();
} else {
denyLinkFocus();
} }
} }
@ -151,8 +165,10 @@ public class CommentsMiniInfoItemHolder extends InfoItemHolder {
linkify(); linkify();
if (!hasEllipsis) { if (hasEllipsis) {
allowLinkFocus(); denyLinkFocus();
} else {
determineLinkFocus();
} }
} }
@ -168,13 +184,11 @@ public class CommentsMiniInfoItemHolder extends InfoItemHolder {
itemContentView.setMaxLines(commentExpandedLines); itemContentView.setMaxLines(commentExpandedLines);
itemContentView.setText(commentText); itemContentView.setText(commentText);
linkify(); linkify();
allowLinkFocus(); determineLinkFocus();
} }
private void linkify(){ private void linkify(){
Linkify.addLinks(itemContentView, Linkify.WEB_URLS); Linkify.addLinks(itemContentView, Linkify.WEB_URLS);
Linkify.addLinks(itemContentView, pattern, null, null, timestampLink); Linkify.addLinks(itemContentView, pattern, null, null, timestampLink);
itemContentView.setMovementMethod(null);
} }
} }