diff --git a/compose/snippets/src/androidTest/java/com/example/compose/snippets/semantics/SemanticsSnippets.kt b/compose/snippets/src/androidTest/java/com/example/compose/snippets/semantics/SemanticsSnippets.kt index 1b867edfa..89b577ea7 100644 --- a/compose/snippets/src/androidTest/java/com/example/compose/snippets/semantics/SemanticsSnippets.kt +++ b/compose/snippets/src/androidTest/java/com/example/compose/snippets/semantics/SemanticsSnippets.kt @@ -16,6 +16,7 @@ package com.example.compose.snippets.semantics +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.semantics.Role import androidx.compose.ui.semantics.SemanticsProperties diff --git a/compose/snippets/src/main/java/com/example/compose/snippets/animations/sharedelement/CustomizeSharedElementsSnippets.kt b/compose/snippets/src/main/java/com/example/compose/snippets/animations/sharedelement/CustomizeSharedElementsSnippets.kt index d599e1586..079c68347 100644 --- a/compose/snippets/src/main/java/com/example/compose/snippets/animations/sharedelement/CustomizeSharedElementsSnippets.kt +++ b/compose/snippets/src/main/java/com/example/compose/snippets/animations/sharedelement/CustomizeSharedElementsSnippets.kt @@ -659,7 +659,7 @@ fun CustomPredictiveBackHandle() { // For each backEvent that comes in, we manually seekTo the reported back progress try { seekableTransitionState.seekTo(backEvent.progress, targetState = Screen.Home) - } catch (e: CancellationException) { + } catch (_: CancellationException) { // seekTo may be cancelled as expected, if animateTo or subsequent seekTo calls // before the current seekTo finishes, in this case, we ignore the cancellation. } @@ -671,6 +671,7 @@ fun CustomPredictiveBackHandle() { // When the predictive back gesture is cancelled, we snap to the end state to ensure // it completes its seeking animation back to the currentState seekableTransitionState.snapTo(seekableTransitionState.currentState) + throw e } } val coroutineScope = rememberCoroutineScope() diff --git a/compose/snippets/src/main/java/com/example/compose/snippets/predictiveback/PredictiveBackSnippets.kt b/compose/snippets/src/main/java/com/example/compose/snippets/predictiveback/PredictiveBackSnippets.kt index fb94e1186..f9999f67c 100644 --- a/compose/snippets/src/main/java/com/example/compose/snippets/predictiveback/PredictiveBackSnippets.kt +++ b/compose/snippets/src/main/java/com/example/compose/snippets/predictiveback/PredictiveBackSnippets.kt @@ -37,6 +37,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.geometry.Offset import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.TransformOrigin +import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.input.pointer.util.VelocityTracker import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.unit.dp @@ -110,7 +111,10 @@ private fun PredictiveBackHandlerBasicExample() { Box( modifier = Modifier - .fillMaxSize(boxScale) + .graphicsLayer { + scaleX = boxScale + scaleY = scaleX + } .background(Color.Blue) ) @@ -127,6 +131,7 @@ private fun PredictiveBackHandlerBasicExample() { } catch (e: CancellationException) { // code for cancellation boxScale = 1F + throw e } } // [END android_compose_predictivebackhandler_basic] @@ -180,8 +185,10 @@ private fun PredictiveBackHandlerManualProgress() { closeDrawer(velocityTracker.calculateVelocity().x) } catch (e: CancellationException) { openDrawer(velocityTracker.calculateVelocity().x) + throw e + } finally { + velocityTracker.resetTracking() } - velocityTracker.resetTracking() } // [END android_compose_predictivebackhandler_manualprogress] }