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) id(subSpaceSummary.roomId)
matrixItem(subSpaceSummary.toMatrixItem()) matrixItem(subSpaceSummary.toMatrixItem())
selected(false) selected(false)
canDrag(true)
onMore { host.callback?.onSpaceSettings(subSpaceSummary) }
listener { host.callback?.onSpaceSelected(subSpaceSummary) } listener { host.callback?.onSpaceSelected(subSpaceSummary) }
countState( countState(
UnreadCounterBadgeView.State( UnreadCounterBadgeView.State(
@ -135,8 +133,6 @@ class NewSpaceSummaryController @Inject constructor(
avatarRenderer(host.avatarRenderer) avatarRenderer(host.avatarRenderer)
id(roomSummary.roomId) id(roomSummary.roomId)
matrixItem(roomSummary.toMatrixItem()) matrixItem(roomSummary.toMatrixItem())
canDrag(true)
onMore { host.callback?.onSpaceSettings(roomSummary) }
listener { host.callback?.onSpaceSelected(roomSummary) } listener { host.callback?.onSpaceSelected(roomSummary) }
countState(UnreadCounterBadgeView.State(roomSummary.notificationCount, roomSummary.highlightCount > 0)) 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 lateinit var matrixItem: MatrixItem
@EpoxyAttribute var selected: Boolean = false @EpoxyAttribute var selected: Boolean = false
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var listener: ClickListener? = null @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 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) { override fun bind(holder: Holder) {
super.bind(holder) super.bind(holder)
holder.rootView.onClick(listener) holder.rootView.onClick(listener)
holder.groupNameView.text = matrixItem.displayName holder.name.text = matrixItem.displayName
holder.rootView.isChecked = selected holder.rootView.isChecked = selected
avatarRenderer.render(matrixItem, holder.avatarImageView) avatarRenderer.render(matrixItem, holder.avatar)
holder.counterBadgeView.render(countState) holder.unreadCounter.render(countState)
} }
override fun unbind(holder: Holder) { override fun unbind(holder: Holder) {
avatarRenderer.clear(holder.avatarImageView) avatarRenderer.clear(holder.avatar)
super.unbind(holder) super.unbind(holder)
} }
class Holder : VectorEpoxyHolder() { class Holder : VectorEpoxyHolder() {
val rootView by bind<CheckableConstraintLayout>(R.id.root) val rootView by bind<CheckableConstraintLayout>(R.id.root)
val avatarImageView by bind<ImageView>(R.id.avatar) val avatar by bind<ImageView>(R.id.avatar)
val groupNameView by bind<TextView>(R.id.name) val name by bind<TextView>(R.id.name)
val counterBadgeView by bind<UnreadCounterBadgeView>(R.id.unread_counter) val unreadCounter by bind<UnreadCounterBadgeView>(R.id.unread_counter)
} }
} }

View File

@ -96,7 +96,7 @@ class SpaceListFragment @Inject constructor(
toPositionM = null toPositionM = null
fromPositionM = null fromPositionM = null
model?.matrixItem?.id?.let { model?.matrixItem?.id?.let {
viewModel.handle(SpaceListAction.OnStartDragging(it, model.expanded)) viewModel.handle(SpaceListAction.OnStartDragging(it, false))
} }
itemView?.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS) itemView?.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
initialElevation = itemView?.elevation initialElevation = itemView?.elevation
@ -122,10 +122,6 @@ class SpaceListFragment @Inject constructor(
itemView?.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS) 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_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/bg_space_item" android:background="@drawable/bg_space_item"
android:ellipsize="middle"
android:orientation="vertical" android:orientation="vertical"
android:padding="16dp" android:padding="16dp"
android:singleLine="true"
android:text="@string/change_space" android:text="@string/change_space"
android:textAllCaps="true" android:textAllCaps="true"
android:textColor="?vctr_content_tertiary" android:textColor="?vctr_content_tertiary"