From 886cd253ec149b5f9109250f192073d340aab3ea Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Wed, 30 Mar 2022 17:07:24 +0200 Subject: [PATCH] [merge] Revert back to old section header Change-Id: Id7a4a9b31a02acbabff028d8d684e3d02dc1c1ec --- .../home/room/list/RoomCategoryItem.kt | 9 +-- .../home/room/list/SectionHeaderAdapter.kt | 15 +++-- .../main/res/layout/item_room_category_sc.xml | 65 +++++++++++++++++++ 3 files changed, 78 insertions(+), 11 deletions(-) create mode 100644 vector/src/main/res/layout/item_room_category_sc.xml diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomCategoryItem.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomCategoryItem.kt index feb4abc6b8..59e0108981 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomCategoryItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomCategoryItem.kt @@ -29,7 +29,7 @@ import im.vector.app.core.epoxy.VectorEpoxyModel import im.vector.app.core.epoxy.onClick import im.vector.app.features.themes.ThemeUtils -@EpoxyModelClass(layout = R.layout.item_room_category) +@EpoxyModelClass(layout = R.layout.item_room_category_sc) abstract class RoomCategoryItem : VectorEpoxyModel() { @EpoxyAttribute lateinit var title: String @@ -50,15 +50,16 @@ abstract class RoomCategoryItem : VectorEpoxyModel() { } holder.unreadCounterBadgeView.render(UnreadCounterBadgeView.State(unreadNotificationCount, showHighlighted, unreadMessages, markedUnread)) holder.titleView.text = title - holder.counterView.text = itemCount.takeIf { it > 0 }?.toString().orEmpty() - holder.counterView.setCompoundDrawablesWithIntrinsicBounds(null, null, expandedArrowDrawable, null) + //holder.counterView.text = itemCount.takeIf { it > 0 }?.toString().orEmpty() + //holder.counterView.setCompoundDrawablesWithIntrinsicBounds(null, null, expandedArrowDrawable, null) + holder.titleView.setCompoundDrawablesWithIntrinsicBounds(null, null, expandedArrowDrawable, null) holder.rootView.onClick(listener) } class Holder : VectorEpoxyHolder() { val unreadCounterBadgeView by bind(R.id.roomCategoryUnreadCounterBadgeView) val titleView by bind(R.id.roomCategoryTitleView) - val counterView by bind(R.id.roomCategoryCounterView) + //val counterView by bind(R.id.roomCategoryCounterView) val rootView by bind(R.id.roomCategoryRootView) } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/SectionHeaderAdapter.kt b/vector/src/main/java/im/vector/app/features/home/room/list/SectionHeaderAdapter.kt index 1b23d3db7e..c5466eb353 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/SectionHeaderAdapter.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/SectionHeaderAdapter.kt @@ -25,7 +25,7 @@ import androidx.recyclerview.widget.RecyclerView import im.vector.app.R import im.vector.app.core.epoxy.ClickListener import im.vector.app.core.epoxy.onClick -import im.vector.app.databinding.ItemRoomCategoryBinding +import im.vector.app.databinding.ItemRoomCategoryScBinding import im.vector.app.features.themes.ThemeUtils class SectionHeaderAdapter constructor( @@ -66,7 +66,7 @@ class SectionHeaderAdapter constructor( override fun getItemId(position: Int) = roomsSectionData.hashCode().toLong() - override fun getItemViewType(position: Int) = R.layout.item_room_category + override fun getItemViewType(position: Int) = R.layout.item_room_category_sc override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VH { return VH.create(parent, onClickAction) @@ -79,7 +79,7 @@ class SectionHeaderAdapter constructor( override fun getItemCount(): Int = if (roomsSectionData.isHidden) 0 else 1 class VH constructor( - private val binding: ItemRoomCategoryBinding, + private val binding: ItemRoomCategoryScBinding, onClickAction: ClickListener ) : RecyclerView.ViewHolder(binding.root) { @@ -99,16 +99,17 @@ class SectionHeaderAdapter constructor( null } binding.root.isClickable = roomsSectionData.isCollapsable - binding.roomCategoryCounterView.setCompoundDrawablesWithIntrinsicBounds(null, null, collapsableArrowDrawable, null) - binding.roomCategoryCounterView.text = roomsSectionData.itemCount.takeIf { it > 0 }?.toString().orEmpty() + binding.roomCategoryTitleView.setCompoundDrawablesWithIntrinsicBounds(null, null, collapsableArrowDrawable, null) + //binding.roomCategoryCounterView.setCompoundDrawablesWithIntrinsicBounds(null, null, collapsableArrowDrawable, null) + //binding.roomCategoryCounterView.text = roomsSectionData.itemCount.takeIf { it > 0 }?.toString().orEmpty() binding.roomCategoryUnreadCounterBadgeView.render(UnreadCounterBadgeView.State(roomsSectionData.notificationCount, roomsSectionData.isHighlighted, roomsSectionData.unread, roomsSectionData.markedUnread)) } companion object { fun create(parent: ViewGroup, onClickAction: ClickListener): VH { val view = LayoutInflater.from(parent.context) - .inflate(R.layout.item_room_category, parent, false) - val binding = ItemRoomCategoryBinding.bind(view) + .inflate(R.layout.item_room_category_sc, parent, false) + val binding = ItemRoomCategoryScBinding.bind(view) return VH(binding, onClickAction) } } diff --git a/vector/src/main/res/layout/item_room_category_sc.xml b/vector/src/main/res/layout/item_room_category_sc.xml new file mode 100644 index 0000000000..01c52662cf --- /dev/null +++ b/vector/src/main/res/layout/item_room_category_sc.xml @@ -0,0 +1,65 @@ + + + + + + + + + +