yannecer / NCalendar

一款安卓日历,仿miui,钉钉,华为的日历,万年历、365、周日历,月日历,月视图、周视图滑动切换,农历,节气,Andriod Calendar , MIUI Calendar,小米日历
Apache License 2.0
1.59k stars 314 forks source link

NCalendar getNestedScrollingChild 递归问题 #27

Closed Basakerone closed 6 years ago

Basakerone commented 6 years ago
private View getNestedScrollingChild(View view) {
    if (view instanceof ViewGroup) {
        int childCount = ((ViewGroup) view).getChildCount();
        for (int i = 0; i < childCount; i++) {
            View childAt = ((ViewGroup) view).getChildAt(i);
            if (childAt instanceof NestedScrollingChild) {
                return childAt;
            } else {
                return getNestedScrollingChild(((ViewGroup) view).getChildAt(i));  //修改
            }
        }
    }
    return null;
}

不然给recyclerview嵌套一层就会直接返回null

yannecer commented 6 years ago

@Basakerone 这个方法执行前,有判断的

Basakerone commented 6 years ago

前面的判断只适合嵌套一层,如果recyclerview嵌套2层,就直接返回null了

yannecer commented 6 years ago

@Basakerone 嗯,可能不是太完善,可以根据具体需求把targetView指向NestedScrollingChild的实现类就行了