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

androidx的布局适配 #614

Closed
liluyue opened this issue Sep 17, 2021 · 3 comments · Fixed by #615
Closed

androidx的布局适配 #614

liluyue opened this issue Sep 17, 2021 · 3 comments · Fixed by #615

Comments

@liluyue
Copy link

liluyue commented Sep 17, 2021

因为androidx是通过setFactory2来变换布局信息的,而插件的getLayoutInflater()丢失了androidx全局设入的factory2,
导致布局丢失了androidx的风格。我本地是通过这种方式做的暂时修复。希望您能修复一下

 @NonNull
    @Override
    public LayoutInflater getLayoutInflater() {
        if (inflater == null) {
            inflater = super.getLayoutInflater();
            inflater.setFactory2(LayoutInflater.from(this).getFactory2());
        }
        return inflater;
    }
@shifujun
Copy link
Collaborator

你使用的代码已经包含 c710a18 了吗?提交注释说明了当时的情况,也是缺失了AndroidX自动安装的Factory。如果包含了,能方便修改一下LiveDataWithActivityTestActivity,演示一下怎么复现问题吗?可以在androidx-cases-app模块运行调试非插件环境下的表现。在LiveDataWithActivityTest运行自动化测试调试插件环境下的表现。

@liluyue
Copy link
Author

liluyue commented Sep 17, 2021

好的,我试一下

@liluyue
Copy link
Author

liluyue commented Sep 18, 2021

3f25c5c中包含了复现场景,由于对自动化测试不熟,我用了log的方式打印异常数据

shifujun added a commit to shifujun/Shadow that referenced this issue Sep 18, 2021
由于ShadowLayoutInflater不再只是一个转调壳子,有了状态(mOriginalFactory等),
不能再总是new新的对象了。换了新对象就无法还原Factory了。

fixup! c710a18
fix Tencent#614
shifujun added a commit that referenced this issue Sep 18, 2021
由于ShadowLayoutInflater不再只是一个转调壳子,有了状态(mOriginalFactory等),
不能再总是new新的对象了。换了新对象就无法还原Factory了。

fixup! c710a18
fix #614
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

Successfully merging a pull request may close this issue.

2 participants