Fix incorrect image showing in gallery when other media is unavailable.
This commit is contained in:
parent
f57b1a8f5e
commit
6b9e921888
1 changed files with 10 additions and 2 deletions
|
@ -60,20 +60,28 @@ class MediaPreviewRepository {
|
|||
val frontLimit: Int = limit / 2
|
||||
val windowStart = if (startingRow >= frontLimit) startingRow - frontLimit else 0
|
||||
|
||||
itemPosition = startingRow - windowStart
|
||||
|
||||
cursor.moveToPosition(windowStart)
|
||||
|
||||
for (i in 0..limit) {
|
||||
val element = MediaTable.MediaRecord.from(cursor)
|
||||
if (element.attachment?.transferState == AttachmentTable.TRANSFER_PROGRESS_DONE || element.attachment?.transferState == AttachmentTable.TRANSFER_PROGRESS_STARTED) {
|
||||
mediaRecords.add(element)
|
||||
|
||||
if (startingAttachmentId.id == cursor.requireLong(AttachmentTable.ID)) {
|
||||
itemPosition = mediaRecords.lastIndex
|
||||
}
|
||||
}
|
||||
|
||||
if (!cursor.moveToNext()) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (itemPosition == -1) {
|
||||
Log.w(TAG, "Unable to find target image for $startingAttachmentId")
|
||||
}
|
||||
}
|
||||
|
||||
val messageIds = mediaRecords.mapNotNull { it.attachment?.mmsId }.toSet()
|
||||
val messages: Map<Long, SpannableString> = SignalDatabase.messages.getMessages(messageIds)
|
||||
.map { it as MmsMessageRecord }
|
||||
|
|
Loading…
Add table
Reference in a new issue