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

插件manager中的view如果有ProgressBar,但是宿主不显示ProgressBar #1271

Closed
budaowengd opened this issue Dec 17, 2023 · 4 comments · Fixed by #1273
Closed

插件manager中的view如果有ProgressBar,但是宿主不显示ProgressBar #1271

budaowengd opened this issue Dec 17, 2023 · 4 comments · Fixed by #1273
Assignees
Labels
bug Something isn't working

Comments

@budaowengd
Copy link

budaowengd commented Dec 17, 2023

1、Shadow里Manager就会首先从manger.apk中动态加载一个View供宿主显示Loading状态。修改activity_load_plugin.xml
`

<ProgressBar
    style="?android:attr/progressBarStyle"
    android:id="@+id/progressBar1"
    android:indeterminateTint="@android:color/holo_blue_dark"
    android:layout_gravity="center"
    android:layout_height="wrap_content"
    android:layout_marginTop="30dp"
    android:layout_width="wrap_content"
    android:max="100"
    android:progress="50"
    android:progressTint="@android:color/holo_blue_dark" />

<TextView
    android:layout_gravity="center"
    android:layout_height="wrap_content"
    android:layout_marginTop="10dp"
    android:layout_width="wrap_content"
    android:text="正在加载中..."
    android:textSize="30sp" />
`

2、ProgressBar 不会显示,页面只显示"正在加载中..."
image
image

请问是咋回事

@shifujun
Copy link
Collaborator

shifujun commented Dec 18, 2023

这一般就是View的Context的问题。

final View view = LayoutInflater.from(mCurrentContext).inflate(R.layout.activity_load_plugin, null);

这里的inflater的context可能是宿主的。所以有些资源可能找不到。调试调试看看它在请求context的哪些接口,搞一个wrapper接下来请求,从插件里取资源给它一般就可以了。

@budaowengd
Copy link
Author

大佬,我从github拉下来Shadow代码后,就修改了 activity_load_plugin.xml,然后加了个ProgressBar,就显示不了了。你说的"搞一个wrapper接下来请求,从插件里取资源给它一般就可以了。" 我有点不懂该改哪里,可以再详细说说吗?

shifujun added a commit to shifujun/Shadow that referenced this issue Dec 19, 2023
模仿ContextThemeWrapper的做法。
否则Android内置的View,如ProgressBar在从Theme.obtainStyledAttributes
时会获取不到自己的资源。

fix Tencent#1271
@shifujun
Copy link
Collaborator

这是个Bug。activity_load_plugin.xml原本就有个ProgressBar没显示出来。
没看代码前,我忘了前面说的那个context其实已经不是宿主的了。

@shifujun shifujun added the bug Something isn't working label Dec 19, 2023
@shifujun shifujun self-assigned this Dec 19, 2023
@budaowengd
Copy link
Author

已确认修复,感谢!

shifujun added a commit that referenced this issue Dec 20, 2023
模仿ContextThemeWrapper的做法。
否则Android内置的View,如ProgressBar在从Theme.obtainStyledAttributes
时会获取不到自己的资源。

fix #1271
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants