MCPcopy Create free account
hub / github.com/M66B/FairEmail / getWord

Method getWord

app/src/main/java/eu/faircode/email/StyleHelper.java:1588–1614  ·  view source on GitHub ↗
(TextView tvBody)

Source from the content-addressed store, hash-verified

1586 }
1587
1588 static private Pair<Integer, Integer> getWord(TextView tvBody) {
1589 int start = tvBody.getSelectionStart();
1590 int end = tvBody.getSelectionEnd();
1591 Spannable edit = (Spannable) tvBody.getText();
1592
1593 if (start < 0 || end < 0)
1594 return null;
1595
1596 if (start > end) {
1597 int tmp = start;
1598 start = end;
1599 end = tmp;
1600 }
1601
1602 // Expand selection at start
1603 while (start > 0 && edit.charAt(start - 1) != ' ' && edit.charAt(start - 1) != '\n')
1604 start--;
1605
1606 // Expand selection at end
1607 while (end < edit.length() && edit.charAt(end) != ' ' && edit.charAt(end) != '\n')
1608 end++;
1609
1610 if (start == end)
1611 return null;
1612
1613 return new Pair<>(start, end);
1614 }
1615
1616 public static Pair<Integer, Integer> getParagraph(TextView tvBody) {
1617 return getParagraph(tvBody, false);

Callers 1

applyMethod · 0.95

Calls 3

charAtMethod · 0.80
getTextMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected