spierce7
02/02/2021, 11:06 PMAndroidView
composable to embed a native Android View into Jetpack Compose. However, I’d when a certain event happens on my model, I’d like to re-create the AndroidView
, removing the old, and replacing it with a newly created one. How would I go about doing that?jim
02/02/2021, 11:26 PMandroidx.compose.runtime.key
But I'm a bit suspicious of your framing "when an event occurs", as it tends to indicate that you are thinking in an imperative way instead of a declarative one. Instead, consider how your data model needs to be updated when the event occurs, and how that data model gets rendered to the screen. This might be "when a user clicks the 'new' button, I create a new empty contact card with a new UUID", and then the key around your AndroidView would be key(uuid)
. Without more details, I can't tell you what your key should be, but I can tell you that your question implies you're thinking about the problem imperatively.spierce7
02/02/2021, 11:55 PMBut I’m a bit suspicious of your framingGood call. I’m using exoplayer, and exoplayer seems to have a bug when updating playlists. Sometimes it gets stuck and doesn’t play, even after calling
play
. The best way to guarantee this doesn’t happen I’ve found is just to reload the screen. Another way, is just to re-create the Exoplayer View.jim
02/03/2021, 12:00 AMAdam Powell
02/03/2021, 12:31 AM