Cleans up epoxy class for NewSpaceSummaryItem and adds ellipsize to header

This commit is contained in:
ericdecanini 2022-08-05 16:08:05 +02:00
parent 0567fa3e53
commit e6508e8a5a
4 changed files with 10 additions and 24 deletions

View file

@ -108,8 +108,6 @@ class NewSpaceSummaryController @Inject constructor(
id(subSpaceSummary.roomId)
matrixItem(subSpaceSummary.toMatrixItem())
selected(false)
canDrag(true)
onMore { host.callback?.onSpaceSettings(subSpaceSummary) }
listener { host.callback?.onSpaceSelected(subSpaceSummary) }
countState(
UnreadCounterBadgeView.State(
@ -135,8 +133,6 @@ class NewSpaceSummaryController @Inject constructor(
avatarRenderer(host.avatarRenderer)
id(roomSummary.roomId)
matrixItem(roomSummary.toMatrixItem())
canDrag(true)
onMore { host.callback?.onSpaceSettings(roomSummary) }
listener { host.callback?.onSpaceSelected(roomSummary) }
countState(UnreadCounterBadgeView.State(roomSummary.notificationCount, roomSummary.highlightCount > 0))
}

View file

@ -37,35 +37,27 @@ abstract class NewSpaceSummaryItem : VectorEpoxyModel<NewSpaceSummaryItem.Holder
@EpoxyAttribute lateinit var matrixItem: MatrixItem
@EpoxyAttribute var selected: Boolean = false
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var listener: ClickListener? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var onMore: ClickListener? = null
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var toggleExpand: ClickListener? = null
@EpoxyAttribute var expanded: Boolean = false
@EpoxyAttribute var hasChildren: Boolean = false
@EpoxyAttribute var indent: Int = 0
@EpoxyAttribute var countState: UnreadCounterBadgeView.State = UnreadCounterBadgeView.State(0, false)
@EpoxyAttribute var description: String? = null
@EpoxyAttribute var showSeparator: Boolean = false
@EpoxyAttribute var canDrag: Boolean = true
override fun bind(holder: Holder) {
super.bind(holder)
holder.rootView.onClick(listener)
holder.groupNameView.text = matrixItem.displayName
holder.name.text = matrixItem.displayName
holder.rootView.isChecked = selected
avatarRenderer.render(matrixItem, holder.avatarImageView)
holder.counterBadgeView.render(countState)
avatarRenderer.render(matrixItem, holder.avatar)
holder.unreadCounter.render(countState)
}
override fun unbind(holder: Holder) {
avatarRenderer.clear(holder.avatarImageView)
avatarRenderer.clear(holder.avatar)
super.unbind(holder)
}
class Holder : VectorEpoxyHolder() {
val rootView by bind<CheckableConstraintLayout>(R.id.root)
val avatarImageView by bind<ImageView>(R.id.avatar)
val groupNameView by bind<TextView>(R.id.name)
val counterBadgeView by bind<UnreadCounterBadgeView>(R.id.unread_counter)
val avatar by bind<ImageView>(R.id.avatar)
val name by bind<TextView>(R.id.name)
val unreadCounter by bind<UnreadCounterBadgeView>(R.id.unread_counter)
}
}

View file

@ -96,7 +96,7 @@ class SpaceListFragment @Inject constructor(
toPositionM = null
fromPositionM = null
model?.matrixItem?.id?.let {
viewModel.handle(SpaceListAction.OnStartDragging(it, model.expanded))
viewModel.handle(SpaceListAction.OnStartDragging(it, false))
}
itemView?.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
initialElevation = itemView?.elevation
@ -122,10 +122,6 @@ class SpaceListFragment @Inject constructor(
itemView?.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
}
}
override fun isDragEnabledForModel(model: NewSpaceSummaryItem?): Boolean {
return model?.canDrag == true
}
})
}

View file

@ -5,8 +5,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_space_item"
android:ellipsize="middle"
android:orientation="vertical"
android:padding="16dp"
android:singleLine="true"
android:text="@string/change_space"
android:textAllCaps="true"
android:textColor="?vctr_content_tertiary"