/** * Justifies wheel */ private void justify() { listener.onJustify(); setNextMessage(MESSAGE_JUSTIFY); }
/** * Initializes class data * @param context the context */ private void initData(Context context) { scroller = new WheelScroller(getContext(), scrollingListener); }
/** * 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); }
/** * Updates view. Rebuilds items and label if necessary, recalculate items sizes. */ private void updateView() { if (rebuildItems()) { calculateLayoutWidth(getWidth(), MeasureSpec.EXACTLY); layout(getWidth(), getHeight()); } }
/** * Sets the current item w/o animation. Does nothing when index is wrong. * * @param index the item index */ public void setCurrentItem(int index) { setCurrentItem(index, false); }
@Override 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(); } }
/** * Notifies listeners about ending scrolling */ protected void notifyScrollingListenersAboutEnd() { for (OnWheelScrollListener listener : scrollingListeners) { listener.onScrollingFinished(this); } }
/** * Notifies listeners about clicking */ protected void notifyClickListenersAboutClick(int item) { for (OnWheelClickedListener listener : clickingListeners) { listener.onItemClicked(this, item); } }
/** * Stops scrolling */ public void stopScrolling() { scroller.stopScrolling(); } }
@Override public void onInvalidated() { invalidateWheel(true); } };
/** * Sets the drawable for the wheel background * @param resource */ public void setWheelBackground(int resource) { wheelBackground = resource; setBackgroundResource(wheelBackground); }
/** * Notifies listeners about starting scrolling */ protected void notifyScrollingListenersAboutStart() { for (OnWheelScrollListener listener : scrollingListeners) { listener.onScrollingStarted(this); } }
/** * Gets empty item view * @return the cached empty view */ public View getEmptyItem() { return getCachedView(emptyItems); }
/** * Justifies wheel */ private void justify() { listener.onJustify(); setNextMessage(MESSAGE_JUSTIFY); }
/** * Initializes class data * * @param context * the context */ private void initData(Context context) { scroller = new WheelScroller(getContext(), scrollingListener); }
/** * 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); }
@Override 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(); } }
/** * Notifies listeners about ending scrolling */ protected void notifyScrollingListenersAboutEnd() { for (OnWheelScrollListener listener : scrollingListeners) { listener.onScrollingFinished(this); } }