kankan.wheel.widget
Class WheelRecycle

java.lang.Object
  extended by kankan.wheel.widget.WheelRecycle

public class WheelRecycle
extends java.lang.Object

Recycle stores wheel items to reuse.


Field Summary
private  java.util.List<View> emptyItems
           
private  java.util.List<View> items
           
private  WheelView wheel
           
 
Constructor Summary
WheelRecycle(WheelView wheel)
          Constructor
 
Method Summary
private  java.util.List<View> addView(View view, java.util.List<View> cache)
          Adds view to specified cache.
 void clearAll()
          Clears all views
private  View getCachedView(java.util.List<View> cache)
          Gets view from specified cache.
 View getEmptyItem()
          Gets empty item view
 View getItem()
          Gets item view
 int recycleItems(LinearLayout layout, int firstItem, ItemsRange range)
          Recycles items from specified layout.
private  void recycleView(View view, int index)
          Adds view to cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

items

private java.util.List<View> items

emptyItems

private java.util.List<View> emptyItems

wheel

private WheelView wheel
Constructor Detail

WheelRecycle

public WheelRecycle(WheelView wheel)
Constructor

Parameters:
wheel - the wheel view
Method Detail

recycleItems

public int recycleItems(LinearLayout layout,
                        int firstItem,
                        ItemsRange range)
Recycles items from specified layout. There are saved only items not included to specified range. All the cached items are removed from original layout.

Parameters:
layout - the layout containing items to be cached
firstItem - the number of first item in layout
range - the range of current wheel items
Returns:
the new value of first item number

getItem

public View getItem()
Gets item view

Returns:
the cached view

getEmptyItem

public View getEmptyItem()
Gets empty item view

Returns:
the cached empty view

clearAll

public void clearAll()
Clears all views


addView

private java.util.List<View> addView(View view,
                                     java.util.List<View> cache)
Adds view to specified cache. Creates a cache list if it is null.

Parameters:
view - the view to be cached
cache - the cache list
Returns:
the cache list

recycleView

private void recycleView(View view,
                         int index)
Adds view to cache. Determines view type (item view or empty one) by index.

Parameters:
view - the view to be cached
index - the index of view

getCachedView

private View getCachedView(java.util.List<View> cache)
Gets view from specified cache.

Parameters:
cache - the cache
Returns:
the first view from cache.