Esempio n. 1
0
 public void onScroll(int distance) { // 杞瓙杞姩杩囩▼涓�
   doScroll(distance);
   int height = getHeight();
   if (scrollingOffset > height) {
     scrollingOffset = height;
     scroller.stopScrolling();
   } else if (scrollingOffset < -height) {
     scrollingOffset = -height;
     scroller.stopScrolling();
   }
 }
Esempio n. 2
0
  @Override
  public boolean onTouchEvent(MotionEvent event) {
    if (!isEnabled() || getViewAdapter() == null) {
      return true;
    }

    switch (event.getAction()) {
      case MotionEvent.ACTION_MOVE:
        if (getParent() != null) {
          getParent().requestDisallowInterceptTouchEvent(true);
        }
        break;

      case MotionEvent.ACTION_UP:
        if (!isScrollingPerformed) {
          int distance = (int) event.getY() - getHeight() / 2;
          if (distance > 0) {
            distance += getItemHeight() / 2;
          } else {
            distance -= getItemHeight() / 2;
          }
          int items = distance / getItemHeight();
          if (items != 0 && isValidItemIndex(currentItem + items)) {
            notifyClickListenersAboutClick(currentItem + items);
          }
        }
        break;
    }

    return scroller.onTouchEvent(event);
  }
Esempio n. 3
0
 /** Stops scrolling */
 public void stopScrolling() {
   scroller.stopScrolling();
 }
Esempio n. 4
0
 /**
  * Scroll the wheel
  *
  * @param itemsToSkip items to scroll
  * @param time scrolling duration
  */
 public void scroll(int itemsToScroll, int time) {
   int distance = itemsToScroll * getItemHeight() - scrollingOffset;
   scroller.scroll(distance, time);
 }
Esempio n. 5
0
 /**
  * Set the the specified scrolling interpolator
  *
  * @param interpolator the interpolator
  */
 public void setInterpolator(Interpolator interpolator) {
   scroller.setInterpolator(interpolator);
 }
Esempio n. 6
0
 public void onJustify() {
   if (Math.abs(scrollingOffset) > WheelScroller.MIN_DELTA_FOR_SCROLLING) {
     scroller.scroll(scrollingOffset, 0);
   }
 }
Esempio n. 7
0
 /**
  * Scroll the spinnerwheel
  *
  * @param itemsToScroll items to scroll
  * @param time scrolling duration
  */
 public void scroll(int itemsToScroll, int time) {
   int distance = itemsToScroll * getItemDimension() - mScrollingOffset;
   onScrollTouched(); // we have to emulate touch when scrolling spinnerwheel programmatically to
                      // light up stuff
   mScroller.scroll(distance, time);
 }