1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 16:40:32 +00:00

linkify optimizations

This commit is contained in:
yausername 2019-03-22 04:57:33 +05:30
parent 6421d3017e
commit a026143a84

View File

@ -91,15 +91,14 @@ public class CommentsMiniInfoItemHolder extends InfoItemHolder {
streamUrl = item.getUrl();
itemContentView.setMaxLines(commentDefaultLines);
itemContentView.setLines(commentDefaultLines);
commentText = item.getCommentText();
itemContentView.setText(commentText);
linkify();
itemContentView.setOnTouchListener(CommentTextOnTouchListener.INSTANCE);
if(itemContentView.getLineCount() == 0){
if (itemContentView.getLineCount() == 0) {
itemContentView.post(() -> ellipsize());
}else{
} else {
ellipsize();
}
@ -119,15 +118,17 @@ public class CommentsMiniInfoItemHolder extends InfoItemHolder {
private void ellipsize() {
if (itemContentView.getLineCount() > commentDefaultLines){
int endOfLastLine = itemContentView.getLayout().getLineEnd(commentDefaultLines - 1);
String newVal = itemContentView.getText().subSequence(0, endOfLastLine - 3) + "...";
int end = itemContentView.getText().toString().lastIndexOf(' ', endOfLastLine -3);
if(end == -1) end = Math.max(endOfLastLine -3, 0);
String newVal = itemContentView.getText().subSequence(0, end) + "...";
itemContentView.setText(newVal);
linkify();
}
linkify();
}
private void toggleEllipsize() {
if (itemContentView.getText().toString().equals(commentText)) {
ellipsize();
if (itemContentView.getLineCount() > commentDefaultLines) ellipsize();
} else {
expand();
}