android.support.v4.view.NestedScrollingChild Java Examples
The following examples show how to use
android.support.v4.view.NestedScrollingChild.
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 |
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 |
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 |
@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); } } }
Example #4
Source File: QRefreshLayout.java From RefreshLayout with Apache License 2.0 | 6 votes |
@Override protected void onFinishInflate() { super.onFinishInflate(); if (getChildCount() > 1) { throw new IllegalStateException("QRefreshLayout can only have one child"); } mTarget = getChildAt(0); mTarget.setClickable(true); boolean targetNestedScrollingEnabled = false; if (mTarget instanceof NestedScrollingChild) { targetNestedScrollingEnabled = ((NestedScrollingChild) mTarget).isNestedScrollingEnabled(); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { targetNestedScrollingEnabled = mTarget.isNestedScrollingEnabled(); } setNestedScrollingEnabled(targetNestedScrollingEnabled); ViewGroup.LayoutParams params = mTarget.getLayoutParams(); params.width = LayoutParams.MATCH_PARENT; params.height = LayoutParams.MATCH_PARENT; mTarget.setLayoutParams(params); if (mHeaderView == null) { setHeaderView(new HeaderView(getContext())); } if (mFooterView == null) { setFooterView(new FooterView(getContext())); } }
Example #5
Source File: BottomSheetBehaviorV2.java From paper-launcher with MIT License | 5 votes |
private View findScrollingChild(View view) { if (view instanceof NestedScrollingChild) { return view; } if (view instanceof ViewGroup) { ViewGroup group = (ViewGroup) view; for (int i = 0, count = group.getChildCount(); i < count; i++) { View scrollingChild = findScrollingChild(group.getChildAt(i)); if (scrollingChild != null) { return scrollingChild; } } } return null; }
Example #6
Source File: BottomSheetBehaviorGoogleMapsLike.java From Nibo with MIT License | 5 votes |
private View findScrollingChild(View view) { if (view instanceof NestedScrollingChild) { return view; } if (view instanceof ViewGroup) { ViewGroup group = (ViewGroup) view; for (int i = 0, count = group.getChildCount(); i < count; i++) { View scrollingChild = findScrollingChild(group.getChildAt(i)); if (scrollingChild != null) { return scrollingChild; } } } return null; }
Example #7
Source File: TopSheetBehavior.java From AndroidTopSheet with Apache License 2.0 | 5 votes |
private View findScrollingChild(View view) { if (view instanceof NestedScrollingChild) { return view; } if (view instanceof ViewGroup) { ViewGroup group = (ViewGroup) view; for (int i = 0, count = group.getChildCount(); i < count; i++) { View scrollingChild = findScrollingChild(group.getChildAt(i)); if (scrollingChild != null) { return scrollingChild; } } } return null; }
Example #8
Source File: RNBottomSheetBehavior.java From react-native-bottom-sheet-behavior with MIT License | 5 votes |
private View findScrollingChild(View view) { if (view instanceof NestedScrollingChild) { return view; } if (view instanceof ViewGroup) { ViewGroup group = (ViewGroup) view; for (int i = 0, count = group.getChildCount(); i < count; i++) { View scrollingChild = findScrollingChild(group.getChildAt(i)); if (scrollingChild != null) { return scrollingChild; } } } return null; }
Example #9
Source File: SheetBehavior.java From AndroidSweetBehavior with Apache License 2.0 | 5 votes |
private View findScrollingChild(View view) { if (view instanceof NestedScrollingChild) { return view; } if (view instanceof ViewGroup) { ViewGroup group = (ViewGroup) view; for (int i = 0, count = group.getChildCount(); i < count; i++) { View scrollingChild = findScrollingChild(group.getChildAt(i)); if (scrollingChild != null) { return scrollingChild; } } } return null; }
Example #10
Source File: CommonPtrLayout.java From FamilyChat with Apache License 2.0 | 4 votes |
/** * 通过id得到相应的view */ @Override protected void onFinishInflate() { final int childCount = getChildCount(); if (childCount > 0) { mRefreshView = findViewById(com.lib.ptrview.R.id.common_ptrview_refresh_view); mContentView = findViewById(com.lib.ptrview.R.id.common_ptrview_content); mLoadMoreView = findViewById(com.lib.ptrview.R.id.common_ptrview_loadmore_view); mScrollContentView = findViewById(com.lib.ptrview.R.id.common_ptrview_content_scroll); } if (mContentView == null) { throw new IllegalStateException("CommonPtrLayout: mContentView is null"); } if (mIsCoo) { if (mContentView instanceof CoordinatorLayout) { CoordinatorLayout coo = (CoordinatorLayout) mContentView; mAppBar = (AppBarLayout) coo.getChildAt(0); setAppBarListener(); } else { throw new IllegalStateException("CommonPtrLayout: mContentView is not CoordinatorLayout"); } if (mScrollContentView == null) { throw new IllegalStateException("CommonPtrLayout: mScrollContentView is null"); } if (!(mScrollContentView instanceof NestedScrollingChild)) { throw new IllegalStateException("CommonPtrLayout: mScrollContentView is not NestedScrollingChild"); } } if (mRefreshEnabled) { if (mRefreshView == null) throw new IllegalStateException("CommonPrtLayout : You must set a refreshView when the refreshEnabled is true."); if (!(mRefreshView instanceof CommonPtrViewImpl)) throw new IllegalStateException("CommonPrtLayout : The refreshView must instanceof CommonPtrViewImpl."); mRefreshView.setBackgroundResource(mRefreshBgResId); getRefreshView().setIsPullDownMode(true); } if (mLoadMoreEnabled) { if (mLoadMoreView == null) throw new IllegalStateException("CommonPrtLayout : You must set a loadMoreView when the refreshEnabled is true."); if (!(mLoadMoreView instanceof CommonPtrViewImpl)) throw new IllegalStateException("CommonPrtLayout : The loadMoreView must instanceof CommonPtrViewImpl."); mLoadMoreView.setBackgroundResource(mLoadMoreBgResId); getLoadMoreView().setIsPullDownMode(false); } super.onFinishInflate(); for (int i = 0; i < childCount; i++) { View v = getChildAt(i); if (v != mContentView) bringChildToFront(v); } }
Example #11
Source File: CanRefreshLayout.java From CanRefresh with Apache License 2.0 | 2 votes |
/** * 通过id得到相应的view */ @Override protected void onFinishInflate() { final int childCount = getChildCount(); if (childCount > 0) { mHeaderView = findViewById(com.canyinghao.canrefresh.R.id.can_refresh_header); mContentView = findViewById(com.canyinghao.canrefresh.R.id.can_content_view); mFooterView = findViewById(com.canyinghao.canrefresh.R.id.can_refresh_footer); mScrollView = findViewById(com.canyinghao.canrefresh.R.id.can_scroll_view); } if (mContentView == null) { throw new IllegalStateException("mContentView is null"); } if (mIsCoo) { if (mContentView instanceof CoordinatorLayout) { CoordinatorLayout coo = (CoordinatorLayout) mContentView; mAppBar = (AppBarLayout) coo.getChildAt(0); setAppBarListener(); } else { throw new IllegalStateException("mContentView is not CoordinatorLayout"); } if (mScrollView == null) { throw new IllegalStateException("mScrollView is null"); } if (mScrollView instanceof ViewPager) { mViewPager = (ViewPager) mScrollView; mIsViewPager = true; } else if (mScrollView instanceof NestedScrollingChild) { mIsViewPager = false; } else { throw new IllegalStateException("mScrollView is not NestedScrollingChild or ViewPager"); } } if (mHeaderView != null && !(mHeaderView instanceof CanRefresh)) { throw new IllegalStateException("mHeaderView error"); } if (mFooterView != null && !(mFooterView instanceof CanRefresh)) { throw new IllegalStateException("mFooterView error"); } if (mHeaderView != null) { getHeaderInterface().setIsHeaderOrFooter(true); } if (mFooterView != null) { getFooterInterface().setIsHeaderOrFooter(false); } super.onFinishInflate(); setStyle(mHeadStyle, mFootStyle); }