diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt index 3c30b19d49..0a943a5bf3 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt @@ -211,10 +211,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe var searchViewItem: MenuItem? = null private val isScrolledToBottom: Boolean - get() { - val position = layoutManager?.findFirstCompletelyVisibleItemPosition() ?: 0 - return position == 0 - } + get() = binding?.conversationRecyclerView?.isScrolledToBottom ?: true private val layoutManager: LinearLayoutManager? get() { return binding?.conversationRecyclerView?.layoutManager as LinearLayoutManager? } diff --git a/libsession/src/main/java/org/session/libsession/utilities/ViewUtils.kt b/libsession/src/main/java/org/session/libsession/utilities/ViewUtils.kt index 5781ea3e2c..f67abe8ec4 100644 --- a/libsession/src/main/java/org/session/libsession/utilities/ViewUtils.kt +++ b/libsession/src/main/java/org/session/libsession/utilities/ViewUtils.kt @@ -4,6 +4,7 @@ import android.content.Context import android.util.TypedValue import androidx.annotation.AttrRes import androidx.annotation.ColorInt +import androidx.recyclerview.widget.RecyclerView @ColorInt fun Context.getColorFromAttr( @@ -13,4 +14,10 @@ fun Context.getColorFromAttr( ): Int { theme.resolveAttribute(attrColor, typedValue, resolveRefs) return typedValue.data -} \ No newline at end of file +} + +val RecyclerView.isScrolledToBottom: Boolean + get() { + val contentHeight = height - (paddingTop + paddingBottom) + return computeVerticalScrollRange() == computeVerticalScrollOffset() + contentHeight + }