The current implementation of MarkdownLineHeightSpan is a bit tricky:
|
public class MarkdownLineHeightSpan implements MarkdownSpan, LineHeightSpan { |
|
private final float mLineHeight; |
|
|
|
public MarkdownLineHeightSpan(float lineHeight) { |
|
mLineHeight = lineHeight; |
|
} |
|
|
|
@Override |
|
public void chooseHeight(CharSequence text, int start, int end, int spanstartv, int lineHeight, Paint.FontMetricsInt fm) { |
|
fm.top -= mLineHeight / 4; |
|
fm.ascent -= mLineHeight / 4; |
|
} |
|
} |
Also, we need to obtain information about existing spans before applying MarkdownLineHeightSpan:
|
case "h1": |
|
setSpan(ssb, new MarkdownBoldSpan(), start, end); |
|
CustomLineHeightSpan[] spans = ssb.getSpans(0, ssb.length(), CustomLineHeightSpan.class); |
|
if (spans.length >= 1) { |
|
int lineHeight = spans[0].getLineHeight(); |
|
setSpan(ssb, new MarkdownLineHeightSpan(lineHeight * 1.5f), start, end); |
|
} |
|
// NOTE: size span must be set after line height span to avoid height jumps |
|
setSpan(ssb, new MarkdownFontSizeSpan(mMarkdownStyle.getH1FontSize()), start, end); |
The objective of this task is to eliminate division by 4 as well as calling .getSpans() method if needed.
The current implementation of
MarkdownLineHeightSpanis a bit tricky:react-native-live-markdown/android/src/main/java/com/expensify/livemarkdown/spans/MarkdownLineHeightSpan.java
Lines 6 to 18 in b753c7a
Also, we need to obtain information about existing spans before applying
MarkdownLineHeightSpan:react-native-live-markdown/android/src/main/java/com/expensify/livemarkdown/MarkdownUtils.java
Lines 149 to 157 in b753c7a
The objective of this task is to eliminate division by 4 as well as calling
.getSpans()method if needed.