lifting duplicated event_base layout to the base class, with the option for children to override

This commit is contained in:
Adam Brown 2022-06-30 09:46:20 +01:00
parent a815ac996b
commit d0e5b3eb21
13 changed files with 17 additions and 13 deletions

View File

@ -43,7 +43,9 @@ import org.matrix.android.sdk.api.util.MatrixItem
* Base timeline item that adds an optional information bar with the sender avatar, name, time, send state.
* Adds associated click listeners (on avatar, displayname).
*/
abstract class AbsMessageItem<H : AbsMessageItem.Holder>(@LayoutRes layoutId: Int) : AbsBaseMessageItem<H>(layoutId) {
abstract class AbsMessageItem<H : AbsMessageItem.Holder>(
@LayoutRes layoutId: Int = R.layout.item_timeline_event_base
) : AbsBaseMessageItem<H>(layoutId) {
override val baseAttributes: AbsBaseMessageItem.Attributes
get() = attributes

View File

@ -37,7 +37,9 @@ import im.vector.app.features.home.room.detail.timeline.helper.LocationPinProvid
import im.vector.app.features.home.room.detail.timeline.style.TimelineMessageLayout
import im.vector.app.features.home.room.detail.timeline.style.granularRoundedCorners
abstract class AbsMessageLocationItem<H : AbsMessageLocationItem.Holder>(@LayoutRes layoutId: Int) : AbsMessageItem<H>(layoutId) {
abstract class AbsMessageLocationItem<H : AbsMessageLocationItem.Holder>(
@LayoutRes layoutId: Int = R.layout.item_timeline_event_base
) : AbsMessageItem<H>(layoutId) {
@EpoxyAttribute
var locationUrl: String? = null

View File

@ -38,7 +38,7 @@ import im.vector.app.features.home.room.detail.timeline.style.TimelineMessageLay
import im.vector.app.features.themes.ThemeUtils
@EpoxyModelClass
abstract class MessageAudioItem : AbsMessageItem<MessageAudioItem.Holder>(R.layout.item_timeline_event_base) {
abstract class MessageAudioItem : AbsMessageItem<MessageAudioItem.Holder>() {
@EpoxyAttribute
var filename: String = ""

View File

@ -35,7 +35,7 @@ import im.vector.app.features.home.room.detail.timeline.style.TimelineMessageLay
import im.vector.app.features.themes.ThemeUtils
@EpoxyModelClass
abstract class MessageFileItem : AbsMessageItem<MessageFileItem.Holder>(R.layout.item_timeline_event_base) {
abstract class MessageFileItem : AbsMessageItem<MessageFileItem.Holder>() {
@EpoxyAttribute
var filename: String = ""

View File

@ -37,7 +37,7 @@ import im.vector.app.features.media.ImageContentRenderer
import org.matrix.android.sdk.api.session.room.model.message.MessageType
@EpoxyModelClass
abstract class MessageImageVideoItem : AbsMessageItem<MessageImageVideoItem.Holder>(R.layout.item_timeline_event_base) {
abstract class MessageImageVideoItem : AbsMessageItem<MessageImageVideoItem.Holder>() {
@EpoxyAttribute
lateinit var mediaData: ImageContentRenderer.Data

View File

@ -23,7 +23,7 @@ import im.vector.app.R
@EpoxyModelClass
abstract class MessageLiveLocationInactiveItem :
AbsMessageItem<MessageLiveLocationInactiveItem.Holder>(R.layout.item_timeline_event_base),
AbsMessageItem<MessageLiveLocationInactiveItem.Holder>(),
LiveLocationShareStatusItem by DefaultLiveLocationShareStatusItem() {
@EpoxyAttribute

View File

@ -31,7 +31,7 @@ import im.vector.app.features.location.live.LocationLiveMessageBannerViewState
import org.threeten.bp.LocalDateTime
@EpoxyModelClass
abstract class MessageLiveLocationItem : AbsMessageLocationItem<MessageLiveLocationItem.Holder>(R.layout.item_timeline_event_base) {
abstract class MessageLiveLocationItem : AbsMessageLocationItem<MessageLiveLocationItem.Holder>() {
@EpoxyAttribute
var currentUserId: String? = null

View File

@ -23,7 +23,7 @@ import im.vector.app.R
@EpoxyModelClass
abstract class MessageLiveLocationStartItem :
AbsMessageItem<MessageLiveLocationStartItem.Holder>(R.layout.item_timeline_event_base),
AbsMessageItem<MessageLiveLocationStartItem.Holder>(),
LiveLocationShareStatusItem by DefaultLiveLocationShareStatusItem() {
@EpoxyAttribute

View File

@ -20,7 +20,7 @@ import com.airbnb.epoxy.EpoxyModelClass
import im.vector.app.R
@EpoxyModelClass
abstract class MessageLocationItem : AbsMessageLocationItem<MessageLocationItem.Holder>(R.layout.item_timeline_event_base) {
abstract class MessageLocationItem : AbsMessageLocationItem<MessageLocationItem.Holder>() {
override fun getViewStubId() = STUB_ID

View File

@ -38,7 +38,7 @@ import io.noties.markwon.MarkwonPlugin
import org.matrix.android.sdk.api.extensions.orFalse
@EpoxyModelClass
abstract class MessageTextItem : AbsMessageItem<MessageTextItem.Holder>(R.layout.item_timeline_event_base) {
abstract class MessageTextItem : AbsMessageItem<MessageTextItem.Holder>() {
@EpoxyAttribute
var searchForPills: Boolean = false

View File

@ -38,7 +38,7 @@ import im.vector.app.features.themes.ThemeUtils
import im.vector.app.features.voice.AudioWaveformView
@EpoxyModelClass
abstract class MessageVoiceItem : AbsMessageItem<MessageVoiceItem.Holder>(R.layout.item_timeline_event_base) {
abstract class MessageVoiceItem : AbsMessageItem<MessageVoiceItem.Holder>() {
interface WaveformTouchListener {
fun onWaveformTouchedUp(percentage: Float)

View File

@ -27,7 +27,7 @@ import im.vector.app.features.home.room.detail.timeline.TimelineEventController
import im.vector.lib.core.utils.epoxy.charsequence.EpoxyCharSequence
@EpoxyModelClass
abstract class PollItem : AbsMessageItem<PollItem.Holder>(R.layout.item_timeline_event_base) {
abstract class PollItem : AbsMessageItem<PollItem.Holder>() {
@EpoxyAttribute
var pollQuestion: EpoxyCharSequence? = null

View File

@ -20,7 +20,7 @@ import com.airbnb.epoxy.EpoxyModelClass
import im.vector.app.R
@EpoxyModelClass
abstract class RedactedMessageItem : AbsMessageItem<RedactedMessageItem.Holder>(R.layout.item_timeline_event_base) {
abstract class RedactedMessageItem : AbsMessageItem<RedactedMessageItem.Holder>() {
override fun getViewStubId() = STUB_ID