Fix some crashes

This commit is contained in:
Thomas 2022-05-25 10:43:58 +02:00
parent 813a2f4e12
commit 18106ebede
2 changed files with 2 additions and 2 deletions

View File

@ -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

View File

@ -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);