|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectView
kankan.wheel.widget.WheelView
public class WheelView
Numeric wheel view.
Field Summary | |
---|---|
private GradientDrawable |
bottomShadow
|
private Drawable |
centerDrawable
|
private java.util.List<OnWheelChangedListener> |
changingListeners
|
private java.util.List<OnWheelClickedListener> |
clickingListeners
|
private int |
currentItem
|
private DataSetObserver |
dataObserver
|
private static int |
DEF_VISIBLE_ITEMS
Default count of visible items |
private int |
firstItem
|
(package private) boolean |
isCyclic
|
private boolean |
isScrollingPerformed
|
private static int |
ITEM_OFFSET_PERCENT
Top and bottom items offset (to hide that) |
private int |
itemHeight
|
private LinearLayout |
itemsLayout
|
private static int |
PADDING
Left and right padding value |
private WheelRecycle |
recycle
|
private WheelScroller |
scroller
|
(package private) WheelScroller.ScrollingListener |
scrollingListener
|
private java.util.List<OnWheelScrollListener> |
scrollingListeners
|
private int |
scrollingOffset
|
private static int[] |
SHADOWS_COLORS
Top and bottom shadows colors |
private GradientDrawable |
topShadow
|
private WheelViewAdapter |
viewAdapter
|
private int |
visibleItems
|
Constructor Summary | |
---|---|
WheelView(Context context)
Constructor |
|
WheelView(Context context,
AttributeSet attrs)
Constructor |
|
WheelView(Context context,
AttributeSet attrs,
int defStyle)
Constructor |
Method Summary | |
---|---|
void |
addChangingListener(OnWheelChangedListener listener)
Adds wheel changing listener |
void |
addClickingListener(OnWheelClickedListener listener)
Adds wheel clicking listener |
void |
addScrollingListener(OnWheelScrollListener listener)
Adds wheel scrolling listener |
private boolean |
addViewItem(int index,
boolean first)
Adds view for item to items layout |
private void |
buildViewForMeasuring()
Builds view for measuring |
private int |
calculateLayoutWidth(int widthSize,
int mode)
Calculates control width and creates text layouts |
private void |
createItemsLayout()
Creates item layouts if necessary |
private void |
doScroll(int delta)
Scrolls the wheel |
private void |
drawCenterRect(Canvas canvas)
Draws rect for current value |
private void |
drawItems(Canvas canvas)
Draws items |
private void |
drawShadows(Canvas canvas)
Draws shadows on top and bottom of control |
int |
getCurrentItem()
Gets current value |
private int |
getDesiredHeight(LinearLayout layout)
Calculates desired height for layout |
private int |
getItemHeight()
Returns height of wheel item |
private ItemsRange |
getItemsRange()
Calculates range for wheel items |
private View |
getItemView(int index)
Returns view for specified item |
WheelViewAdapter |
getViewAdapter()
Gets view adapter |
int |
getVisibleItems()
Gets count of visible items |
private void |
initData(Context context)
Initializes class data |
private void |
initResourcesIfNecessary()
Initializes resources |
void |
invalidateWheel(boolean clearCaches)
Invalidates wheel |
boolean |
isCyclic()
Tests if wheel is cyclic. |
private boolean |
isValidItemIndex(int index)
Checks whether intem index is valid |
private void |
layout(int width,
int height)
Sets layouts width and height |
protected void |
notifyChangingListeners(int oldValue,
int newValue)
Notifies changing listeners |
protected void |
notifyClickListenersAboutClick(int item)
Notifies listeners about clicking |
protected void |
notifyScrollingListenersAboutEnd()
Notifies listeners about ending scrolling |
protected void |
notifyScrollingListenersAboutStart()
Notifies listeners about starting scrolling |
protected void |
onDraw(Canvas canvas)
|
protected void |
onLayout(boolean changed,
int l,
int t,
int r,
int b)
|
protected void |
onMeasure(int widthMeasureSpec,
int heightMeasureSpec)
|
boolean |
onTouchEvent(MotionEvent event)
|
private boolean |
rebuildItems()
Rebuilds wheel items if necessary. |
void |
removeChangingListener(OnWheelChangedListener listener)
Removes wheel changing listener |
void |
removeClickingListener(OnWheelClickedListener listener)
Removes wheel clicking listener |
void |
removeScrollingListener(OnWheelScrollListener listener)
Removes wheel scrolling listener |
void |
scroll(int itemsToScroll,
int time)
Scroll the wheel |
void |
setCurrentItem(int index)
Sets the current item w/o animation. |
void |
setCurrentItem(int index,
boolean animated)
Sets the current item. |
void |
setCyclic(boolean isCyclic)
Set wheel cyclic flag |
void |
setInterpolator(Interpolator interpolator)
Set the the specified scrolling interpolator |
void |
setViewAdapter(WheelViewAdapter viewAdapter)
Sets view adapter. |
void |
setVisibleItems(int count)
Sets the desired count of visible items. |
void |
stopScrolling()
Stops scrolling |
private void |
updateView()
Updates view. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final int[] SHADOWS_COLORS
private static final int ITEM_OFFSET_PERCENT
private static final int PADDING
private static final int DEF_VISIBLE_ITEMS
private int currentItem
private int visibleItems
private int itemHeight
private Drawable centerDrawable
private GradientDrawable topShadow
private GradientDrawable bottomShadow
private WheelScroller scroller
private boolean isScrollingPerformed
private int scrollingOffset
boolean isCyclic
private LinearLayout itemsLayout
private int firstItem
private WheelViewAdapter viewAdapter
private WheelRecycle recycle
private java.util.List<OnWheelChangedListener> changingListeners
private java.util.List<OnWheelScrollListener> scrollingListeners
private java.util.List<OnWheelClickedListener> clickingListeners
WheelScroller.ScrollingListener scrollingListener
private DataSetObserver dataObserver
Constructor Detail |
---|
public WheelView(Context context, AttributeSet attrs, int defStyle)
public WheelView(Context context, AttributeSet attrs)
public WheelView(Context context)
Method Detail |
---|
private void initData(Context context)
context
- the contextpublic void setInterpolator(Interpolator interpolator)
interpolator
- the interpolatorpublic int getVisibleItems()
public void setVisibleItems(int count)
count
- the desired count for visible itemspublic WheelViewAdapter getViewAdapter()
public void setViewAdapter(WheelViewAdapter viewAdapter)
viewAdapter
- the view adapterpublic void addChangingListener(OnWheelChangedListener listener)
listener
- the listenerpublic void removeChangingListener(OnWheelChangedListener listener)
listener
- the listenerprotected void notifyChangingListeners(int oldValue, int newValue)
oldValue
- the old wheel valuenewValue
- the new wheel valuepublic void addScrollingListener(OnWheelScrollListener listener)
listener
- the listenerpublic void removeScrollingListener(OnWheelScrollListener listener)
listener
- the listenerprotected void notifyScrollingListenersAboutStart()
protected void notifyScrollingListenersAboutEnd()
public void addClickingListener(OnWheelClickedListener listener)
listener
- the listenerpublic void removeClickingListener(OnWheelClickedListener listener)
listener
- the listenerprotected void notifyClickListenersAboutClick(int item)
public int getCurrentItem()
public void setCurrentItem(int index, boolean animated)
index
- the item indexanimated
- the animation flagpublic void setCurrentItem(int index)
index
- the item indexpublic boolean isCyclic()
public void setCyclic(boolean isCyclic)
isCyclic
- the flag to setpublic void invalidateWheel(boolean clearCaches)
clearCaches
- if true then cached views will be clearprivate void initResourcesIfNecessary()
private int getDesiredHeight(LinearLayout layout)
layout
- the source layout
private int getItemHeight()
private int calculateLayoutWidth(int widthSize, int mode)
widthSize
- the input layout widthmode
- the layout mode
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
protected void onLayout(boolean changed, int l, int t, int r, int b)
private void layout(int width, int height)
width
- the layout widthheight
- the layout heightprotected void onDraw(Canvas canvas)
private void drawShadows(Canvas canvas)
canvas
- the canvas for drawingprivate void drawItems(Canvas canvas)
canvas
- the canvas for drawingprivate void drawCenterRect(Canvas canvas)
canvas
- the canvas for drawingpublic boolean onTouchEvent(MotionEvent event)
private void doScroll(int delta)
delta
- the scrolling valuepublic void scroll(int itemsToScroll, int time)
itemsToSkip
- items to scrolltime
- scrolling durationprivate ItemsRange getItemsRange()
private boolean rebuildItems()
private void updateView()
private void createItemsLayout()
private void buildViewForMeasuring()
private boolean addViewItem(int index, boolean first)
index
- the item indexfirst
- the flag indicates if view should be first
private boolean isValidItemIndex(int index)
index
- the item index
private View getItemView(int index)
index
- the item index
public void stopScrolling()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |