@@ -24,7 +24,6 @@ import androidx.compose.runtime.mutableStateListOf
24
24
import androidx.compose.runtime.mutableStateOf
25
25
import androidx.compose.runtime.setValue
26
26
import androidx.lifecycle.AndroidViewModel
27
- import androidx.lifecycle.MutableLiveData
28
27
import androidx.lifecycle.ViewModel
29
28
import androidx.lifecycle.ViewModelProvider
30
29
import androidx.media3.common.Effect
@@ -79,7 +78,7 @@ class CompositionPreviewViewModel(application: Application, val compositionLayou
79
78
var applyEffects : MutableState <Boolean >,
80
79
)
81
80
82
- var toastMessage = MutableLiveData <String ?>(null )
81
+ var snackbarMessage by mutableStateOf <String ?>(null )
83
82
84
83
var compositionPlayer by mutableStateOf(createCompositionPlayer())
85
84
@@ -143,7 +142,7 @@ class CompositionPreviewViewModel(application: Application, val compositionLayou
143
142
144
143
fun addItem (index : Int ) {
145
144
selectedMediaItems.add(mediaItemOptions[index].copy(applyEffects = mutableStateOf(false )))
146
- toastMessage.value = " Added item: ${mediaItemOptions[index].title} "
145
+ snackbarMessage = " Added item: ${mediaItemOptions[index].title} "
147
146
}
148
147
149
148
fun removeItem (index : Int ) {
@@ -173,7 +172,7 @@ class CompositionPreviewViewModel(application: Application, val compositionLayou
173
172
outputFile =
174
173
createExternalCacheFile(" composition-preview-" + Clock .DEFAULT .elapsedRealtime() + " .mp4" )
175
174
} catch (e: IOException ) {
176
- toastMessage.value = " Aborting export! Unable to create output file: $e "
175
+ snackbarMessage = " Aborting export! Unable to create output file: $e "
177
176
Log .e(TAG , " Aborting export! Unable to create output file: " , e)
178
177
return
179
178
}
@@ -234,7 +233,7 @@ class CompositionPreviewViewModel(application: Application, val compositionLayou
234
233
exportException : ExportException ,
235
234
) {
236
235
exportStopwatch.stop()
237
- toastMessage.value = " Export error: $exportException "
236
+ snackbarMessage = " Export error: $exportException "
238
237
Log .e(TAG , " Export error" , exportException)
239
238
Log .d(TAG , DebugTraceUtil .generateTraceSummary())
240
239
exportResultInformation = EXPORT_ERROR_MESSAGE
@@ -410,7 +409,7 @@ class CompositionPreviewViewModel(application: Application, val compositionLayou
410
409
player.addListener(
411
410
object : Player .Listener {
412
411
override fun onPlayerError (error : PlaybackException ) {
413
- toastMessage.value = " Preview error: $error "
412
+ snackbarMessage = " Preview error: $error "
414
413
Log .e(TAG , " Preview error" , error)
415
414
}
416
415
}
0 commit comments