@@ -178,13 +178,13 @@ class ThreadAdapter(
178
178
}
179
179
}
180
180
181
- private fun SuperCollapsedBlockViewHolder.bindSuperCollapsedBlock (item : SuperCollapsedBlock ) {
182
- with (binding.superCollapsedBlock) {
183
- text = context.getString( R .string. superCollapsedBlock, item.messagesUids.count())
184
- setOnClickListener {
185
- text = context.getString( R .string.loadingText)
186
- threadAdapterCallbacks?.onSuperCollapsedBlockClicked?.invoke( )
187
- }
181
+ private fun SuperCollapsedBlockViewHolder.bindSuperCollapsedBlock (
182
+ item : SuperCollapsedBlock ,
183
+ ) = with (binding. superCollapsedBlock) {
184
+ text = context.getString( R .string.superCollapsedBlock, item.messagesUids.count())
185
+ setOnClickListener {
186
+ text = context.getString( R .string.loadingText )
187
+ threadAdapterCallbacks?.onSuperCollapsedBlockClicked?.invoke()
188
188
}
189
189
}
190
190
@@ -614,22 +614,27 @@ class ThreadAdapter(
614
614
class MessageDiffCallback : DiffUtil .ItemCallback <Any >() {
615
615
616
616
override fun areItemsTheSame (oldItem : Any , newItem : Any ): Boolean {
617
- return if (oldItem is Message ) {
618
- newItem is Message && newItem.uid == oldItem.uid
619
- } else {
620
- newItem is SuperCollapsedBlock
617
+ return when (oldItem) {
618
+ is Message -> newItem is Message && newItem.uid == oldItem.uid
619
+ is SuperCollapsedBlock -> newItem is SuperCollapsedBlock
620
+ else -> false
621
621
}
622
622
}
623
623
624
624
override fun areContentsTheSame (oldItem : Any , newItem : Any ): Boolean {
625
- return if (oldItem is Message ) {
626
- newItem is Message &&
627
- areMessageContentsTheSameExceptCalendar(oldItem, newItem) &&
628
- newItem.latestCalendarEventResponse == oldItem.latestCalendarEventResponse
629
- } else {
630
- newItem is SuperCollapsedBlock &&
631
- oldItem is SuperCollapsedBlock &&
632
- newItem.messagesUids.count() == oldItem.messagesUids.count()
625
+ return when (oldItem) {
626
+ is Message -> {
627
+ newItem is Message &&
628
+ areMessageContentsTheSameExceptCalendar(oldItem, newItem) &&
629
+ newItem.latestCalendarEventResponse == oldItem.latestCalendarEventResponse
630
+ }
631
+ is SuperCollapsedBlock -> {
632
+ newItem is SuperCollapsedBlock &&
633
+ newItem.messagesUids.count() == oldItem.messagesUids.count()
634
+ }
635
+ else -> {
636
+ false
637
+ }
633
638
}
634
639
}
635
640
0 commit comments