klinker24 / Android-TextView-LinkBuilder

Insanely easy way to define clickable links within a TextView.
MIT License
1.59k stars 199 forks source link

NullPointerException #46

Closed cnsilvan closed 6 years ago

cnsilvan commented 7 years ago

java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.indexOf(java.lang.String, int)' on a null object reference at java.util.regex.Pattern.quote(Pattern.java:439) at com.klinker.android.link_builder.LinkBuilder.on(Unknown Source) setText setContext addLinks build addLinkToSpan addLinkToSpan applyLink

cnsilvan commented 7 years ago
private void addLinkToSpan(Spannable s, Link link) {
        // maybe this line
        Pattern pattern = Pattern.compile(Pattern.quote(link.getText()));
        // maybe this line
        Matcher matcher = pattern.matcher(text);

        while (matcher.find()) {
            int start = matcher.start();
            if (start >= 0) {
                int end = start + link.getText().length();
                applyLink(link, new Range(start, end), s);
            }

            if (findOnlyFirstMatch) {
                break;
            }
        }
    }
klinker24 commented 7 years ago

For this, it would be very helpful if you could provide an example that will throw the exception.

klinker24 commented 6 years ago

Closing for no followup or method to reproduce it