File tree Expand file tree Collapse file tree 3 files changed +23
-7
lines changed
src/main/java/org/ole/planet/myplanet Expand file tree Collapse file tree 3 files changed +23
-7
lines changed Original file line number Diff line number Diff line change @@ -9,8 +9,8 @@ android {
99 applicationId " org.ole.planet.myplanet"
1010 minSdk = 26
1111 targetSdk = 36
12- versionCode = 3709
13- versionName = " 0.37.9 "
12+ versionCode = 3710
13+ versionName = " 0.37.10 "
1414 ndkVersion = ' 26.3.11579264'
1515 testInstrumentationRunner " androidx.test.runner.AndroidJUnitRunner"
1616 vectorDrawables. useSupportLibrary = true
Original file line number Diff line number Diff line change @@ -309,10 +309,22 @@ class AdapterResource(
309309 areItemsTheSame = { old, new -> old?.id == new?.id },
310310 areContentsTheSame = { old, new ->
311311 old?.title == new?.title &&
312- old?.description == new?.description &&
313- old?.createdDate == new?.createdDate &&
314- old?.averageRating == new?.averageRating &&
315- old?.timesRated == new?.timesRated
312+ old?.description == new?.description &&
313+ old?.createdDate == new?.createdDate &&
314+ old?.averageRating == new?.averageRating &&
315+ old?.timesRated == new?.timesRated
316+ },
317+ getChangePayload = { old, new ->
318+ val ratingChanged = old?.averageRating != new?.averageRating || old?.timesRated != new?.timesRated
319+ val otherContentChanged = old?.title != new?.title ||
320+ old?.description != new?.description ||
321+ old?.createdDate != new?.createdDate
322+
323+ if (ratingChanged && ! otherContentChanged) {
324+ RATING_PAYLOAD
325+ } else {
326+ null
327+ }
316328 }
317329 )
318330 libraryList = newList
Original file line number Diff line number Diff line change @@ -17,7 +17,8 @@ object DiffUtils {
1717 oldList : List <T >,
1818 newList : List <T >,
1919 areItemsTheSame : (oldItem: T , newItem: T ) -> Boolean ,
20- areContentsTheSame : (oldItem: T , newItem: T ) -> Boolean
20+ areContentsTheSame : (oldItem: T , newItem: T ) -> Boolean ,
21+ getChangePayload : ((oldItem: T , newItem: T ) -> Any? )? = null
2122 ): RecyclerDiffUtil .DiffResult {
2223 val callback = object : RecyclerDiffUtil .Callback () {
2324 override fun getOldListSize () = oldList.size
@@ -26,6 +27,9 @@ object DiffUtils {
2627 areItemsTheSame(oldList[oldItemPosition], newList[newItemPosition])
2728 override fun areContentsTheSame (oldItemPosition : Int , newItemPosition : Int ) =
2829 areContentsTheSame(oldList[oldItemPosition], newList[newItemPosition])
30+ override fun getChangePayload (oldItemPosition : Int , newItemPosition : Int ): Any? {
31+ return getChangePayload?.invoke(oldList[oldItemPosition], newList[newItemPosition])
32+ }
2933 }
3034 return RecyclerDiffUtil .calculateDiff(callback)
3135 }
You can’t perform that action at this time.
0 commit comments