File tree Expand file tree Collapse file tree 4 files changed +21
-10
lines changed
app/src/main/java/com/android/developers/androidify/navigation
camera/src/main/java/com/android/developers/androidify/camera
creation/src/main/java/com/android/developers/androidify/creation Expand file tree Collapse file tree 4 files changed +21
-10
lines changed Original file line number Diff line number Diff line change @@ -89,7 +89,6 @@ fun MainNavigation() {
89
89
fadeIn(motionScheme.defaultEffectsSpec()),
90
90
scaleOut(
91
91
targetScale = 0.7f ,
92
- transformOrigin = TransformOrigin (pivotFractionX = 0.5f , pivotFractionY = 0.5f ),
93
92
),
94
93
)
95
94
},
@@ -108,14 +107,17 @@ fun MainNavigation() {
108
107
entry<Camera > {
109
108
CameraPreviewScreen (
110
109
onImageCaptured = { uri ->
110
+ backStack.removeAll { it is Create }
111
111
backStack.add(Create (uri.toString()))
112
+ backStack.removeAll { it is Camera }
112
113
},
113
114
)
114
115
}
115
116
entry<Create > { createKey ->
116
117
CreationScreen (
117
118
createKey.fileName,
118
119
onCameraPressed = {
120
+ backStack.removeAll { it is Camera }
119
121
backStack.add(Camera )
120
122
},
121
123
onBackPressed = {
@@ -142,7 +144,7 @@ fun MainNavigation() {
142
144
showSplash = false
143
145
},
144
146
onTransitionMidpoint = {
145
- backStack.add(Create ())
147
+ backStack.add(Create (fileName = null ))
146
148
},
147
149
)
148
150
}
Original file line number Diff line number Diff line change @@ -137,6 +137,7 @@ fun CameraPreviewScreen(
137
137
// so CameraX can retrieve the new Surface.
138
138
LaunchedEffect (surface) {
139
139
val oldIsTableTop = isTableTopPosture(foldingFeature)
140
+
140
141
snapshotFlow { foldingFeature }
141
142
.takeWhile {
142
143
val newIsTableTop = isTableTopPosture(it)
Original file line number Diff line number Diff line change @@ -169,6 +169,7 @@ fun CreationScreen(
169
169
}
170
170
LaunchedEffect (Unit ) {
171
171
if (fileName != null ) creationViewModel.onImageSelected(fileName.toUri())
172
+ else creationViewModel.onImageSelected(null )
172
173
}
173
174
val pickMedia = rememberLauncherForActivityResult(PickVisualMedia ()) { uri ->
174
175
if (uri != null ) {
Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ class CreationViewModel @Inject constructor(
89
89
val snackbarHostState: StateFlow <SnackbarHostState >
90
90
get() = _snackbarHostState
91
91
92
- fun onImageSelected (uri : Uri ) {
92
+ fun onImageSelected (uri : Uri ? ) {
93
93
_uiState .update {
94
94
it.copy(
95
95
imageUri = uri,
@@ -116,14 +116,21 @@ class CreationViewModel @Inject constructor(
116
116
_uiState .update {
117
117
it.copy(promptGenerationInProgress = true )
118
118
}
119
- val prompt = textGenerationRepository.getNextGeneratedBotPrompt()
120
- Log .d(" CreationViewModel" , " Prompt: $prompt " )
121
- if (prompt != null ) {
119
+ try {
120
+ val prompt = textGenerationRepository.getNextGeneratedBotPrompt()
121
+ Log .d(" CreationViewModel" , " Prompt: $prompt " )
122
+ if (prompt != null ) {
123
+ _uiState .update {
124
+ it.copy(
125
+ generatedPrompt = prompt,
126
+ promptGenerationInProgress = false ,
127
+ )
128
+ }
129
+ }
130
+ } catch (exception: Exception ) {
131
+ Log .e(" CreationViewModel" , " Error generating prompt" , exception)
122
132
_uiState .update {
123
- it.copy(
124
- generatedPrompt = prompt,
125
- promptGenerationInProgress = false ,
126
- )
133
+ it.copy(promptGenerationInProgress = false )
127
134
}
128
135
}
129
136
}
You can’t perform that action at this time.
0 commit comments