Wear OS Tiles:如何动态更新 UI
因此,我正在努力构建媒体图块,但每当我播放下一首歌曲并使用 getUpdater(applicationContext).requestUpdate(MyTileService::class.java)
刷新图块需要几秒钟的时间,因此下一首歌曲开始,但是图块的内容不会改变。我尝试在磁贴刷新代码中传递新歌曲标题,但磁贴在变量刷新之前刷新。
when(request.state!!.lastClickableId) {
"play" -> pauseLayout(songTitle_txt!!,request.deviceParameters!!)
"pause" -> playLayout(songTitle_txt!!,request.deviceParameters!!)
else ->pauseLayout(songTitle_txt!!,request.deviceParameters!!)
}
我还试图弄清楚如何使用歌曲进度更新 ARC,我可以将其存档到实际的 Wear OS 应用程序中,但在涉及图块时感到困惑。是否可以获取对图块元素的引用并仅更新这些元素?
So I am working to build media tile, but whenever I play the a next song and use getUpdater(applicationContext).requestUpdate(MyTileService::class.java)
it take few seconds before it refreshes the tile, so the next song starts but, the content of the tile do not change. I tries passing the new song title in the tile refresh code, but the tile refreshes before the variable refresh.
when(request.state!!.lastClickableId) {
"play" -> pauseLayout(songTitle_txt!!,request.deviceParameters!!)
"pause" -> playLayout(songTitle_txt!!,request.deviceParameters!!)
else ->pauseLayout(songTitle_txt!!,request.deviceParameters!!)
}
I am also trying to figure how to update the ARC using the song progress, I can archived it the actual Wear OS app, but confused when it comes to tiles. Can one get a reference to the tile elements and only update those ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为 onclick 操作可能会有所不同,但如果外部事件(播放时间、更改后的歌曲名称)是触发器,您的更新频率将受到限制。
请参阅https://stackoverflow.com/a/70565444/1542667
I think onclick actions might be different, but if an external event (play time, song name after it changes) is the trigger you will be limited in how often you can update.
See https://stackoverflow.com/a/70565444/1542667