kankan.wheel.widget.adapters
Class AbstractWheelTextAdapter

java.lang.Object
  extended by kankan.wheel.widget.adapters.AbstractWheelAdapter
      extended by kankan.wheel.widget.adapters.AbstractWheelTextAdapter
All Implemented Interfaces:
WheelViewAdapter
Direct Known Subclasses:
AdapterWheel, ArrayWheelAdapter, NumericWheelAdapter

public abstract class AbstractWheelTextAdapter
extends AbstractWheelAdapter

Abstract wheel adapter provides common functionality for adapters.


Field Summary
protected  Context context
           
static int DEFAULT_TEXT_COLOR
          Default text color
static int DEFAULT_TEXT_SIZE
          Default text size
protected  int emptyItemResourceId
           
protected  LayoutInflater inflater
           
protected  int itemResourceId
           
protected  int itemTextResourceId
           
static int LABEL_COLOR
          Default text color
protected static int NO_RESOURCE
          No resource constant.
static int TEXT_VIEW_ITEM_RESOURCE
          Text view resource.
private  int textColor
           
private  int textSize
           
 
Constructor Summary
protected AbstractWheelTextAdapter(Context context)
          Constructor
protected AbstractWheelTextAdapter(Context context, int itemResource)
          Constructor
protected AbstractWheelTextAdapter(Context context, int itemResource, int itemTextResource)
          Constructor
 
Method Summary
protected  void configureTextView(TextView view)
          Configures text view.
 View getEmptyItem(View convertView, ViewGroup parent)
          Get a View that displays an empty wheel item placed before the first or after the last wheel item.
 int getEmptyItemResource()
          Gets resource Id for empty items views
 View getItem(int index, View convertView, ViewGroup parent)
          Get a View that displays the data at the specified position in the data set
 int getItemResource()
          Gets resource Id for items views
protected abstract  java.lang.CharSequence getItemText(int index)
          Returns text for specified item
 int getItemTextResource()
          Gets resource Id for text view in item layout
 int getTextColor()
          Gets text color
 int getTextSize()
          Gets text size
private  TextView getTextView(View view, int textResource)
          Loads a text view from view
private  View getView(int resource, ViewGroup parent)
          Loads view from resources
 void setEmptyItemResource(int emptyItemResourceId)
          Sets resource Id for empty items views
 void setItemResource(int itemResourceId)
          Sets resource Id for items views
 void setItemTextResource(int itemTextResourceId)
          Sets resource Id for text view in item layout
 void setTextColor(int textColor)
          Sets text color
 void setTextSize(int textSize)
          Sets text size
 
Methods inherited from class kankan.wheel.widget.adapters.AbstractWheelAdapter
notifyDataChangedEvent, notifyDataInvalidatedEvent, registerDataSetObserver, unregisterDataSetObserver
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface kankan.wheel.widget.adapters.WheelViewAdapter
getItemsCount
 

Field Detail

TEXT_VIEW_ITEM_RESOURCE

public static final int TEXT_VIEW_ITEM_RESOURCE
Text view resource. Used as a default view for adapter.

See Also:
Constant Field Values

NO_RESOURCE

protected static final int NO_RESOURCE
No resource constant.

See Also:
Constant Field Values

DEFAULT_TEXT_COLOR

public static final int DEFAULT_TEXT_COLOR
Default text color

See Also:
Constant Field Values

LABEL_COLOR

public static final int LABEL_COLOR
Default text color

See Also:
Constant Field Values

DEFAULT_TEXT_SIZE

public static final int DEFAULT_TEXT_SIZE
Default text size

See Also:
Constant Field Values

textColor

private int textColor

textSize

private int textSize

context

protected Context context

inflater

protected LayoutInflater inflater

itemResourceId

protected int itemResourceId

itemTextResourceId

protected int itemTextResourceId

emptyItemResourceId

protected int emptyItemResourceId
Constructor Detail

AbstractWheelTextAdapter

protected AbstractWheelTextAdapter(Context context)
Constructor

Parameters:
context - the current context

AbstractWheelTextAdapter

protected AbstractWheelTextAdapter(Context context,
                                   int itemResource)
Constructor

Parameters:
context - the current context
itemResource - the resource ID for a layout file containing a TextView to use when instantiating items views

AbstractWheelTextAdapter

protected AbstractWheelTextAdapter(Context context,
                                   int itemResource,
                                   int itemTextResource)
Constructor

Parameters:
context - the current context
itemResource - the resource ID for a layout file containing a TextView to use when instantiating items views
itemTextResource - the resource ID for a text view in the item layout
Method Detail

getTextColor

public int getTextColor()
Gets text color

Returns:
the text color

setTextColor

public void setTextColor(int textColor)
Sets text color

Parameters:
textColor - the text color to set

getTextSize

public int getTextSize()
Gets text size

Returns:
the text size

setTextSize

public void setTextSize(int textSize)
Sets text size

Parameters:
textSize - the text size to set

getItemResource

public int getItemResource()
Gets resource Id for items views

Returns:
the item resource Id

setItemResource

public void setItemResource(int itemResourceId)
Sets resource Id for items views

Parameters:
itemResourceId - the resource Id to set

getItemTextResource

public int getItemTextResource()
Gets resource Id for text view in item layout

Returns:
the item text resource Id

setItemTextResource

public void setItemTextResource(int itemTextResourceId)
Sets resource Id for text view in item layout

Parameters:
itemTextResourceId - the item text resource Id to set

getEmptyItemResource

public int getEmptyItemResource()
Gets resource Id for empty items views

Returns:
the empty item resource Id

setEmptyItemResource

public void setEmptyItemResource(int emptyItemResourceId)
Sets resource Id for empty items views

Parameters:
emptyItemResourceId - the empty item resource Id to set

getItemText

protected abstract java.lang.CharSequence getItemText(int index)
Returns text for specified item

Parameters:
index - the item index
Returns:
the text of specified items

getItem

public View getItem(int index,
                    View convertView,
                    ViewGroup parent)
Description copied from interface: WheelViewAdapter
Get a View that displays the data at the specified position in the data set

Parameters:
index - the item index
convertView - the old view to reuse if possible
parent - the parent that this view will eventually be attached to
Returns:
the wheel item View

getEmptyItem

public View getEmptyItem(View convertView,
                         ViewGroup parent)
Description copied from interface: WheelViewAdapter
Get a View that displays an empty wheel item placed before the first or after the last wheel item.

Specified by:
getEmptyItem in interface WheelViewAdapter
Overrides:
getEmptyItem in class AbstractWheelAdapter
Parameters:
convertView - the old view to reuse if possible
parent - the parent that this view will eventually be attached to
Returns:
the empty item View

configureTextView

protected void configureTextView(TextView view)
Configures text view. Is called for the TEXT_VIEW_ITEM_RESOURCE views.

Parameters:
view - the text view to be configured

getTextView

private TextView getTextView(View view,
                             int textResource)
Loads a text view from view

Parameters:
view - the text view or layout containing it
textResource - the text resource Id in layout
Returns:
the loaded text view

getView

private View getView(int resource,
                     ViewGroup parent)
Loads view from resources

Parameters:
resource - the resource Id
Returns:
the loaded view or null if resource is not set