Repository navigation
Conversation
52a1912 to
ba19eb9
Compare
|
@kikoso Please review this PR for adding clustering increamental item diff |
ba19eb9 to
fc84cf6
Compare
| clusterContentRotation: Float = 0.0f, | ||
| clusterItemContentRotation: Float = 0.0f, | ||
| clusterRenderer: ClusterRenderer<T>? = null, | ||
| key: ((T) -> Any)? = null, |
There was a problem hiding this comment.
Adding a parameter to an existing public function changes its JVM signature, so anything compiled against the previous version would break at runtime, even though source calls still compile thanks to the default value. Could we keep the old signatures as @Deprecated(level = DeprecationLevel.HIDDEN) overloads delegating to the new ones, or do I miss anything?
There was a problem hiding this comment.
Done. Added hidden deprecated overloads for all four previous JVM signatures.
| clusterContentRotation: Float = 0.0f, | ||
| clusterItemContentRotation: Float = 0.0f, | ||
| clusterItemDecoration: @Composable @GoogleMapComposable (T) -> Unit = {}, | ||
| key: ((T) -> Any)? = null, |
There was a problem hiding this comment.
nit: in the other overloads key goes before clusterItemDecoration, but here it comes after it. Should we keep the same order everywhere, for consistency?
There was a problem hiding this comment.
Done. key now comes before clusterItemDecoration in every overload.
| items.forEach { item -> | ||
| val itemKey = key?.invoke(item) ?: item | ||
| if (key != null) { | ||
| require(itemKey !in keyedItems) { |
There was a problem hiding this comment.
This will crash the app if the data contains a duplicated key, which can easily happen with backend data. Should we at least state in the KDoc of key that an IllegalArgumentException is thrown, or would it make sense to log and keep the last item instead? What do you think?
There was a problem hiding this comment.
Changed this to log a warning and keep the last item for duplicate keys. The behavior is documented in KDoc and covered by unit tests.
| return keyedItems | ||
| } | ||
|
|
||
| internal fun <T, K> diffClusterItems( |
There was a problem hiding this comment.
Since clusterItemsByKey and diffClusterItems are pure functions, could we add some plain JVM unit tests for them (empty lists, duplicate keys, unkeyed equality, add + remove + update in the same pass)? They would be much faster than the instrumented ones and cover more edge cases.
There was a problem hiding this comment.
Done. Added JVM unit tests for empty collections, duplicate keys, unkeyed equality, and add/remove/update in one pass.
| CustomUiClustering( | ||
| items = items, | ||
| ) | ||
| LaunchedEffect(clusteringType) { |
There was a problem hiding this comment.
Just a random idea: GoogleMapClustering is getting quite busy with the generator loop and the overlay. Would it make sense to move the keyed diff demo into its own composable (e.g. KeyedDiffClustering), like the other clustering types?
There was a problem hiding this comment.
Done. Moved the keyed diff demo and its update loop and overlay into KeyedDiffClustering.
| import androidx.compose.foundation.layout.Column | ||
| import androidx.compose.foundation.horizontalScroll | ||
| import androidx.compose.foundation.layout.Arrangement | ||
| import androidx.compose.foundation.layout.Box |
There was a problem hiding this comment.
nit: import ordering.
| import androidx.compose.foundation.layout.Column | |
| import androidx.compose.foundation.horizontalScroll | |
| import androidx.compose.foundation.layout.Arrangement | |
| import androidx.compose.foundation.layout.Box | |
| import androidx.compose.foundation.horizontalScroll | |
| import androidx.compose.foundation.layout.Arrangement | |
| import androidx.compose.foundation.layout.Box | |
| import androidx.compose.foundation.layout.Column |
Summary
Fixes #504
Validation
:maps-compose-utils:testDebugUnitTest:maps-app:connectedDebugAndroidTestforGoogleMapViewClusteringTests(6/6 passed on Motorola Edge 50 Neo):maps-compose-utils:lintDebug :maps-app:lintDebugManual verification