@Override public void onNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) { super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed); if (dyConsumed > 0 && child.getVisibility() == View.VISIBLE) { child.hide(new FloatingActionButton.OnVisibilityChangedListener() { @Override public void onHidden(FloatingActionButton fab) { super.onShown(fab); fab.setVisibility(View.INVISIBLE); } }); } else if (dyConsumed < 0){ child.show(); } }
private float[] getFabTranslationYForBottomNavigationBar(CoordinatorLayout parent, FloatingActionButton fab) { float minOffset = 0; float viewHeight = 0; final List<View> dependencies = parent.getDependencies(fab); for (int i = 0, z = dependencies.size(); i < z; i++) { final View view = dependencies.get(i); if (view instanceof BottomNavigationBar) { viewHeight = view.getHeight(); minOffset = Math.min(minOffset, ViewCompat.getTranslationY(view) - viewHeight); } } float[] returnValues = {minOffset, viewHeight}; return returnValues; }
@Override public void onNestedScroll(final CoordinatorLayout coordinatorLayout, final FloatingActionButton child, final View target, final int dxConsumed, final int dyConsumed, final int dxUnconsumed, final int dyUnconsumed) { super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed); if (dyConsumed > 0 && child.getVisibility() == View.VISIBLE) { /** design lib 升级到 25.1.0 导致 child.hide() 效果失效,法克哟 * http://stackoverflow.com/questions/41761736/android-design-library-25-1-0-causes-floatingactionbutton-behavior-to-stop-worki */ child.hide(new FloatingActionButton.OnVisibilityChangedListener() { @Override public void onHidden(FloatingActionButton fab) { super.onHidden(fab); fab.setVisibility(View.INVISIBLE); } }); } else if (dyConsumed < 0 && child.getVisibility() != View.VISIBLE) { child.show(); } }
@Override public void updateSnackbar(CoordinatorLayout parent, View dependency, View child) { if (dependency instanceof Snackbar.SnackbarLayout) { if (mSnackbarHeight == -1) { mSnackbarHeight = dependency.getHeight(); } int targetPadding = child.getMeasuredHeight(); int shadow = (int) ViewCompat.getElevation(child); ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) dependency.getLayoutParams(); layoutParams.bottomMargin = targetPadding - shadow; child.bringToFront(); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { child.getParent().requestLayout(); ((View) child.getParent()).invalidate(); } } }
private void init(final CoordinatorLayout coordinatorLayout, final AppBarLayout child) { // disable dragCallback by default if (mDragCallbackListener == null) { mDragCallbackListener = new DragCallback() { @Override public boolean canDrag(AppBarLayout appBarLayout) { return false; } }; setDragCallback(mDragCallbackListener); } // dispatch init event Utils.log("onInit"); mCoordinatorLayout = coordinatorLayout; onInit(coordinatorLayout, child); }
@Override public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, View child, View target, int dx, int dy, int[] consumed) { super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed); // if (!mIsScrollToBottom) { // float mPreTranslationY = dy + child.getTranslationY(); // if (mPreTranslationY <= 0) { // child.setTranslationY(0); // mIsAnimatingOut = true; // } // if (mPreTranslationY >= child.getHeight()) { // child.setTranslationY(child.getHeight()); // mIsAnimatingOut = false; // } // if (mPreTranslationY > 0 && mPreTranslationY < child.getHeight()) { // child.setTranslationY(mPreTranslationY); // mIsAnimatingOut = dy > 0; // } // } }
@Override public boolean onDependentViewChanged(CoordinatorLayout parent, SimpleDraweeView child, View dependency) { maybeInitProperties(child, dependency); final int maxScrollDistance = (int) (mStartToolbarPosition - getStatusBarHeight()); float expandedPercentageFactor = dependency.getY() / maxScrollDistance; float distanceYToSubtract = ((mStartYPosition - mFinalYPosition) * (1f - expandedPercentageFactor)) + (child.getHeight()/2); float distanceXToSubtract = ((mStartXPosition - mFinalXPosition) * (1f - expandedPercentageFactor)) + (child.getWidth()/2); float heightToSubtract = ((mStartHeight - finalHeight) * (1f - expandedPercentageFactor)); child.setY(mStartYPosition - distanceYToSubtract); child.setX(mStartXPosition - distanceXToSubtract); int proportionalAvatarSize = (int) (mAvatarMaxSize * (expandedPercentageFactor)); CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) child.getLayoutParams(); lp.width = (int) (mStartHeight - heightToSubtract); lp.height = (int) (mStartHeight - heightToSubtract); child.setLayoutParams(lp); return true; }
@Override public boolean onNestedFling(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target, float velocityX, float velocityY, boolean consumed) { if (target instanceof RecyclerView && velocityY < 0) { Log.d(TAG, "onNestedFling: target is recyclerView"); final RecyclerView recyclerView = (RecyclerView) target; final View firstChild = recyclerView.getChildAt(0); final int childAdapterPosition = recyclerView.getChildAdapterPosition(firstChild); consumed = childAdapterPosition > TOP_CHILD_FLING_THRESHOLD; } // prevent fling flickering when going up if (target instanceof NestedScrollView && velocityY > 0) { consumed = true; } if (Math.abs(velocityY) < OPTIMAL_FLING_VELOCITY) { velocityY = OPTIMAL_FLING_VELOCITY * (velocityY < 0 ? -1 : 1); } Log.d(TAG, "onNestedFling: velocityY - " + velocityY + ", consumed - " + consumed); return super.onNestedFling(coordinatorLayout, child, target, velocityX, velocityY, consumed); }
@Override public void onNestedScroll(final CoordinatorLayout coordinatorLayout, final FloatingActionButton fab, final View target, final int dxConsumed, final int dyConsumed, final int dxUnconsumed, final int dyUnconsumed) { super.onNestedScroll(coordinatorLayout, fab, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed); if (!enabled) return; if (dyConsumed > 0 && fab.getVisibility() == View.VISIBLE) { // User scrolled down and the FAB is currently visible -> hide the FAB fab.hide(); } else if (dyConsumed < 0 && fab.getVisibility() != View.VISIBLE) { // User scrolled up and the FAB is currently not visible -> show the FAB fab.postDelayed(new Runnable() { @Override public void run() { fab.show(); } }, 200L); } }
@Override protected void setBaseView(@LayoutRes int layoutId) { Slidr.attach(this); contentView = LayoutInflater.from(this).inflate(R.layout.activity_back, null); setContentView(contentView); rootLayout = (CoordinatorLayout) findViewById(R.id.root_layout); abl = (AppBarLayout) findViewById(R.id.abl); mToolbar = (Toolbar) findViewById(R.id.toolbar); flActivityContainer = (FrameLayout) findViewById(R.id.activity_container); flActivityContainer.addView(LayoutInflater.from(this).inflate(layoutId, flActivityContainer, false)); setSupportActionBar(mToolbar); getToolBar().setDisplayHomeAsUpEnabled(true); BarUtils.setStatusBarColor(this, ContextCompat.getColor(UtilsApp.getInstance(), R.color.colorPrimary), 0); BarUtils.addMarginTopEqualStatusBarHeight(rootLayout); }
/** * 点击内容栏唤起底部操作区域 * * @param coordinatorLayout 外部CoordinatorLayout * @param contentView 滚动区域 * @param bottomView 滚动时隐藏底部区域 */ public static void showBottomLayout(CoordinatorLayout coordinatorLayout, View contentView, final View bottomView) { //coordinatorLayout.onStartNestedScroll(contentView, null, ViewCompat.SCROLL_AXIS_VERTICAL); //coordinatorLayout.onNestedPreScroll(bottomView, 0, -1, new int[2]); //coordinatorLayout.onStopNestedScroll(null); // bottomView.animate() // .translationY(0) // .setInterpolator(INTERPOLATOR) // .setDuration(200) // .setListener(new AnimatorListenerAdapter() { // @Override // public void onAnimationEnd(Animator animation) { // bottomView.setTranslationY(0); // } // }); }
/** 初始化数据 */ private void prepare(CoordinatorLayout parent, View child, View dependency) { mDependStartX = (int) dependency.getX(); mDependStartY = (int) dependency.getY(); mDependStartWidth = dependency.getWidth(); mDependStartHeight = dependency.getHeight(); mStartX = (int) child.getX(); mStartY = (int) child.getY(); mStartWidth = child.getWidth(); mStartHeight = child.getHeight(); mStartAlpha = child.getAlpha(); mStartRotateX = child.getRotationX(); mStartRotateY = child.getRotationY(); //特殊处理y方向变化 if (mDependTargetY == UNSPECIFIED_INT && dependency instanceof AppBarLayout) { mDependTargetY = ((AppBarLayout) dependency).getTotalScrollRange(); } // 背景颜色渐变 if (child.getBackground() instanceof ColorDrawable) mStartBackgroundColor = ((ColorDrawable) child.getBackground()).getColor(); // 自定义动画 if (mAnimationId != 0) { mAnimation = AnimationUtils.loadAnimation(child.getContext(), mAnimationId); mAnimation.initialize(child.getWidth(), child.getHeight(), parent.getWidth(), parent.getHeight()); } // 兼容5.0以上的沉浸模式 if (Build.VERSION.SDK_INT > 16 && parent.getFitsSystemWindows() && targetY != UNSPECIFIED_INT) { targetY += getStatusBarHeight(parent.getContext()); } isPrepared = true; }
@Override public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) { //UCViewTab要滑动的距离为Header的高度减去TitleView的高度 float offsetRange = mTitleViewHeight - dependency.getMeasuredHeight(); //当Header向上滑动mTitleViewHeight高度后,即滑动完成 int headerOffsetRange = -mTitleViewHeight; if(dependency.getTranslationY() == headerOffsetRange) {//Header已经上滑结束 child.setTranslationY(offsetRange); } else if(dependency.getTranslationY() == 0) {//下滑结束,也是初始化的状态 child.setTranslationY(0); } else { //UCViewTab与UCViewHeader为同向滑动 //根据依赖UCViewHeader的滑动比例计算当前UCViewTab应该要滑动的值translationY child.setTranslationY(dependency.getTranslationY() / (headerOffsetRange * 1.0f) * offsetRange); } return false; }
@Override protected void layoutChild(final CoordinatorLayout parent, final View child, final int layoutDirection) { final List<View> dependencies = parent.getDependencies(child); final View header = findFirstDependency(dependencies); if (header != null) { final CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) child.getLayoutParams(); final Rect available = mTempRect1; available.set(parent.getPaddingLeft() + lp.leftMargin, header.getBottom() + lp.topMargin, parent.getWidth() - parent.getPaddingRight() - lp.rightMargin, parent.getHeight() + header.getBottom() - parent.getPaddingBottom() - lp.bottomMargin); final Rect out = mTempRect2; GravityCompat.apply(resolveGravity(lp.gravity), child.getMeasuredWidth(), child.getMeasuredHeight(), available, out, layoutDirection); final int overlap = getOverlapPixelsForOffset(header); child.layout(out.left, out.top - overlap, out.right, out.bottom - overlap); mVerticalLayoutGap = out.top - header.getBottom(); } else { // If we don't have a dependency, let super handle it super.layoutChild(parent, child, layoutDirection); mVerticalLayoutGap = 0; } }
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { Dialog mSheet = super.onCreateDialog(savedInstanceState); View contentView = View.inflate(getContext(), R.layout.bottom_sheet_emoticons, null); mSheet.setContentView(contentView); unbinder = ButterKnife.bind(this, mSheet); CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) ((View) contentView.getParent()).getLayoutParams(); CoordinatorLayout.Behavior behavior = params.getBehavior(); if (behavior != null && behavior instanceof BottomSheetBehavior) { bottomSheetBehavior = (BottomSheetBehavior) behavior; bottomSheetBehavior.setBottomSheetCallback(mBottomSheetBehaviorCallback); } onPostCreate(this); return mSheet; }
@Override public void onNestedScroll(CoordinatorLayout coordinatorLayout, V child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) { super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed); if (dyUnconsumed > 0 && mTotalDyUnconsumed < 0) { mTotalDyUnconsumed = 0; mOverScrollDirection = ScrollDirection.SCROLL_DIRECTION_UP; } else if (dyUnconsumed < 0 && mTotalDyUnconsumed > 0) { mTotalDyUnconsumed = 0; mOverScrollDirection = ScrollDirection.SCROLL_DIRECTION_DOWN; } mTotalDyUnconsumed += dyUnconsumed; onNestedVerticalOverScroll(coordinatorLayout, child, mOverScrollDirection, dyConsumed, mTotalDyUnconsumed); // @By_syk // Log.d(C.LOG_TAG, "onNestedScroll: " + mTotalDyUnconsumed); // if (Math.abs(mTotalDyUnconsumed) > dampLen) { // onNestedVerticalOverScroll(coordinatorLayout, child, mOverScrollDirection, dyConsumed, mTotalDyUnconsumed); // } }
@Override public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) { StretchView v = (StretchView) dependency; switch (v.getDirection()) { case StretchView.BOTTOM: child.setTranslationY(Math.min(dependency.getY() - parent.getHeight(), 0)); return true; case StretchView.LEFT: child.setTranslationX(Math.max(dependency.getX(), 0)); return true; case StretchView.RIGHT: child.setTranslationX(Math.min(dependency.getX() - parent.getWidth(), 0)); return true; } return false; }
@Override public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, View directTargetChild, View target, int nestedScrollAxes) { if (nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL){ return true; } return super.onStartNestedScroll(coordinatorLayout, child, directTargetChild, target, nestedScrollAxes); }
@Override public boolean onTouchEvent(CoordinatorLayout parent, V child, MotionEvent event) { if (!child.isShown()) { return false; } int action = MotionEventCompat.getActionMasked(event); if (mState == STATE_DRAGGING && action == MotionEvent.ACTION_DOWN) { return true; } mViewDragHelper.processTouchEvent(event); // Record the velocity if (action == MotionEvent.ACTION_DOWN) { reset(); } if (mVelocityTracker == null) { mVelocityTracker = VelocityTracker.obtain(); } mVelocityTracker.addMovement(event); // The ViewDragHelper tries to capture only the top-most View. We have to explicitly tell it // to capture the bottom sheet in case it is not captured and the touch slop is passed. if (action == MotionEvent.ACTION_MOVE && !mIgnoreEvents) { if (Math.abs(mInitialY - event.getY()) > mViewDragHelper.getTouchSlop()) { mViewDragHelper.captureChildView(child, event.getPointerId(event.getActionIndex())); } } return !mIgnoreEvents; }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // We have a menu item to show in action bar. setHasOptionsMenu(true); AppCompatActivity activity = (AppCompatActivity) getActivity(); if (activity != null) { mCoordinatorLayout = (CoordinatorLayout) getActivity().findViewById(R.id.coordinator_layout); //setupRevealBackground(savedInstanceState); if (mPrefs == null) mPrefs = PreferenceManager.getDefaultSharedPreferences(activity); mHandler = new Handler(); mParser = Parser.getExistingInstance(mPrefs.getInt(Constants.KEY_ANIME_SOURCE, Constants.DEFAULT_ANIME_SOURCE)); mIsGrid = mPrefs.getBoolean(Constants.KEY_SHOW_CATALOG_AS_GRID, true); mGridColumnCount = mPrefs.getInt(Constants.KEY_GRID_COLUMN_COUNT, getResources().getInteger(R.integer.grid_num_cols)); mListColumnCount = mPrefs.getInt(Constants.KEY_LIST_COLUMN_COUNT, getResources().getInteger(R.integer.list_num_cols)); mLayoutManager = new GridLayoutManager(getActivity(), mIsGrid ? mGridColumnCount : mListColumnCount); mRecyclerView.setLayoutManager(mLayoutManager); // Create an empty adapter we will use to display the loaded data. mAdapter = new EpisodeRecyclerAdapter(getActivity(), itemClickListener); mRecyclerView.setAdapter(mAdapter); } //Restore previous state if (savedInstanceState == null) { // Prepare the loader. Either re-connect with an existing one, // or start a new one. getLoaderManager().initLoader(0, null, this); } }
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); if (mBehavior == null) { mBehavior = (Behavior) ((CoordinatorLayout.LayoutParams) getLayoutParams()).getBehavior(); } }
private Snackbar.SnackbarLayout getSnackBarInstance(CoordinatorLayout parent, V child) { final List<View> dependencies = parent.getDependencies(child); for (int i = 0, z = dependencies.size(); i < z; i++) { final View view = dependencies.get(i); if (view instanceof Snackbar.SnackbarLayout) { return (Snackbar.SnackbarLayout) view; } } return null; }
@Override public void onStopNestedScroll(CoordinatorLayout coordinatorLayout, View child, View target) { super.onStopNestedScroll(coordinatorLayout, child, target); if (child.getTranslationY() == 0 || child.getTranslationY() == child.getHeight()) return; if (mIsAnimatingOut) { animateOut(child); } else { animateIn(child); } }
@Override public boolean onLayoutChild(CoordinatorLayout parent, View child, int layoutDirection) { // FIXME: 16/7/27 不知道为啥在XML设置-45dip,解析出来的topMargin少了1个px,所以这里用代码设置一遍 ((CoordinatorLayout.LayoutParams) child.getLayoutParams()).topMargin = -getTitleHeight(); parent.onLayoutChild(child, layoutDirection); if (BuildConfig.DEBUG) { Log.d(TAG, "layoutChild:top" + child.getTop() + ",height" + child.getHeight()); } return true; }
@Override public boolean onStartNestedScroll(CoordinatorLayout parent, AppBarLayout child, View directTargetChild, View target, int nestedScrollAxes, int type) { if (super.onStartNestedScroll(parent, child, directTargetChild, target, nestedScrollAxes, type)) { bindChild(child); mOriginTop = child.getY(); mAppBarLayout.stopScrollAnimation(); return true; } else { return false; } }
/** * @param duration open animation duration */ public void openPager(int duration) { View child = mChild.get(); CoordinatorLayout parent = mParent.get(); if (isClosed() && child != null) { if (mFlingRunnable != null) { child.removeCallbacks(mFlingRunnable); mFlingRunnable = null; } mFlingRunnable = new FlingRunnable(parent, child); mFlingRunnable.scrollToOpen(duration); } }
@Override public boolean onDependentViewChanged(CoordinatorLayout parent, FloatingActionButton child, View dependency) { if (isDependent(dependency)) { updateFabTranslationForBottomNavigationBar(parent, child, dependency); return false; } return super.onDependentViewChanged(parent, child, dependency); }
@Override public void onDependentViewRemoved(CoordinatorLayout parent, FloatingActionButton child, View dependency) { if (isDependent(dependency)) { updateFabTranslationForBottomNavigationBar(parent, child, dependency); } }
@Override public void onDetached(SmoothRefreshLayout layout) { layout.setOnChildNotYetInEdgeCannotMoveFooterCallBack(null); layout.setOnChildNotYetInEdgeCannotMoveHeaderCallBack(null); CoordinatorLayout coordinatorLayout = findCoordinatorLayout(layout); if (coordinatorLayout == null) return; AppBarLayout appBarLayout = findAppBarLayout(coordinatorLayout); if (appBarLayout == null) return; appBarLayout.removeOnOffsetChangedListener(this); }
@Override public void onNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) { if ((dyConsumed > 0 || dyUnconsumed > 0) && !isAnimatingOut && child.getVisibility() == View.VISIBLE) {//往下滑 AnimatorUtil.scaleHide(child, viewPropertyAnimatorListener); if (mOnStateChangedListener != null) { mOnStateChangedListener.onChanged(false); } } else if ((dyConsumed < 0 || dyUnconsumed < 0) && child.getVisibility() != View.VISIBLE) { AnimatorUtil.scaleShow(child, null); if (mOnStateChangedListener != null) { mOnStateChangedListener.onChanged(true); } } }
/** * 布局child的位置, 和自定义view的套路一样 */ @Override public boolean onLayoutChild(CoordinatorLayout parent, V child, int layoutDirection) { if (mTargetView != null) { ViewCompat.offsetTopAndBottom(mTargetView, lastTop); int top = mTargetView.getBottom();// - Math.abs(lastTop); child.layout(0, top, child.getMeasuredWidth(), top + child.getMeasuredHeight()); return true; } return super.onLayoutChild(parent, child, layoutDirection); }
public boolean onLayoutChildFixed(CoordinatorLayout parent, V child, int layoutDirection) { if (ViewCompat.getFitsSystemWindows(parent) && !ViewCompat.getFitsSystemWindows(child)) { ViewCompat.setFitsSystemWindows(child, true); } int savedTop = child.getTop(); // First let the parent lay it out parent.onLayoutChild(child, layoutDirection); // Offset the bottom sheet mParentHeight = parent.getHeight(); int peekHeight; if (mPeekHeightAuto) { if (mPeekHeightMin == 0) { mPeekHeightMin = parent.getResources().getDimensionPixelSize( android.support.design.R.dimen.design_bottom_sheet_peek_height_min); } peekHeight = Math.max(mPeekHeightMin, mParentHeight - parent.getWidth() * 9 / 16); } else { peekHeight = mPeekHeight; } mMinOffset = Math.max(0, mParentHeight - child.getHeight()); mMaxOffset = Math.max(mParentHeight - peekHeight, mMinOffset); if (mState == STATE_EXPANDED) { ViewCompat.offsetTopAndBottom(child, mMinOffset); } else if (mHideable && mState == STATE_HIDDEN) { ViewCompat.offsetTopAndBottom(child, mParentHeight); } else if (mState == STATE_COLLAPSED) { ViewCompat.offsetTopAndBottom(child, mMaxOffset); } else if (mState == STATE_DRAGGING || mState == STATE_SETTLING) { ViewCompat.offsetTopAndBottom(child, savedTop - child.getTop()); } if (mViewDragHelper == null) { mViewDragHelper = ViewDragHelper.create(parent, mDragCallback); } mViewRef = new WeakReference<>(child); mNestedScrollingChildRef = new WeakReference<>(findScrollingChild(child)); return true; }
@Override public void onNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) { if(dyConsumed > 0 && child.getVisibility() == View.INVISIBLE){ child.show(); }else if(dyConsumed < 0){ //官方的hide方法会设置为gone,而这个方法在view为gone时不会调用 child.setVisibility(View.INVISIBLE); } }
@Override public void onNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) { if ((dyConsumed > 0 || dyUnconsumed > 0) && !isAnimatingOut && child.getVisibility() == View.VISIBLE) { AnimatorUtil.scaleHide(child, listener); if (mOnStateChangedListener != null) { mOnStateChangedListener.onChanged(false); } } else if ((dyConsumed < 0 || dyUnconsumed < 0) && child.getVisibility() != View.VISIBLE) { AnimatorUtil.scaleShow(child, null); if (mOnStateChangedListener != null) { mOnStateChangedListener.onChanged(true); } } }
@Override public boolean onStartNestedScroll(final CoordinatorLayout coordinatorLayout, final FloatingActionButton child, final View directTargetChild, final View target, final int nestedScrollAxes) { // Ensure we react to vertical scrolling return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL || super.onStartNestedScroll(coordinatorLayout, child, directTargetChild, target, nestedScrollAxes); }
public void setFab(FloatingActionButton fab) { ViewGroup.LayoutParams layoutParams = fab.getLayoutParams(); if (layoutParams != null && layoutParams instanceof CoordinatorLayout.LayoutParams) { CoordinatorLayout.LayoutParams coLayoutParams = (CoordinatorLayout.LayoutParams) layoutParams; BottomNavBarFabBehaviour bottomNavBarFabBehaviour = new BottomNavBarFabBehaviour(); coLayoutParams.setBehavior(bottomNavBarFabBehaviour); } }
private float getFabTranslationYForSnackbar(CoordinatorLayout parent, View fab) { float minOffset = 0; final List<View> dependencies = parent.getDependencies(fab); for (int i = 0, z = dependencies.size(); i < z; i++) { final View view = dependencies.get(i); if (view instanceof Snackbar.SnackbarLayout && parent.doViewsOverlap(fab, view)) { minOffset = Math.min(minOffset, ViewCompat.getTranslationY(view) - view.getHeight()); } } return minOffset; }
@Override public boolean onNestedPreFling(CoordinatorLayout coordinatorLayout, DummyView child, View target, float velocityX, float velocityY) { BottomSheetCoordinatorLayout sheet = (BottomSheetCoordinatorLayout) coordinatorLayout; if (shouldForwardEvent(sheet, velocityY > 0)) { return sheet.getBehavior().onNestedPreFling(coordinatorLayout, sheet, target, velocityX, velocityY); } else { return false; } }
@Override public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, View child, View directTargetChild, View target, int nestedScrollAxes) { if (tabSuspension) { return (nestedScrollAxes & ViewCompat.SCROLL_AXIS_VERTICAL) != 0 && !isClosed(); } return (nestedScrollAxes & ViewCompat.SCROLL_AXIS_VERTICAL) != 0; }