Fix hasAnimations returning false for some composables
We were missing a "notNull" check when filtering slot trees that match the
Composable being previewed. As a result, for some cases we were trying to
find transitions in an empty list instead of a list containing only the
aforementioned Composable. Therefore, Android Studio would think that some
composables containing transition animations didn't have any.
Bug: 163469060
Test: Tests on the Android Studio side using a DevRel project
Change-Id: Ia111894d7b767bb265fc37fa7f0f302212b51535
diff --git a/ui/ui-tooling/src/main/java/androidx/ui/tooling/preview/ComposeViewAdapter.kt b/ui/ui-tooling/src/main/java/androidx/ui/tooling/preview/ComposeViewAdapter.kt
index 751f3ea..0976e84 100644
--- a/ui/ui-tooling/src/main/java/androidx/ui/tooling/preview/ComposeViewAdapter.kt
+++ b/ui/ui-tooling/src/main/java/androidx/ui/tooling/preview/ComposeViewAdapter.kt
@@ -223,7 +223,7 @@
@VisibleForTesting
internal fun findAndSubscribeTransitions() {
val slotTrees = slotTableRecord.store.map { it.asTree() }
- slotTrees.map { tree -> tree.firstOrNull { it.name == composableName } }
+ slotTrees.mapNotNull { tree -> tree.firstOrNull { it.name == composableName } }
.firstOrNull()?.let { composable ->
// Find all the AnimationClockObservers corresponding to transition animations
val observers = composable.findAll {