From 0942c6d64889af2fc7a23e341ba2ed8d3449c918 Mon Sep 17 00:00:00 2001 From: Maxime Naturel Date: Thu, 17 Feb 2022 17:22:18 +0100 Subject: [PATCH] Removing some with() code pattern --- .../home/room/list/RoomCategoryItem.kt | 6 ++---- .../home/room/list/SectionHeaderAdapter.kt | 18 ++++++++---------- 2 files changed, 10 insertions(+), 14 deletions(-) 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 6c872e0f99..6057072e41 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 @@ -48,10 +48,8 @@ abstract class RoomCategoryItem : VectorEpoxyModel() { } holder.unreadCounterBadgeView.render(UnreadCounterBadgeView.State(unreadNotificationCount, showHighlighted)) holder.titleView.text = title - with(holder.counterView) { - text = itemCount.takeIf { it > 0 }?.toString().orEmpty() - setCompoundDrawablesWithIntrinsicBounds(null, null, expandedArrowDrawable, null) - } + holder.counterView.text = itemCount.takeIf { it > 0 }?.toString().orEmpty() + holder.counterView.setCompoundDrawablesWithIntrinsicBounds(null, null, expandedArrowDrawable, null) holder.rootView.onClick(listener) } 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 b6a3777ded..2e6436d21d 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 @@ -80,17 +80,15 @@ class SectionHeaderAdapter constructor( } fun bind(roomsSectionData: RoomsSectionData) { - with(binding) { - roomCategoryTitleView.text = roomsSectionData.name - val tintColor = ThemeUtils.getColor(root.context, R.attr.vctr_content_secondary) - val expandedArrowDrawableRes = if (roomsSectionData.isExpanded) R.drawable.ic_expand_more else R.drawable.ic_expand_less - val expandedArrowDrawable = ContextCompat.getDrawable(root.context, expandedArrowDrawableRes)?.also { - DrawableCompat.setTint(it, tintColor) - } - roomCategoryCounterView.setCompoundDrawablesWithIntrinsicBounds(null, null, expandedArrowDrawable, null) - roomCategoryCounterView.text = roomsSectionData.itemCount.takeIf { it > 0 }?.toString().orEmpty() - roomCategoryUnreadCounterBadgeView.render(UnreadCounterBadgeView.State(roomsSectionData.notificationCount, roomsSectionData.isHighlighted)) + binding.roomCategoryTitleView.text = roomsSectionData.name + val tintColor = ThemeUtils.getColor(binding.root.context, R.attr.vctr_content_secondary) + val expandedArrowDrawableRes = if (roomsSectionData.isExpanded) R.drawable.ic_expand_more else R.drawable.ic_expand_less + val expandedArrowDrawable = ContextCompat.getDrawable(binding.root.context, expandedArrowDrawableRes)?.also { + DrawableCompat.setTint(it, tintColor) } + binding.roomCategoryCounterView.setCompoundDrawablesWithIntrinsicBounds(null, null, expandedArrowDrawable, null) + binding.roomCategoryCounterView.text = roomsSectionData.itemCount.takeIf { it > 0 }?.toString().orEmpty() + binding.roomCategoryUnreadCounterBadgeView.render(UnreadCounterBadgeView.State(roomsSectionData.notificationCount, roomsSectionData.isHighlighted)) } companion object {