@@ -29,6 +29,7 @@ import org.ole.planet.myplanet.model.RealmUserModel
2929import org.ole.planet.myplanet.repository.TeamRepository
3030import org.ole.planet.myplanet.ui.feedback.FeedbackFragment
3131import org.ole.planet.myplanet.ui.navigation.NavigationHelper
32+ import org.ole.planet.myplanet.utilities.DiffUtils
3233import org.ole.planet.myplanet.utilities.SharedPrefManager
3334import org.ole.planet.myplanet.utilities.TimeUtils
3435
@@ -251,7 +252,12 @@ class AdapterTeamList(
251252
252253 if (validTeams.isEmpty()) {
253254 val diffResult = withContext(Dispatchers .Default ) {
254- DiffUtil .calculateDiff(TeamDiffCallback (oldList, emptyList()))
255+ DiffUtils .calculateDiff(
256+ oldList,
257+ emptyList(),
258+ areItemsTheSame = { old, new -> old._id == new._id },
259+ areContentsTheSame = { old, new -> old == new }
260+ )
255261 }
256262 visitCounts = emptyMap()
257263 filteredList = emptyList()
@@ -334,7 +340,12 @@ class AdapterTeamList(
334340 }
335341
336342 val diffResult = withContext(Dispatchers .Default ) {
337- DiffUtil .calculateDiff(TeamDiffCallback (oldList, newList))
343+ DiffUtils .calculateDiff(
344+ oldList,
345+ newList,
346+ areItemsTheSame = { old, new -> old._id == new._id },
347+ areContentsTheSame = { old, new -> old == new }
348+ )
338349 }
339350
340351 visitCounts = allVisitCounts
@@ -344,20 +355,6 @@ class AdapterTeamList(
344355 }
345356 }
346357
347- private class TeamDiffCallback (
348- private val oldList : List <TeamData >, private val newList : List <TeamData >
349- ) : DiffUtil.Callback() {
350- override fun getOldListSize (): Int = oldList.size
351- override fun getNewListSize (): Int = newList.size
352- override fun areItemsTheSame (oldItemPosition : Int , newItemPosition : Int ): Boolean {
353- return oldList[oldItemPosition]._id == newList[newItemPosition]._id
354- }
355-
356- override fun areContentsTheSame (oldItemPosition : Int , newItemPosition : Int ): Boolean {
357- return oldList[oldItemPosition] == newList[newItemPosition]
358- }
359- }
360-
361358 private fun requestToJoin (team : RealmMyTeam , user : RealmUserModel ? ) {
362359 val teamId = team._id ? : return
363360 val teamType = team.teamType
0 commit comments