You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Render GlanceAppWidgetHostPreview on the page element of Pager, nothing appears on the page it was hidden.
However, when I manually click on the element, it seems to reappear when the updateContent() specified for clickable is called.
To Reproduce
use GlanceAppWidgetHostPreview in HorizontalPager's page content
From the above event, I know that could display it by manually calling updateContent().
So I delayed updateContent() by 100 millis when it was mounted, and the element was always displayed before and after paging.
As a workaround I use runBlocking instead of LaunchedEffect.
Adding the following to AppWidgetHost also worked, but probably this isn't the right fix and the issue is rather related to how lazy composables and AndroidView interact.
update = { hostView ->
if (hostView != state.value) {
if (state.providerInfo != null) {
hostView.setAppWidget(index, state.providerInfo)
hostView.setPadding(0, 0, 0, 0)
} else {
// When no provider is provided, use a fake provider workaround to init the host
hostView.setFakeAppWidget()
}
}
+ state.snapshot?.let {+ hostView.updateAppWidget(it)+ }
state. Value = hostView
}
Describe the bug
Render
GlanceAppWidgetHostPreview
on the page element of Pager, nothing appears on the page it was hidden.However, when I manually click on the element, it seems to reappear when the
updateContent()
specified for clickable is called.To Reproduce
use
GlanceAppWidgetHostPreview
in HorizontalPager's page contentscreen-20221010-185355_2.mp4
Expected behavior
From the above event, I know that could display it by manually calling
updateContent()
.So I delayed
updateContent()
by 100 millis when it was mounted, and the element was always displayed before and after paging.glance-experimental-tools/GlanceAppWidgetHostPreview.kt at b903edb88c898ca36c4a1b5099c2ebebd32ec6c9 · google/glance-experimental-tools
if (hostState.isReady) { LaunchedEffect(hostState.value) { + delay(100) updateContent() } }
screen-20221010-185448_2.mp4
Environment:
The text was updated successfully, but these errors were encountered: