Skip to content

Commit 2e5e361

Browse files
Format code
1 parent 7369169 commit 2e5e361

File tree

1 file changed

+24
-19
lines changed

1 file changed

+24
-19
lines changed

app/src/main/java/com/infomaniak/mail/ui/main/thread/ThreadAdapter.kt

+24-19
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,13 @@ class ThreadAdapter(
178178
}
179179
}
180180

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()
188188
}
189189
}
190190

@@ -614,22 +614,27 @@ class ThreadAdapter(
614614
class MessageDiffCallback : DiffUtil.ItemCallback<Any>() {
615615

616616
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
621621
}
622622
}
623623

624624
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+
}
633638
}
634639
}
635640

0 commit comments

Comments
 (0)