android.support.v4.view.NestedScrollingParent Java Examples

The following examples show how to use android.support.v4.view.NestedScrollingParent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RefreshContentWrapper.java    From CollapsingRefresh with Apache License 2.0 6 votes vote down vote up
private void findScrollableView(View content, RefreshKernel kernel) {
    mScrollableView = findScrollableViewInternal(content, true);
    try {
        if (mScrollableView instanceof CoordinatorLayout) {
            kernel.getRefreshLayout().setNestedScrollingEnabled(false);
            wrapperCoordinatorLayout(((CoordinatorLayout) mScrollableView), kernel.getRefreshLayout());
        }
    } catch (Throwable e) {//try 不能删除
    }
    if (mScrollableView instanceof NestedScrollingParent
            && !(mScrollableView instanceof NestedScrollingChild)) {
        mScrollableView = findScrollableViewInternal(mScrollableView, false);
    }
    if (mScrollableView instanceof ViewPager) {
        wrapperViewPager((ViewPager) this.mScrollableView);
    }
    if (mScrollableView == null) {
        mScrollableView = content;
    }
}
 
Example #2
Source File: RefreshContentWrapper.java    From CollapsingRefresh with Apache License 2.0 6 votes vote down vote up
private View findScrollableViewInternal(View content, boolean selfable) {
    View scrollableView = null;
    Queue<View> views = new LinkedBlockingQueue<>(Collections.singletonList(content));
    while (!views.isEmpty() && scrollableView == null) {
        View view = views.poll();
        if (view != null) {
            if ((selfable || view != content) && (view instanceof AbsListView
                    || view instanceof ScrollView
                    || view instanceof ScrollingView
                    || view instanceof NestedScrollingChild
                    || view instanceof NestedScrollingParent
                    || view instanceof WebView
                    || view instanceof ViewPager)) {
                scrollableView = view;
            } else if (view instanceof ViewGroup) {
                ViewGroup group = (ViewGroup) view;
                for (int j = 0; j < group.getChildCount(); j++) {
                    views.add(group.getChildAt(j));
                }
            }
        }
    }
    return scrollableView;
}
 
Example #3
Source File: RefreshContentWrapper.java    From CollapsingRefresh with Apache License 2.0 6 votes vote down vote up
@Override
public void setPrimaryItem(ViewGroup container, int position, Object object) {
    super.setPrimaryItem(container, position, object);
    if (object instanceof View) {
        mScrollableView = ((View) object);
    } else if (object instanceof Fragment) {
        mScrollableView = ((Fragment) object).getView();
    }
    if (mScrollableView != null) {
        mScrollableView = findScrollableViewInternal(mScrollableView, true);
        if (mScrollableView instanceof NestedScrollingParent
                && !(mScrollableView instanceof NestedScrollingChild)) {
            mScrollableView = findScrollableViewInternal(mScrollableView, false);
        }
    }
}