From f094f84b865d2ffdfd27f40a7c83912da007efce Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Mon, 22 Aug 2022 15:17:08 +0200 Subject: [PATCH] fix ConversationLineItemDecoration (#2677) * fix ConversationLineItemDecoration * cleanup code a bit --- .../viewthread/ConversationLineItemDecoration.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/viewthread/ConversationLineItemDecoration.kt b/app/src/main/java/com/keylesspalace/tusky/components/viewthread/ConversationLineItemDecoration.kt index 7e98ebef7..36e36d10f 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/viewthread/ConversationLineItemDecoration.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/viewthread/ConversationLineItemDecoration.kt @@ -20,6 +20,7 @@ import android.graphics.Canvas import android.graphics.drawable.Drawable import android.view.View import androidx.core.content.ContextCompat +import androidx.core.view.forEach import androidx.recyclerview.widget.RecyclerView import com.keylesspalace.tusky.R @@ -31,14 +32,13 @@ class ConversationLineItemDecoration(private val context: Context) : RecyclerVie val dividerStart = parent.paddingStart + context.resources.getDimensionPixelSize(R.dimen.status_line_margin_start) val dividerEnd = dividerStart + divider.intrinsicWidth - val childCount = parent.childCount val avatarMargin = context.resources.getDimensionPixelSize(R.dimen.account_avatar_margin) - for (i in 0 until childCount) { - val child = parent.getChildAt(i) + val items = (parent.adapter as ThreadAdapter).currentList + + parent.forEach { child -> val position = parent.getChildAdapterPosition(child) - val items = (parent.adapter as ThreadAdapter).currentList val current = items.getOrNull(position) @@ -50,7 +50,7 @@ class ConversationLineItemDecoration(private val context: Context) : RecyclerVie child.top + avatarMargin } val below = items.getOrNull(position + 1) - val dividerBottom = if (below != null && current.id == below.status.inReplyToId && below.isDetailed) { + val dividerBottom = if (below != null && current.id == below.status.inReplyToId && !current.isDetailed) { child.bottom } else { child.top + avatarMargin