fix crash when status has more than 4 images and accessibility service is active (#1204)
This commit is contained in:
parent
1b9e279064
commit
ea048c9f0c
1 changed files with 4 additions and 1 deletions
|
@ -16,8 +16,10 @@ import androidx.recyclerview.widget.RecyclerView
|
||||||
import androidx.recyclerview.widget.RecyclerViewAccessibilityDelegate
|
import androidx.recyclerview.widget.RecyclerViewAccessibilityDelegate
|
||||||
import com.keylesspalace.tusky.R
|
import com.keylesspalace.tusky.R
|
||||||
import com.keylesspalace.tusky.adapter.StatusBaseViewHolder
|
import com.keylesspalace.tusky.adapter.StatusBaseViewHolder
|
||||||
|
import com.keylesspalace.tusky.entity.Status.Companion.MAX_MEDIA_ATTACHMENTS
|
||||||
import com.keylesspalace.tusky.interfaces.StatusActionListener
|
import com.keylesspalace.tusky.interfaces.StatusActionListener
|
||||||
import com.keylesspalace.tusky.viewdata.StatusViewData
|
import com.keylesspalace.tusky.viewdata.StatusViewData
|
||||||
|
import kotlin.math.min
|
||||||
|
|
||||||
// Not using lambdas because there's boxing of int then
|
// Not using lambdas because there's boxing of int then
|
||||||
interface StatusProvider {
|
interface StatusProvider {
|
||||||
|
@ -60,7 +62,8 @@ class ListStatusAccessibilityDelegate(
|
||||||
R.id.action_open_media_2,
|
R.id.action_open_media_2,
|
||||||
R.id.action_open_media_3,
|
R.id.action_open_media_3,
|
||||||
R.id.action_open_media_4)
|
R.id.action_open_media_4)
|
||||||
for (i in 0 until status.attachments.size) {
|
val attachmentCount = min(status.attachments.size, MAX_MEDIA_ATTACHMENTS)
|
||||||
|
for (i in 0 until attachmentCount) {
|
||||||
info.addAction(AccessibilityActionCompat(
|
info.addAction(AccessibilityActionCompat(
|
||||||
mediaActions[i],
|
mediaActions[i],
|
||||||
context.getString(R.string.action_open_media_n, i + 1)))
|
context.getString(R.string.action_open_media_n, i + 1)))
|
||||||
|
|
Loading…
Reference in a new issue