mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-15 01:35:07 +08:00
Makes sure bind and unbind are calling super in items
This commit is contained in:
parent
10d78a3102
commit
f762c4c7a2
@ -1,6 +1,9 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<option name="RIGHT_MARGIN" value="160" />
|
||||
<AndroidXmlCodeStyleSettings>
|
||||
<option name="ARRANGEMENT_SETTINGS_MIGRATED_TO_191" value="true" />
|
||||
</AndroidXmlCodeStyleSettings>
|
||||
<JetCodeStyleSettings>
|
||||
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
|
||||
<value>
|
||||
|
@ -29,6 +29,7 @@ abstract class DividerItem : VectorEpoxyModel<DividerItem.Holder>() {
|
||||
@EpoxyAttribute var color: Int = -1
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
if (color != -1) {
|
||||
holder.view.setBackgroundColor(color)
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ abstract class ErrorWithRetryItem : VectorEpoxyModel<ErrorWithRetryItem.Holder>(
|
||||
var listener: (() -> Unit)? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.textView.text = text
|
||||
holder.buttonView.isVisible = listener != null
|
||||
holder.buttonView.setOnClickListener { listener?.invoke() }
|
||||
|
@ -28,6 +28,7 @@ abstract class HelpFooterItem : VectorEpoxyModel<HelpFooterItem.Holder>() {
|
||||
var text: String? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.textView.text = text
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@ abstract class NoResultItem : VectorEpoxyModel<NoResultItem.Holder>() {
|
||||
var text: String? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.textView.text = text
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
package im.vector.riotx.core.epoxy
|
||||
|
||||
import androidx.annotation.CallSuper
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.LifecycleRegistry
|
||||
@ -38,11 +39,13 @@ abstract class VectorEpoxyModel<H : VectorEpoxyHolder> : EpoxyModelWithHolder<H>
|
||||
|
||||
private var onModelVisibilityStateChangedListener: OnVisibilityStateChangedListener? = null
|
||||
|
||||
@CallSuper
|
||||
override fun bind(holder: H) {
|
||||
super.bind(holder)
|
||||
lifecycleRegistry.currentState = Lifecycle.State.STARTED
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
override fun unbind(holder: H) {
|
||||
lifecycleRegistry.currentState = Lifecycle.State.DESTROYED
|
||||
coroutineScope.coroutineContext.cancelChildren()
|
||||
|
@ -58,6 +58,7 @@ abstract class BottomSheetActionItem : VectorEpoxyModel<BottomSheetActionItem.Ho
|
||||
lateinit var listener: View.OnClickListener
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.view.setOnClickListener {
|
||||
listener.onClick(it)
|
||||
}
|
||||
|
@ -49,6 +49,7 @@ abstract class BottomSheetMessagePreviewItem : VectorEpoxyModel<BottomSheetMessa
|
||||
var userClicked: (() -> Unit)? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
avatarRenderer.render(matrixItem, holder.avatar)
|
||||
holder.avatar.setOnClickListener { userClicked?.invoke() }
|
||||
holder.sender.setTextOrHide(matrixItem.displayName)
|
||||
|
@ -41,6 +41,7 @@ abstract class BottomSheetQuickReactionsItem : VectorEpoxyModel<BottomSheetQuick
|
||||
var listener: Listener? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.textViews.forEachIndexed { index, textView ->
|
||||
textView.typeface = fontProvider.typeface ?: Typeface.DEFAULT
|
||||
textView.text = texts[index]
|
||||
|
@ -49,6 +49,7 @@ abstract class BottomSheetRoomPreviewItem : VectorEpoxyModel<BottomSheetRoomPrev
|
||||
@EpoxyAttribute var favoriteClickListener: ClickListener? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
avatarRenderer.render(matrixItem, holder.avatar)
|
||||
holder.avatar.onClick(settingsClickListener)
|
||||
holder.roomName.setTextOrHide(matrixItem.displayName)
|
||||
|
@ -41,6 +41,7 @@ abstract class BottomSheetSendStateItem : VectorEpoxyModel<BottomSheetSendStateI
|
||||
var drawableStart: Int = 0
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.progress.isVisible = showProgress
|
||||
holder.text.setCompoundDrawablesWithIntrinsicBounds(drawableStart, 0, 0, 0)
|
||||
holder.text.text = text
|
||||
|
@ -40,6 +40,7 @@ abstract class ProfileMatrixItem : VectorEpoxyModel<ProfileMatrixItem.Holder>()
|
||||
@EpoxyAttribute var clickListener: View.OnClickListener? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
val bestName = matrixItem.getBestName()
|
||||
val matrixId = matrixItem.id.takeIf { it != bestName }
|
||||
holder.view.setOnClickListener(clickListener)
|
||||
|
@ -47,6 +47,7 @@ abstract class GenericButtonItem : VectorEpoxyModel<GenericButtonItem.Holder>()
|
||||
var iconRes: Int? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.button.text = text
|
||||
val textColor = textColor ?: ThemeUtils.getColor(holder.view.context, R.attr.riotx_text_primary)
|
||||
holder.button.setTextColor(textColor)
|
||||
|
@ -52,6 +52,7 @@ abstract class GenericFooterItem : VectorEpoxyModel<GenericFooterItem.Holder>()
|
||||
var textColor: Int? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.text.setTextOrHide(text)
|
||||
when (style) {
|
||||
GenericItem.STYLE.BIG_TEXT -> holder.text.textSize = 18f
|
||||
|
@ -74,6 +74,7 @@ abstract class GenericItem : VectorEpoxyModel<GenericItem.Holder>() {
|
||||
var itemClickAction: Action? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.titleText.setTextOrHide(title)
|
||||
|
||||
if (titleIconResourceId != -1) {
|
||||
|
@ -33,6 +33,7 @@ abstract class GenericItemHeader : VectorEpoxyModel<GenericItemHeader.Holder>()
|
||||
var text: String? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.text.setTextOrHide(text)
|
||||
}
|
||||
|
||||
|
@ -57,6 +57,7 @@ abstract class GenericItemWithValue : VectorEpoxyModel<GenericItemWithValue.Hold
|
||||
var itemClickAction: View.OnClickListener? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.titleText.setTextOrHide(title)
|
||||
|
||||
if (titleIconResourceId != -1) {
|
||||
|
@ -13,7 +13,9 @@ abstract class GenericLoaderItem : VectorEpoxyModel<GenericLoaderItem.Holder>()
|
||||
|
||||
// Maybe/Later add some style configuration, SMALL/BIG ?
|
||||
|
||||
override fun bind(holder: Holder) {}
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
}
|
||||
|
||||
class Holder : VectorEpoxyHolder()
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ abstract class AttachmentPreviewItem<H : AttachmentPreviewItem.Holder> : VectorE
|
||||
abstract val attachment: ContentAttachmentData
|
||||
|
||||
override fun bind(holder: H) {
|
||||
super.bind(holder)
|
||||
if (attachment.type == ContentAttachmentData.Type.VIDEO || attachment.type == ContentAttachmentData.Type.IMAGE) {
|
||||
Glide.with(holder.view.context)
|
||||
.asBitmap()
|
||||
|
@ -37,6 +37,7 @@ abstract class AutocompleteMatrixItem : VectorEpoxyModel<AutocompleteMatrixItem.
|
||||
@EpoxyAttribute var clickListener: View.OnClickListener? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.view.setOnClickListener(clickListener)
|
||||
holder.nameView.text = matrixItem.getBestName()
|
||||
holder.subNameView.setTextOrHide(subName)
|
||||
|
@ -37,6 +37,7 @@ abstract class AutocompleteCommandItem : VectorEpoxyModel<AutocompleteCommandIte
|
||||
var clickListener: View.OnClickListener? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.view.setOnClickListener(clickListener)
|
||||
|
||||
holder.nameView.text = name
|
||||
|
@ -40,6 +40,7 @@ abstract class AutocompleteEmojiItem : VectorEpoxyModel<AutocompleteEmojiItem.Ho
|
||||
var onClickListener: ReactionClickListener? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.emojiText.text = emojiItem.emoji
|
||||
holder.emojiText.typeface = emojiTypeFace ?: Typeface.DEFAULT
|
||||
holder.emojiNameText.text = emojiItem.name
|
||||
|
@ -42,6 +42,7 @@ abstract class KeysBackupSettingFooterItem : VectorEpoxyModel<KeysBackupSettingF
|
||||
var clickOnButton2: View.OnClickListener? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.button1.setTextOrHide(textButton1)
|
||||
holder.button1.setOnClickListener(clickOnButton1)
|
||||
|
||||
|
@ -51,6 +51,7 @@ abstract class BottomSheetVerificationActionItem : VectorEpoxyModel<BottomSheetV
|
||||
lateinit var listener: () -> Unit
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.view.setOnClickListener {
|
||||
listener.invoke()
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ abstract class BottomSheetVerificationBigImageItem : VectorEpoxyModel<BottomShee
|
||||
var contentDescription: String? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.image.setImageResource(imageRes)
|
||||
|
||||
if (contentDescription == null) {
|
||||
|
@ -33,6 +33,7 @@ abstract class BottomSheetVerificationDecimalCodeItem : VectorEpoxyModel<BottomS
|
||||
var code: CharSequence = ""
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.code.text = code
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,7 @@ abstract class BottomSheetVerificationEmojisItem : VectorEpoxyModel<BottomSheetV
|
||||
@EpoxyAttribute lateinit var emojiRepresentation6: EmojiRepresentation
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
bindEmojiView(holder.emoji0View, emojiRepresentation0)
|
||||
bindEmojiView(holder.emoji1View, emojiRepresentation1)
|
||||
bindEmojiView(holder.emoji2View, emojiRepresentation2)
|
||||
|
@ -33,6 +33,7 @@ abstract class BottomSheetVerificationNoticeItem : VectorEpoxyModel<BottomSheetV
|
||||
var notice: CharSequence = ""
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.notice.text = notice
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,7 @@ abstract class BottomSheetVerificationQrCodeItem : VectorEpoxyModel<BottomSheetV
|
||||
var animate = false
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.qsrCodeImage.setData(data, animate)
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,7 @@ abstract class BottomSheetVerificationWaitingItem : VectorEpoxyModel<BottomSheet
|
||||
var title: CharSequence = ""
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.title.text = title
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,7 @@ abstract class SettingsItem : EpoxyModelWithHolder<SettingsItem.Holder>() {
|
||||
var itemClickListener: View.OnClickListener? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
if (titleResId != null) {
|
||||
holder.titleText.setText(titleResId!!)
|
||||
} else {
|
||||
|
@ -48,6 +48,7 @@ abstract class FormEditTextItem : VectorEpoxyModel<FormEditTextItem.Holder>() {
|
||||
}
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.textInputLayout.isEnabled = enabled
|
||||
holder.textInputLayout.hint = hint
|
||||
|
||||
|
@ -44,6 +44,7 @@ abstract class FormSwitchItem : VectorEpoxyModel<FormSwitchItem.Holder>() {
|
||||
var summary: String? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.view.setOnClickListener {
|
||||
if (enabled) {
|
||||
holder.switchView.toggle()
|
||||
|
@ -36,6 +36,7 @@ abstract class DisplayReadReceiptItem : EpoxyModelWithHolder<DisplayReadReceiptI
|
||||
@EpoxyAttribute var userClicked: (() -> Unit)? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
avatarRenderer.render(matrixItem, holder.avatarView)
|
||||
holder.displayNameView.text = matrixItem.getBestName()
|
||||
timestamp?.let {
|
||||
|
@ -29,6 +29,7 @@ abstract class DaySeparatorItem : EpoxyModelWithHolder<DaySeparatorItem.Holder>(
|
||||
@EpoxyAttribute lateinit var formattedDay: CharSequence
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.dayTextView.text = formattedDay
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@ abstract class RoomCreateItem : VectorEpoxyModel<RoomCreateItem.Holder>() {
|
||||
@EpoxyAttribute lateinit var text: CharSequence
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.description.movementMethod = BetterLinkMovementMethod.getInstance()
|
||||
holder.description.text = text
|
||||
}
|
||||
|
@ -24,8 +24,6 @@ import im.vector.riotx.core.epoxy.VectorEpoxyModel
|
||||
@EpoxyModelClass(layout = R.layout.item_timeline_read_marker)
|
||||
abstract class TimelineReadMarkerItem : VectorEpoxyModel<TimelineReadMarkerItem.Holder>() {
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
}
|
||||
|
||||
class Holder : VectorEpoxyHolder()
|
||||
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ abstract class ReactionInfoSimpleItem : EpoxyModelWithHolder<ReactionInfoSimpleI
|
||||
var userClicked: (() -> Unit)? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.emojiReactionView.text = reactionKey
|
||||
holder.displayNameView.text = authorDisplayName
|
||||
timeStamp?.let {
|
||||
|
@ -33,6 +33,7 @@ abstract class RoomWidgetItem : EpoxyModelWithHolder<RoomWidgetItem.Holder>() {
|
||||
@EpoxyAttribute var widgetClicked: ClickListener? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.widgetName.text = widget.name
|
||||
holder.view.onClick(widgetClicked)
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ abstract class FilteredRoomFooterItem : VectorEpoxyModel<FilteredRoomFooterItem.
|
||||
var currentFilter: String = ""
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.createRoomButton.setOnClickListener { listener?.createRoom(currentFilter) }
|
||||
holder.createDirectChat.setOnClickListener { listener?.createDirectChat() }
|
||||
holder.openRoomDirectory.setOnClickListener { listener?.openRoomDirectory(currentFilter) }
|
||||
|
@ -37,6 +37,7 @@ abstract class RoomCategoryItem : VectorEpoxyModel<RoomCategoryItem.Holder>() {
|
||||
@EpoxyAttribute var listener: (() -> Unit)? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
val tintColor = ThemeUtils.getColor(holder.rootView.context, R.attr.riotx_text_secondary)
|
||||
val expandedArrowDrawableRes = if (expanded) R.drawable.ic_expand_more_white else R.drawable.ic_expand_less_white
|
||||
val expandedArrowDrawable = ContextCompat.getDrawable(holder.rootView.context, expandedArrowDrawableRes)?.also {
|
||||
|
@ -44,6 +44,7 @@ abstract class PolicyItem : EpoxyModelWithHolder<PolicyItem.Holder>() {
|
||||
var clickListener: View.OnClickListener? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.let {
|
||||
it.checkbox.isChecked = checked
|
||||
it.checkbox.setOnCheckedChangeListener(checkChangeListener)
|
||||
|
@ -57,6 +57,7 @@ abstract class PublicRoomItem : VectorEpoxyModel<PublicRoomItem.Holder>() {
|
||||
var joinListener: (() -> Unit)? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.rootView.setOnClickListener { globalListener?.invoke() }
|
||||
|
||||
avatarRenderer.render(matrixItem, holder.avatarView)
|
||||
|
@ -46,6 +46,7 @@ abstract class RoomDirectoryItem : VectorEpoxyModel<RoomDirectoryItem.Holder>()
|
||||
var globalListener: (() -> Unit)? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.rootView.setOnClickListener { globalListener?.invoke() }
|
||||
|
||||
// Avatar
|
||||
|
@ -73,6 +73,7 @@ abstract class DeviceItem : VectorEpoxyModel<DeviceItem.Holder>() {
|
||||
var dimensionConverter: DimensionConverter? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.root.setOnClickListener { itemClickAction?.invoke() }
|
||||
|
||||
val shield = TrustUtils.shieldForTrust(
|
||||
|
@ -43,6 +43,7 @@ abstract class UserItem : VectorEpoxyModel<UserItem.Holder>() {
|
||||
var itemClickAction: (() -> Unit)? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.root.setOnClickListener { itemClickAction?.invoke() }
|
||||
|
||||
avatarRenderer.render(matrixItem, holder.avatarImage)
|
||||
|
@ -31,6 +31,7 @@ abstract class PushGatewayItem : EpoxyModelWithHolder<PushGatewayItem.Holder>()
|
||||
lateinit var pusher: Pusher
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.kind.text = when (pusher.kind) {
|
||||
// TODO Create const
|
||||
"http" -> "Http Pusher"
|
||||
|
@ -41,6 +41,7 @@ abstract class PushRuleItem : EpoxyModelWithHolder<PushRuleItem.Holder>() {
|
||||
// TODO i18n
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
val context = holder.view.context
|
||||
if (pushRule.enabled) {
|
||||
holder.view.setBackgroundColor(Color.TRANSPARENT)
|
||||
|
@ -34,6 +34,7 @@ abstract class LoginErrorWithRetryItem : VectorEpoxyModel<LoginErrorWithRetryIte
|
||||
var listener: (() -> Unit)? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.textView.text = text
|
||||
holder.buttonView.setOnClickListener { listener?.invoke() }
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ abstract class TermItem : EpoxyModelWithHolder<TermItem.Holder>() {
|
||||
var clickListener: View.OnClickListener? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.checkbox.isChecked = checked
|
||||
holder.title.text = name
|
||||
holder.description.text = description
|
||||
|
@ -29,6 +29,7 @@ abstract class UserDirectoryLetterHeaderItem : VectorEpoxyModel<UserDirectoryLet
|
||||
@EpoxyAttribute var letter: String = ""
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.letterView.text = letter
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ abstract class UserDirectoryUserItem : VectorEpoxyModel<UserDirectoryUserItem.Ho
|
||||
@EpoxyAttribute var selected: Boolean = false
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.view.setOnClickListener(clickListener)
|
||||
// If name is empty, use userId as name and force it being centered
|
||||
if (matrixItem.displayName.isNullOrEmpty()) {
|
||||
|
Loading…
Reference in New Issue
Block a user