@Override
 public void onViewDragStateChanged(int state) {
   switch (state) {
     case ViewDragHelper.STATE_SETTLING:
     case ViewDragHelper.STATE_DRAGGING:
       {
         mScrollingHeaderByHelper = false;
         break;
       }
     case ViewDragHelper.STATE_IDLE:
       {
         if (mTime > 0 && !Float.isNaN(mVelocity)) {
           final float velocity = mVelocity;
           if (velocity < 0 && mDrawer.getHeaderTop() <= mDrawer.getHeaderTopMinimum()) {
             mDrawer.flingCallback(-velocity);
           }
         }
         mTime = -1;
         mDx = Float.NaN;
         mDy = Float.NaN;
         mVelocity = Float.NaN;
         mScrollingHeaderByHelper = false;
         break;
       }
   }
   super.onViewDragStateChanged(state);
 }
 @Override
 public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
   final int top = mDrawer.getHeaderTop(), min = mDrawer.getHeaderTopMinimum();
   final boolean showingFullContent = top <= min, flingUp = velocityY < 0;
   final boolean verticalFling = Math.abs(velocityY) > Math.abs(velocityX);
   if (!verticalFling) return true;
   if (showingFullContent) {
     if (flingUp) {
       // Fling list up when showing full content
       if (mDrawer.isScrollingContentCallback()) {
         mDrawer.flingCallback(-velocityY);
       }
     } else {
       // Fling down when list reached top and not dragging user ViewDragHelper,
       // so we fling header down here
       if (!mDrawer.canScrollCallback(1) && !mDrawer.isUsingDragHelper()) {
         mDrawer.flingHeader(velocityY);
       }
     }
   } else {
     // Header still visible
   }
   return true;
 }