From 7d910f256660f1007c44aeadf5c0525c722dabe6 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 16 Dec 2019 11:30:53 +0100 Subject: [PATCH] Auto review --- .../java/im/vector/riotx/core/ui/views/ReadReceiptsView.kt | 7 ++----- .../detail/readreceipts/DisplayReadReceiptsController.kt | 4 ++-- .../home/room/detail/timeline/item/MergedHeaderItem.kt | 4 +++- .../room/detail/timeline/item/MessageInformationData.kt | 5 +++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/vector/src/main/java/im/vector/riotx/core/ui/views/ReadReceiptsView.kt b/vector/src/main/java/im/vector/riotx/core/ui/views/ReadReceiptsView.kt index ac67f6c6cb..c5e2fdf375 100644 --- a/vector/src/main/java/im/vector/riotx/core/ui/views/ReadReceiptsView.kt +++ b/vector/src/main/java/im/vector/riotx/core/ui/views/ReadReceiptsView.kt @@ -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]) } } diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/readreceipts/DisplayReadReceiptsController.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/readreceipts/DisplayReadReceiptsController.kt index ef7dba5caf..3ec60217a0 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/readreceipts/DisplayReadReceiptsController.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/readreceipts/DisplayReadReceiptsController.kt @@ -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) diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/item/MergedHeaderItem.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/item/MergedHeaderItem.kt index 728c8cd740..93f7dc271d 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/item/MergedHeaderItem.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/item/MergedHeaderItem.kt @@ -55,7 +55,7 @@ abstract class MergedHeaderItem : BaseEventItem() { 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() { val avatarUrl: String? ) + fun Data.toMatrixItem() = MatrixItem.UserItem(userId, memberName, avatarUrl) + data class Attributes( val isCollapsed: Boolean, val mergeData: List, diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/item/MessageInformationData.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/item/MessageInformationData.kt index ffaec7dd48..604a57907e 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/item/MessageInformationData.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/item/MessageInformationData.kt @@ -37,8 +37,7 @@ data class MessageInformationData( val readReceipts: List = 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)