Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 389a1de0 authored by Sudheer Shanka's avatar Sudheer Shanka Committed by Android (Google) Code Review
Browse files

Merge "Avoid NPE in trimToLengthWithEllipsis()."

parents 2c9639a3 bfdc4775
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2173,7 +2173,7 @@ public class TextUtils {
    public static <T extends CharSequence> T trimToLengthWithEllipsis(@Nullable T text,
            @IntRange(from = 1) int size) {
        T trimmed = trimToSize(text, size);
        if (trimmed.length() < text.length()) {
        if (text != null && trimmed.length() < text.length()) {
            trimmed = (T) (trimmed.toString() + "...");
        }
        return trimmed;
+1 −0
Original line number Diff line number Diff line
@@ -792,5 +792,6 @@ public class TextUtilsTest {
        assertEquals("ABC...", TextUtils.trimToLengthWithEllipsis("ABCDEF", 3));
        assertEquals("ABC", TextUtils.trimToLengthWithEllipsis("ABC", 3));
        assertEquals("", TextUtils.trimToLengthWithEllipsis("", 3));
        assertNull(TextUtils.trimToLengthWithEllipsis(null, 3));
    }
}