Fix some crashes

pull/254/head
Thomas 2 years ago
parent 813a2f4e12
commit 18106ebede

@ -32,7 +32,7 @@ class RecyclerViewThreadLines(context: Context, private val lineInfoList: List<L
private val margin: Int = baseMargin * fontScale
override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) {
val position = (view.layoutParams as RecyclerView.LayoutParams).viewLayoutPosition
val position = parent.getChildAdapterPosition(view)
val level = lineInfoList[position].level
val startMargin = margin * level + margin * fontScale
if (parent.layoutDirection == View.LAYOUT_DIRECTION_LTR) outRect.left = startMargin else outRect.right = startMargin

@ -187,7 +187,7 @@ public class SpannableHelper {
if (matchEnd > content.toString().length()) {
matchEnd = content.toString().length();
}
if (content.toString().length() < matchEnd || matchStart < 0) {
if (content.toString().length() < matchEnd || matchStart < 0 || matchStart > matchEnd) {
continue;
}
final String url = content.toString().substring(matchStart, matchEnd);

Loading…
Cancel
Save