private void init() {
    setLayoutParams(
        new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    mGestureListener =
        new SimpleOnGestureListener() {
          @Override
          public boolean onDown(MotionEvent e) {
            isFling = false;
            return true;
          }

          @Override
          public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            // TODO
            if ((e1.getX() - e2.getX()) > MIN_FLING && velocityX < MAX_VELOCITYX) {
              isFling = true;
            }
            // Log.i("byz", MAX_VELOCITYX + ", velocityX = " + velocityX);
            return super.onFling(e1, e2, velocityX, velocityY);
          }
        };
    mGestureDetector = new GestureDetectorCompat(getContext(), mGestureListener);

    // mScroller = ScrollerCompat.create(getContext(), new
    // BounceInterpolator());
    if (mCloseInterpolator != null) {
      mCloseScroller = ScrollerCompat.create(getContext(), mCloseInterpolator);
    } else {
      mCloseScroller = ScrollerCompat.create(getContext());
    }
    if (mOpenInterpolator != null) {
      mOpenScroller = ScrollerCompat.create(getContext(), mOpenInterpolator);
    } else {
      mOpenScroller = ScrollerCompat.create(getContext());
    }

    LayoutParams contentParams =
        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    mContentView.setLayoutParams(contentParams);
    if (mContentView.getId() < 1) {
      mContentView.setId(CONTENT_VIEW_ID);
    }

    mMenuView.setId(MENU_VIEW_ID);
    mMenuView.setLayoutParams(
        new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    addView(mContentView);
    addView(mMenuView);
  }
 public void smoothScrollBy(int dx, int dy, int duration, Interpolator interpolator) {
   if (mInterpolator != interpolator) {
     mInterpolator = interpolator;
     mScroller = ScrollerCompat.create(getContext(), interpolator);
   }
   setScrollState(SCROLL_STATE_SETTLING);
   mLastFlingX = mLastFlingY = 0;
   mScroller.startScroll(0, 0, dx, dy, duration);
   postOnAnimation();
 }
  public void init() {
    mGestureListener =
        new SimpleOnGestureListener() {
          @Override
          public boolean onDown(MotionEvent e) {
            isFling = false;
            return true;
          }

          @Override
          public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {

            if (velocityX > mViewConfiguration.getScaledMinimumFlingVelocity()
                || velocityY > mViewConfiguration.getScaledMinimumFlingVelocity()) isFling = true;
            return isFling;
          }
        };
    mGestureDetector = new GestureDetectorCompat(getContext(), mGestureListener);

    mCloseScroller = ScrollerCompat.create(getContext());
    mOpenScroller = ScrollerCompat.create(getContext());
  }
 public HeaderDrawerLayout(Context context, AttributeSet attrs, int defStyleAttr) {
   super(context, attrs, defStyleAttr);
   final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.HeaderDrawerLayout);
   final int headerLayoutId = a.getResourceId(R.styleable.HeaderDrawerLayout_hdl_headerLayout, 0);
   final int contentLayoutId =
       a.getResourceId(R.styleable.HeaderDrawerLayout_hdl_contentLayout, 0);
   addView(
       mContainer = new InternalContainer(this, context, headerLayoutId, contentLayoutId),
       LayoutParams.MATCH_PARENT,
       LayoutParams.WRAP_CONTENT);
   a.recycle();
   mDragHelper = ViewDragHelper.create(this, mDragCallback = new DragCallback(this));
   mGestureDetector = new GestureDetector(context, new GestureListener(this));
   mScroller = ScrollerCompat.create(context);
 }
 public void setCloseInterpolator(Interpolator closeInterpolator) {
   mCloseInterpolator = closeInterpolator;
   if (mCloseInterpolator != null) {
     mCloseScroller = ScrollerCompat.create(getContext(), mCloseInterpolator);
   }
 }
 public void setOpenInterpolator(Interpolator openInterpolator) {
   mOpenInterpolator = openInterpolator;
   if (mOpenInterpolator != null) {
     mOpenScroller = ScrollerCompat.create(getContext(), mOpenInterpolator);
   }
 }
  private void init() {
    setLayoutParams(
        new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    mGestureListener =
        new SimpleOnGestureListener() {
          @Override
          public boolean onDown(MotionEvent e) {
            isFling = false;
            return true;
          }

          @Override
          public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            // TODO
            if ((e1.getX() - e2.getX()) > MIN_FLING && velocityX < MAX_VELOCITYX) {
              isFling = true;
            }
            // Log.i("byz", MAX_VELOCITYX + ", velocityX = " + velocityX);
            return super.onFling(e1, e2, velocityX, velocityY);
          }
        };
    mGestureDetector = new GestureDetectorCompat(getContext(), mGestureListener);

    // mScroller = ScrollerCompat.create(getContext(), new
    // BounceInterpolator());
    if (mCloseInterpolator != null) {
      mCloseScroller = ScrollerCompat.create(getContext(), mCloseInterpolator);
    } else {
      mCloseScroller = ScrollerCompat.create(getContext());
    }
    if (mOpenInterpolator != null) {
      mOpenScroller = ScrollerCompat.create(getContext(), mOpenInterpolator);
    } else {
      mOpenScroller = ScrollerCompat.create(getContext());
    }

    LayoutParams contentParams =
        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    mContentView.setLayoutParams(contentParams);
    if (mContentView.getId() < 1) {
      mContentView.setId(CONTENT_VIEW_ID);
    }

    mMenuView.setId(MENU_VIEW_ID);
    mMenuView.setLayoutParams(
        new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    addView(mContentView);
    addView(mMenuView);

    // if (mContentView.getBackground() == null) {
    // mContentView.setBackgroundColor(Color.WHITE);
    // }

    // in android 2.x, MenuView height is MATCH_PARENT is not work.
    // getViewTreeObserver().addOnGlobalLayoutListener(
    // new OnGlobalLayoutListener() {
    // @Override
    // public void onGlobalLayout() {
    // setMenuHeight(mContentView.getHeight());
    // // getViewTreeObserver()
    // // .removeGlobalOnLayoutListener(this);
    // }
    // });

  }
 public ViewFlinger() {
   mScroller = ScrollerCompat.create(getContext(), sQuinticInterpolator);
 }
 public FlingRunnable(Context context) {
   mScroller = ScrollerCompat.create(context);
 }