Add 50 dp buffer to isScrolledToBottom (#1228)

This commit is contained in:
Andrew
2023-06-14 10:34:49 +09:30
committed by GitHub
parent f0486061b1
commit cc015c45bd
2 changed files with 7 additions and 5 deletions

View File

@@ -3,6 +3,8 @@ package org.thoughtcrime.securesms.util
import android.content.res.Resources
import android.os.Build
import androidx.annotation.ColorRes
import androidx.recyclerview.widget.RecyclerView
import kotlin.math.max
import kotlin.math.roundToInt
fun Resources.getColorWithID(@ColorRes id: Int, theme: Resources.Theme?): Int {
@@ -30,3 +32,8 @@ fun toDp(px: Float, resources: Resources): Float {
val scale = resources.displayMetrics.density
return (px / scale)
}
val RecyclerView.isScrolledToBottom: Boolean
get() = computeVerticalScrollOffset().coerceAtLeast(0) +
computeVerticalScrollExtent() +
toPx(50, resources) >= computeVerticalScrollRange()