Пример #1
0
 private void hideFb() {
   if (mScrollToTopFb.getVisibility() != View.VISIBLE) {
     return;
   }
   mScrollToTopFb.startAnimation(mFbOutAnim);
   mScrollToTopFb.setVisibility(View.INVISIBLE);
 }
Пример #2
0
 private void showFb() {
   if (mScrollToTopFb.getVisibility() == View.VISIBLE) {
     return;
   }
   mScrollToTopFb.setVisibility(View.VISIBLE);
   mScrollToTopFb.startAnimation(mFbInAnim);
 }
 public void hideFab() {
   if (mFab.getVisibility() == View.VISIBLE) {
     mFab.animate()
         .scaleX(0.65f)
         .scaleY(0.65f)
         .setDuration(100)
         .setListener(
             new AnimationFinishedListener() {
               @Override
               public void onAnimationFinished() {
                 mFab.setVisibility(View.GONE);
               }
             });
     mFab.setImageDrawable(
         new AnimatingDrawable.Builder(getBaseContext())
             .frames(
                 R.drawable.fab_close_1,
                 R.drawable.fab_close_2,
                 R.drawable.fab_close_3,
                 R.drawable.fab_close_4,
                 R.drawable.fab_close_5)
             .build());
     ((Animatable) mFab.getDrawable()).start();
   }
 }
 @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();
   } else if (dyConsumed < 0 && child.getVisibility() != View.VISIBLE) {
     child.show();
   }
 }
  @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 && !this.mIsAnimatingOut && child.getVisibility() == View.VISIBLE) {
      animateOut(child);
    } else if (dyConsumed < 0 && child.getVisibility() != View.VISIBLE) {
      animateIn(child);
    }
  }
Пример #6
0
 @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 && !this.mIsAnimatingOut && child.getVisibility() == View.VISIBLE) {
     // User scrolled down and the FAB is currently visible -> hide the FAB
     animateOut(child);
   } else if (dyConsumed < 0 && child.getVisibility() != View.VISIBLE) {
     // User scrolled up and the FAB is currently not visible -> show the FAB
     animateIn(child);
   }
 }
Пример #7
0
 @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);
   boolean canAnimation = true;
   if (child instanceof BetterFloatingActionButton) {
     canAnimation = ((BetterFloatingActionButton) child).canAnimation();
   }
   if (!canAnimation) return;
   if (dyConsumed > 0 && !this.mIsAnimatingOut && child.getVisibility() == View.VISIBLE) {
     animateOut(child);
   } else if (dyConsumed < 0 && child.getVisibility() != View.VISIBLE) {
     animateIn(child);
   }
 }