Small improvement for IconVisitor (added color null check)

This commit is contained in:
Dimitry Ivanov 2018-02-16 18:17:53 +03:00
parent 286fbae403
commit 4d9e5a299e

View File

@ -2,6 +2,7 @@ package ru.noties.markwon.sample.extension;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.text.TextUtils; import android.text.TextUtils;
import android.widget.TextView;
import org.commonmark.node.CustomNode; import org.commonmark.node.CustomNode;
@ -40,14 +41,19 @@ public class IconVisitor extends SpannableMarkdownVisitor {
final IconNode node = (IconNode) customNode; final IconNode node = (IconNode) customNode;
final String name = node.name(); final String name = node.name();
final String color = node.color();
final String size = node.size(); final String size = node.size();
if (!TextUtils.isEmpty(name) if (!TextUtils.isEmpty(name)
&& !TextUtils.isEmpty(color)
&& !TextUtils.isEmpty(size)) { && !TextUtils.isEmpty(size)) {
final int length = builder.length(); final int length = builder.length();
builder.append(name); builder.append(name);
builder.setSpan(iconSpanProvider.provide(node.name(), node.color(), node.size()), length); builder.setSpan(iconSpanProvider.provide(name, color, size), length);
builder.append(' '); builder.append(' ');
return true; return true;
} }
} }