Shadow icon indicating copy to clipboard operation
Shadow copied to clipboard

插件Activity中使用自定义Dialog 样式问题

Open ARabbitCoder opened this issue 3 years ago • 3 comments

在插件Activity中弹出一个dialog, dialog 构造方法中使用插件内自定义style. 的动画没有生效。 通过debug发现此时的dialog的Resource对象的classloder 关系是PathClassLoder -> RuntimeClassLoader,猜测导致styleID 找不到。不知道是否是bug?

ARabbitCoder avatar May 05 '22 07:05 ARabbitCoder

Resources资源查找和ClassLoader好像没什么关系吧?你可以fork一下,在sample上已有的Dialog测试中复现一下问题。

Dialog因为有自己独立的Window,可能跟Activity一样,它的动画是由系统主动到已安装应用中查找的。如果是这样的场景,插件技术无法解决。

shifujun avatar May 05 '22 07:05 shifujun

这个问题跟https://github.com/Tencent/Shadow/issues/332 这个问题猜测理论上是一致的。我在我自己的项目上使用接口把宿主同样的style样式生成的 ID 传递到插件上就可以。看源码activity的Resource是经过shadow处理过的,所以Activity的ReourceIml的classloader是PluginClassloder, 在构建PluginClassloder 是传递了插件apk路径的,所以可以找到对应的资源,考虑到dialog是不是也需要进行getReource方法去重写呢?

ARabbitCoder avatar May 05 '22 07:05 ARabbitCoder

先把代码push上来看看吧。我猜的场景也不一定是你的场景。

shifujun avatar May 05 '22 07:05 shifujun