java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ com.droidux.pack.wheel.widget.WheelCarousel

Class Overview

A custom view that presents a list of items on a 3D carousel-like control and lets the user pick among them. The items in the carousel come from the SpinnerAdapter associated with this view.

Summary

XML Attributes
Attribute Name Related Method Description
dux_animationDuration Sets how long a transition animation should run (in milliseconds) when layout has changed. 
dux_effectStrength setEffectStrength(float) Specifies the strength of the effect to be apply to the view (see the dux_effectType attribute). 
dux_effectType setEffectType(int) Specifies the effect to be applied to the view. 
dux_floorGap setFloorGap(int) Specifies the distance from the bottom of the reflected view to the "floor". 
dux_reflected setReflected(boolean) Controls whether the view should be reflected. 
dux_reflectionHeight setReflectionHeightFactor(float) Specifies the factor to determine the reflection height. 
dux_reflectionStrength setReflectionStrength(float) Specifies the strength of the reflection. 
dux_tiltAngle Specifies the tilt angle (in degrees) of a wheel carousel. 
[Expand]
Inherited Constants
From class android.view.ViewGroup
From class android.view.View
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
WheelCarousel(Context context)
WheelCarousel(Context context, AttributeSet attrs)
WheelCarousel(Context context, AttributeSet attrs, int defStyle)
Public Methods
View asView()
Convert this interface to its corresponding View.
SpinnerAdapter getAdapter()
Returs the adapter currently associated with this widget.
float getEffectStrength()
Gets the strength of the effect to be applied to the view returned by the adapter.
int getEffectType()
Gets the type of the effect to be applied to the view returned by the adapter.
int getFloorGap()
Gets the distance between the bottom of the view to the 'floor' in a reflected view.
WheelInterfaces.Listeners.OnWheelItemClickListener getOnWheelItemClickListener()
Gets the item-click listener registered for this view.
WheelInterfaces.Listeners.OnWheelItemSelectedListener getOnWheelItemSelectedListener()
Gets the item-selected listener registered for this view.
WheelInterfaces.Listeners.OnWheelScrollListener getOnWheelScrollListener()
Gets the scroll listener registered for this view.
float getReflectionHeightFactor()
Gets the factor to calculate the reflection height.
float getReflectionStrength()
Gets the strength of the reflection in a reflected view.
View getSelectedView()
Gets the currently selected view.
int getSelection()
Gets the position of the currently selected item in the data set.
boolean isReflected()
Returns whether the view is reflected.
void setAdapter(SpinnerAdapter adapter)
The Adapter is used to provide the data which backs this Spinner.
void setAnimationDuration(int duration)
void setCallbackDuringFling(boolean shouldCallback)
Whether or not to callback on any listener while the items are being flinged.
void setCallbackOnUnselectedItemClick(boolean shouldCallback)
Whether or not to callback when an item that is not selected is clicked.
void setEffectStrength(float effectStrength)
Sets the strength of the effect to be applied to the view returned by the adapter.
void setEffectType(int effectType)
Sets the type of the effect to be applied to the view returned by the adapter.
void setFloorGap(int floorGap)
Sets the distance between the bottom of the view to the 'floor' in a reflected view.
void setInterpolator(Interpolator interp)
Sets the interpolator for use by the internal scroller.
void setOnWheelItemClickListener(WheelInterfaces.Listeners.OnWheelItemClickListener listener)
Registers a listener to be notified when the wheel is scrolled.
void setOnWheelItemSelectedListener(WheelInterfaces.Listeners.OnWheelItemSelectedListener listener)
Registers a listener to be notified when an item is selected.
void setOnWheelScrollListener(WheelInterfaces.Listeners.OnWheelScrollListener listener)
Registers a listener to be notified when the wheel is scrolled.
void setReflected(boolean reflected)
Sets whether the view should be reflected.
void setReflectionHeightFactor(float factor)
Sets the factor to calculate the reflection height.
void setReflectionStrength(float strength)
Sets the strength of the reflection in a reflected view.
void setSelection(int position, int animationDuration)
Sets the currently selected item, with option to animate the change.
void setSelection(int position)
Sets the currently selected item.
void setSelection(int position, boolean animated)
Sets the currently selected item, with option to animate the change.
Protected Methods
void dispatchDraw(Canvas canvas)
Called by draw to draw the child views.
boolean drawChild(Canvas canvas, View child, long drawingTime)
Draw one child of this View Group.
boolean getChildStaticTransformation(View child, Transformation t)
Sets t to be the static transformation of the child, if set, returning a boolean to indicate whether a static transform was set.
void onDetachedFromWindow()
This is called when the view is detached from a window.
void onLayout(boolean changed, int left, int top, int right, int bottom)
Called from layout when this view should assign a size and position to each of its children.
void onMeasure(int widthMeasureSpec, int heightMeasureSpec)

Measure the view and its content to determine the measured width and the measured height.

[Expand]
Inherited Methods
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.GestureDetector.OnGestureListener
From interface android.view.KeyEvent.Callback
From interface android.view.ViewManager
From interface android.view.ViewParent
From interface android.view.accessibility.AccessibilityEventSource
From interface com.droidux.pack.wheel.interfaces.WheelInterfaces.Views.WheelCarouselInterface
From interface com.droidux.pack.wheel.interfaces.WheelInterfaces.Views.WheelViewInterface

XML Attributes

dux_animationDuration

Since: API Level

Sets how long a transition animation should run (in milliseconds) when layout has changed. Only relevant if animation is turned on.

Must be an integer value, such as "100".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

Related Methods

dux_effectStrength

Since: API Level

Specifies the strength of the effect to be apply to the view (see the dux_effectType attribute). Should be between 0.0 - 1.0 inclusive.

Related Methods

dux_effectType

Since: API Level

Specifies the effect to be applied to the view.

Must be one of the following constant values.

ConstantValueDescription
none0 Don't apply any effect.
dim1 Apply a dim effect. The dim effect will make the view appears darker.
fade2 Apply a fade effect. The fade effect will change the opacity/alpha of the view.

Related Methods

dux_floorGap

Since: API Level

Specifies the distance from the bottom of the reflected view to the "floor". Its value should be a dimension (such as "5dip").

Must be a dimension value, which is a floating point number appended with a unit such as "2.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), mm (millimeters).

Related Methods

dux_reflected

Since: API Level

Controls whether the view should be reflected.

Must be a boolean value, either "true" or "false".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

Related Methods

dux_reflectionHeight

Since: API Level

Specifies the factor to determine the reflection height. The reflection height will be the specified factor multiplied by the view's getHeight(). Should be between 0.0 - 1.0 inclusive.

dux_reflectionStrength

Since: API Level

Specifies the strength of the reflection. This value is a factor that determines the opacity/alpha of the reflection. Should be between 0.0 - 1.0 inclusive.

dux_tiltAngle

Since: API Level

Specifies the tilt angle (in degrees) of a wheel carousel. Default is 10.0f. Maximum value is 30.0f.

Must be a floating point value, such as "12.5".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

Related Methods

Public Constructors

public WheelCarousel (Context context)

Since: API Level 2.5

public WheelCarousel (Context context, AttributeSet attrs)

Since: API Level 2.5

public WheelCarousel (Context context, AttributeSet attrs, int defStyle)

Since: API Level 2.5

Public Methods

public View asView ()

Since: API Level 2.5

Convert this interface to its corresponding View.

Returns
  • A view object that corresponds to this interface.

public SpinnerAdapter getAdapter ()

Since: API Level 2.5

Returs the adapter currently associated with this widget.

Returns
  • The adapter used to provide this view's content.

public float getEffectStrength ()

Since: API Level 2.5

Gets the strength of the effect to be applied to the view returned by the adapter.

Related XML Attributes
Returns
  • The effect strength

public int getEffectType ()

Since: API Level 2.5

Gets the type of the effect to be applied to the view returned by the adapter.

Related XML Attributes
Returns
  • effectType The type of the effect.

public int getFloorGap ()

Since: API Level 2.5

Gets the distance between the bottom of the view to the 'floor' in a reflected view.

Related XML Attributes
Returns
  • The floor gap.

public WheelInterfaces.Listeners.OnWheelItemClickListener getOnWheelItemClickListener ()

Since: API Level 2.5

Gets the item-click listener registered for this view.

Returns
  • The listener.

public WheelInterfaces.Listeners.OnWheelItemSelectedListener getOnWheelItemSelectedListener ()

Since: API Level 2.5

Gets the item-selected listener registered for this view.

Returns
  • The listener.

public WheelInterfaces.Listeners.OnWheelScrollListener getOnWheelScrollListener ()

Since: API Level 2.5

Gets the scroll listener registered for this view.

Returns
  • The listener.

public float getReflectionHeightFactor ()

Since: API Level 2.5

Gets the factor to calculate the reflection height. The reflection height is the factor multiply by the view's height.

Related XML Attributes
Returns
  • The reflection height factor.

public float getReflectionStrength ()

Since: API Level 2.5

Gets the strength of the reflection in a reflected view.

Related XML Attributes
Returns
  • The reflection strength

public View getSelectedView ()

Since: API Level 2.5

Gets the currently selected view.

Returns
  • The view corresponding to the currently selected item, or null if nothing is selected.

public int getSelection ()

Since: API Level 2.5

Gets the position of the currently selected item in the data set.

Returns
  • The position of the currently selected item in the data set.

public boolean isReflected ()

Since: API Level 2.5

Returns whether the view is reflected.

Related XML Attributes
Returns
  • whether the view is reflected.

public void setAdapter (SpinnerAdapter adapter)

Since: API Level 2.5

The Adapter is used to provide the data which backs this Spinner. It also provides methods to transform spinner items based on their position relative to the selected item.

Parameters
adapter The adapter to use for this spinner.

public void setAnimationDuration (int duration)

Since: API Level 2.5

public void setCallbackDuringFling (boolean shouldCallback)

Since: API Level 2.5

Whether or not to callback on any listener while the items are being flinged. If false only the final selected item will cause the callback. If true, all items between the first and the final will cause callbacks.

Parameters
shouldCallback Whether or not to callback on the listener while the items are being flinged.

public void setCallbackOnUnselectedItemClick (boolean shouldCallback)

Since: API Level 2.5

Whether or not to callback when an item that is not selected is clicked. If false, the item will become selected (and re-centered). If true, the getOnWheelItemClickListener() will get the callback.

Parameters
shouldCallback Whether or not to callback on the listener when an item that is not selected is clicked.

public void setEffectStrength (float effectStrength)

Since: API Level 2.5

Sets the strength of the effect to be applied to the view returned by the adapter.

Related XML Attributes
Parameters
effectStrength The effect strength; 0f-1f inclusive.

public void setEffectType (int effectType)

Since: API Level 2.5

Sets the type of the effect to be applied to the view returned by the adapter.

Related XML Attributes
Parameters
effectType The type of the effect.

public void setFloorGap (int floorGap)

Since: API Level 2.5

Sets the distance between the bottom of the view to the 'floor' in a reflected view.

Related XML Attributes
Parameters
floorGap The distance.

public void setInterpolator (Interpolator interp)

Since: API Level 2.5

Sets the interpolator for use by the internal scroller.

Parameters
interp The interpolator.

public void setOnWheelItemClickListener (WheelInterfaces.Listeners.OnWheelItemClickListener listener)

Since: API Level 2.5

Registers a listener to be notified when the wheel is scrolled.

Parameters
listener The listener to be notified.

public void setOnWheelItemSelectedListener (WheelInterfaces.Listeners.OnWheelItemSelectedListener listener)

Since: API Level 2.5

Registers a listener to be notified when an item is selected.

Parameters
listener The listener to be notified.

public void setOnWheelScrollListener (WheelInterfaces.Listeners.OnWheelScrollListener listener)

Since: API Level 2.5

Registers a listener to be notified when the wheel is scrolled.

Parameters
listener The listener to be notified.

public void setReflected (boolean reflected)

Since: API Level 2.5

Sets whether the view should be reflected.

Related XML Attributes

public void setReflectionHeightFactor (float factor)

Since: API Level 2.5

Sets the factor to calculate the reflection height. The reflection height is the factor multiply by the view's height.

Related XML Attributes
Parameters
factor The reflection height factor.

public void setReflectionStrength (float strength)

Since: API Level 2.5

Sets the strength of the reflection in a reflected view.

Related XML Attributes
Parameters
strength The reflection strength

public void setSelection (int position, int animationDuration)

Since: API Level 2.5

Sets the currently selected item, with option to animate the change. If the position is less than 0, then the item at position 0 will be selected.

Parameters
position Index (starting at 0) of the data item to be selected.
animationDuration If greater than 0, the change will be animated for the duration (by spinning the wheel).

public void setSelection (int position)

Since: API Level 2.5

Sets the currently selected item. If the position is less than 0, then the item at position 0 will be selected.

Parameters
position Index (starting at 0) of the data item to be selected.

public void setSelection (int position, boolean animated)

Since: API Level 2.5

Sets the currently selected item, with option to animate the change. If the position is less than 0, then the item at position 0 will be selected.

Parameters
position Index (starting at 0) of the data item to be selected.
animated If true, the change will be animated (by spinning the wheel).

Protected Methods

protected void dispatchDraw (Canvas canvas)

Since: API Level

Called by draw to draw the child views. This may be overridden by derived classes to gain control just before its children are drawn (but after its own view has been drawn).

Parameters
canvas the canvas on which to draw the view

protected boolean drawChild (Canvas canvas, View child, long drawingTime)

Since: API Level

Draw one child of this View Group. This method is responsible for getting the canvas in the right state. This includes clipping, translating so that the child's scrolled origin is at 0, 0, and applying any animation transformations.

Parameters
canvas The canvas on which to draw the child
child Who to draw
drawingTime The time at which draw is occurring
Returns
  • True if an invalidate() was issued

protected boolean getChildStaticTransformation (View child, Transformation t)

Since: API Level

Sets t to be the static transformation of the child, if set, returning a boolean to indicate whether a static transform was set. The default implementation simply returns false; subclasses may override this method for different behavior. setStaticTransformationsEnabled(boolean) must be set to true for this method to be called.

Parameters
child The child view whose static transform is being requested
t The Transformation which will hold the result
Returns
  • true if the transformation was set, false otherwise

protected void onDetachedFromWindow ()

Since: API Level

This is called when the view is detached from a window. At this point it no longer has a surface for drawing.

protected void onLayout (boolean changed, int left, int top, int right, int bottom)

Since: API Level 2.5

Called from layout when this view should assign a size and position to each of its children. Derived classes with children should override this method and call layout on each of their children.

Parameters
changed This is a new size or position for this view
left Left position, relative to parent
top Top position, relative to parent
right Right position, relative to parent
bottom Bottom position, relative to parent

protected void onMeasure (int widthMeasureSpec, int heightMeasureSpec)

Since: API Level

Measure the view and its content to determine the measured width and the measured height. This method is invoked by measure(int, int) and should be overriden by subclasses to provide accurate and efficient measurement of their contents.

CONTRACT: When overriding this method, you must call setMeasuredDimension(int, int) to store the measured width and height of this view. Failure to do so will trigger an IllegalStateException, thrown by measure(int, int). Calling the superclass' onMeasure(int, int) is a valid use.

The base class implementation of measure defaults to the background size, unless a larger size is allowed by the MeasureSpec. Subclasses should override onMeasure(int, int) to provide better measurements of their content.

If this method is overridden, it is the subclass's responsibility to make sure the measured height and width are at least the view's minimum height and width (getSuggestedMinimumHeight() and getSuggestedMinimumWidth()).

Parameters
widthMeasureSpec horizontal space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.
heightMeasureSpec vertical space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.