Auto review

This commit is contained in:
Benoit Marty 2019-12-16 11:30:53 +01:00
parent 0a0eda3e34
commit 7d910f2566
4 changed files with 10 additions and 10 deletions

View File

@ -22,11 +22,11 @@ import android.view.View
import android.widget.ImageView
import android.widget.LinearLayout
import androidx.core.view.isVisible
import im.vector.matrix.android.api.util.MatrixItem
import im.vector.riotx.R
import im.vector.riotx.core.glide.GlideApp
import im.vector.riotx.features.home.AvatarRenderer
import im.vector.riotx.features.home.room.detail.timeline.item.ReadReceiptData
import im.vector.riotx.features.home.room.detail.timeline.item.toMatrixItem
import kotlinx.android.synthetic.main.view_read_receipts.view.*
private const val MAX_RECEIPT_DISPLAYED = 5
@ -60,10 +60,7 @@ class ReadReceiptsView @JvmOverloads constructor(
receiptAvatars[index].visibility = View.INVISIBLE
} else {
receiptAvatars[index].visibility = View.VISIBLE
avatarRenderer.render(
MatrixItem.UserItem(receiptData.userId, receiptData.displayName, receiptData.avatarUrl),
receiptAvatars[index]
)
avatarRenderer.render(receiptData.toMatrixItem(), receiptAvatars[index])
}
}

View File

@ -18,10 +18,10 @@ package im.vector.riotx.features.home.room.detail.readreceipts
import com.airbnb.epoxy.TypedEpoxyController
import im.vector.matrix.android.api.session.Session
import im.vector.matrix.android.api.util.MatrixItem
import im.vector.riotx.core.date.VectorDateFormatter
import im.vector.riotx.features.home.AvatarRenderer
import im.vector.riotx.features.home.room.detail.timeline.item.ReadReceiptData
import im.vector.riotx.features.home.room.detail.timeline.item.toMatrixItem
import javax.inject.Inject
/**
@ -37,7 +37,7 @@ class DisplayReadReceiptsController @Inject constructor(private val dateFormatte
val timestamp = dateFormatter.formatRelativeDateTime(it.timestamp)
DisplayReadReceiptItem_()
.id(it.userId)
.matrixItem(MatrixItem.UserItem(it.userId, it.displayName, it.avatarUrl))
.matrixItem(it.toMatrixItem())
.avatarRenderer(avatarRender)
.timestamp(timestamp)
.addIf(session.myUserId != it.userId, this)

View File

@ -55,7 +55,7 @@ abstract class MergedHeaderItem : BaseEventItem<MergedHeaderItem.Holder>() {
val data = distinctMergeData.getOrNull(index)
if (data != null && view is ImageView) {
view.visibility = View.VISIBLE
attributes.avatarRenderer.render(MatrixItem.UserItem(data.userId, data.memberName, data.avatarUrl), view)
attributes.avatarRenderer.render(data.toMatrixItem(), view)
} else {
view.visibility = View.GONE
}
@ -88,6 +88,8 @@ abstract class MergedHeaderItem : BaseEventItem<MergedHeaderItem.Holder>() {
val avatarUrl: String?
)
fun Data.toMatrixItem() = MatrixItem.UserItem(userId, memberName, avatarUrl)
data class Attributes(
val isCollapsed: Boolean,
val mergeData: List<Data>,

View File

@ -37,8 +37,7 @@ data class MessageInformationData(
val readReceipts: List<ReadReceiptData> = emptyList()
) : Parcelable {
val matrixItem: MatrixItem
get() = MatrixItem.UserItem(senderId, memberName?.toString(), avatarUrl)
val matrixItem = MatrixItem.UserItem(senderId, memberName?.toString(), avatarUrl)
}
@Parcelize
@ -56,3 +55,5 @@ data class ReadReceiptData(
val displayName: String?,
val timestamp: Long
) : Parcelable
fun ReadReceiptData.toMatrixItem() = MatrixItem.UserItem(userId, displayName, avatarUrl)