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

添加一个从父view逐级搜索到第一个scene的 方法 #10

Closed
Ccixyj opened this issue Dec 9, 2019 · 2 comments
Closed

添加一个从父view逐级搜索到第一个scene的 方法 #10

Ccixyj opened this issue Dec 9, 2019 · 2 comments

Comments

@Ccixyj
Copy link

Ccixyj commented Dec 9, 2019

感谢作者开源的框架。已经集成进项目中,不过我是对activity的某部分的viewgroup做了scene改造。
由于需要手动在activity中需要设置NavigationScene?引用比较丑。希望增加一个从父view逐级搜索到第一个scene就返回的方法.我参考的ViewUtility的方法写的代码

类似的代码

 @Nullable
    public static Scene searchSceneFromView(@Nullable View view) {
        if (view != null) {
            Scene scene = (Scene) view.getTag(R.id.bytedance_scene_view_scene_tag);
            if (scene != null) return scene;
            if (view instanceof ViewGroup) {
                ViewGroup vg = (ViewGroup) view;
                for (int i = 0; i < vg.getChildCount(); i++) {
                    View child = vg.getChildAt(i);
                    scene = searchSceneFromView(child);
                    if (scene != null) return scene;

                }
            }
        }
        return null;
    }
@qii
Copy link
Member

qii commented Dec 9, 2019

你是想从View直接取到NavigationScene吗?ktx库有View.requireNavigationScene()/View.getNavigationScene

@Ccixyj
Copy link
Author

Ccixyj commented Dec 10, 2019

我这边可能是从R.id.content布局来找NavigationScene。需要向下查找。View.requireNavigationScene()/View.getNavigationScene 只能向上查找。
我本地写成扩展方法了

@Ccixyj Ccixyj closed this as completed Dec 10, 2019
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