fix crash when status has more than 4 images and accessibility service is active (#1204)

This commit is contained in:
Konrad Pozniak 2019-04-21 14:29:47 +02:00 committed by GitHub
parent 1b9e279064
commit ea048c9f0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -16,8 +16,10 @@ import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerViewAccessibilityDelegate
import com.keylesspalace.tusky.R
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.viewdata.StatusViewData
import kotlin.math.min
// Not using lambdas because there's boxing of int then
interface StatusProvider {
@ -60,7 +62,8 @@ class ListStatusAccessibilityDelegate(
R.id.action_open_media_2,
R.id.action_open_media_3,
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(
mediaActions[i],
context.getString(R.string.action_open_media_n, i + 1)))