// Documentation from interface
public SpannableStringBuilder append(CharSequence text) {
int length = length();
return replace(length, length, text, 0, text.length());
}
SpannableStringBuilder
source code append()
function doesn't avoid NullPointerException
??
If text is null, append()
function definitely throw NullPointerException
.
It's easily be forgotten to check every case if text is null. For example the text may from the server.
Anyone has a better idea for SpannableStringBuilder
append()
function to avoid npe?
You could wrap the
SpannableStringBuilder
in your own class and put thenull
check there .