@Override
 protected void onSizeChanged(int w, int h, int oldw, int oldh) {
   super.onSizeChanged(w, h, oldw, oldh);
   if (mScroller != null) {
     mScroller.onSizeChanged(w, h, oldw, oldh);
   }
 }
  @Override
  public void draw(Canvas canvas) {
    super.draw(canvas);

    // Overlay index bar
    if (mScroller != null) mScroller.draw(canvas);
  }
 @Override
 public void setAdapter(ListAdapter adapter) {
   super.setAdapter(adapter);
   if (mScroller != null) {
     mScroller.setAdapter(adapter);
   }
 }
 @Override
 public boolean onInterceptTouchEvent(MotionEvent ev) {
   if (mScroller.contains(ev.getX(), ev.getY())) {
     return true;
   }
   return super.onInterceptTouchEvent(ev);
 }
 @Override
 public boolean onTouchEvent(MotionEvent ev) {
   // Intercept ListView's touch event
   if (mScroller != null && mScroller.onTouchEvent(ev)) {
     return true;
   }
   if (mGestureDetector == null) {
     // Create a new GestureDetector -- 手势探测器
     mGestureDetector =
         new GestureDetector(
             getContext(),
             new GestureDetector.SimpleOnGestureListener() {
               @Override
               public boolean onFling(
                   MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
                 if (mScroller != null) {
                   mScroller.show();
                 }
                 return super.onFling(e1, e2, velocityX, velocityY);
               }
             });
   }
   mGestureDetector.onTouchEvent(ev);
   return super.onTouchEvent(ev);
 }
 @Override
 public void draw(Canvas canvas) {
   super.draw(canvas);
   if (mScroller != null) {
     mScroller.draw(canvas);
   }
 }
Beispiel #7
0
 // @Override
 public void setFastScrollEnabled(boolean enabled) {
   mIsFastScrollEnabled = enabled;
   if (mIsFastScrollEnabled) {
     if (mScroller == null) mScroller = new IndexScroller(getContext(), this);
   } else {
     if (mScroller != null) {
       mScroller.hide();
       mScroller = null;
     }
   }
 }
  @Override
  public boolean onTouchEvent(MotionEvent ev) {
    // Intercept ListView's touch event
    if (mScroller != null && mScroller.onTouchEvent(ev)) return true;

    if (mGestureDetector == null) {
      mGestureDetector =
          new GestureDetector(
              getContext(),
              new GestureDetector.SimpleOnGestureListener() {

                @Override
                public boolean onFling(
                    MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
                  // If fling happens, index bar shows
                  if (mScroller != null) mScroller.show();
                  return super.onFling(e1, e2, velocityX, velocityY);
                }
              });
    }
    mGestureDetector.onTouchEvent(ev);

    return super.onTouchEvent(ev);
  }