Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

生成的用户头像不能针对每条弹幕单独定制吗?怎么都是整体设置的 #25

Closed
HpBoss opened this issue Jun 15, 2022 · 2 comments

Comments

@HpBoss
Copy link

HpBoss commented Jun 15, 2022

private val renderer by lazy {
TypedDanmakuRenderer(
simpleRenderer,
DanmakuItemData.DANMAKU_STYLE_USER_AVATAR to UpLogoRenderer(
ResourcesCompat.getDrawable(resources, R.drawable.icon_danmaku_input_text_up_icon, theme)!!
)
)
}
相当于这个DanmaPlayer都得用这个user_avatar,不是应该不同的弹幕各自设置自己的icon吗?
每次自己发送弹幕时,设置的danmakuStyle使用的icon都是事先设置好的

@xanahopper
Copy link
Contributor

DanmakuItemData 可以自定义自己的类,拿到之后可以获取到自己的数据

@HpBoss
Copy link
Author

HpBoss commented Jun 16, 2022

感谢点拨,我自己自定义了一个AvatarRenderer,其中的drawable不再初始化DanmakuPlayer传入renderer时就设置,而是在解析json updatItem时先加载icon,加载成功后向DanmakuItem传入得到的drawable,最终AvatarRenderer measure和draw时拿取DanmaItem中的drawable进行测量绘制就可以了,这样每一条弹幕都能单独配置自己的Icon。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants