https://kotlinlang.org logo
b

bohregard

07/06/2020, 9:17 PM
So when using AndroidView in the latest release, is there a way to get the view to “update”? Say for instance I’m using a custom AndroidView from a library that has buttons, changing text, whatever, compose will never recompose those views. They just have the last state (or sometimes the initial state) when it was drawn last. A good example is ExoPlayer’s PlayerView (which has the built in PlayerController which is never updated with information about the currently playing video. (The surface view works great though).
j

John O'Reilly

07/06/2020, 9:43 PM
you can pass
postInflationCallback
lambda to
AndroidView
which gets passed view which you can potentially use to do update. Doing something similar right now for
AndroidView
that wraps a
SupportMapFragment
(though still have a few things still to figure out as well)
b

bohregard

07/06/2020, 9:44 PM
Hmm, it seems postInflationCallback is only available when using a resource id. I’m using a standalone view. That might work for the initial update, but any ideas on updates that happen on the view afterwords?
a

Adam Powell

07/06/2020, 9:46 PM
our medium-term intention here is to have the configuration block observe snapshot updates and re-run when needed like the rest of compose
I think that's not hooked up just yet
b

bohregard

07/06/2020, 9:58 PM
Ohhhh ok. That sounds interesting. Any ideas when that might land?
a

Adam Powell

07/06/2020, 11:30 PM
Not sure. Some of the work that landed in the last couple of weeks around
emit
vs. the old special syntax for it is likely to impact how it ends up working
m

Madhava

07/07/2020, 4:15 AM
In a similar vein, im trying to add android:windowSoftInputMode adjustResize to AndroidView holding a WebView because when the keyboard is visible the webview doesnt scroll up or resize, is there a way to currently achieve this with AndroidView?
b

bohregard

07/08/2020, 5:18 PM
I think this might be related to this: https://issuetracker.google.com/issues/159838005 @Madhava
m

Madhava

07/08/2020, 10:18 PM
Maybe. Mine works fine, I can type into input boxes and scroll etc, albeit a little laggy, but im just wondering how would i do the normal android "hide keyboard" on webview pattern if its an xml attribute. Should I create an XML view in actual xml first and then load that rather than just programatically instantiating a WebView like the above link?