public class

RotarySelector

extends View
java.lang.Object
   ↳ android.view.View
     ↳ com.droidux.pack.commons.widget.RotarySelector

Class Overview

Custom view that presents up to two items that are selectable by rotating a semi-circle from left to right, or right to left. Used by incoming call screen, and the lock screen when no security pattern is set.

Summary

Nested Classes
interface RotarySelector.OnDialTriggerListener Interface definition for a callback to be invoked when the dial is "triggered" by rotating it one way or the other. 
XML Attributes
Attribute Name Related Method Description
android:orientation  
Constants
int LEFT_HANDLE_GRABBED The left handle is grabbed.
int NOTHING_GRABBED No handle is grabbed, either nothing has been grabbed yet, or a grabbed handle has been released.
int RIGHT_HANDLE_GRABBED The right handle is grabbed.
[Expand]
Inherited Constants
From class android.view.View
Fields
public static final int HORIZONTAL If the android:orientation attribute is set to this value, the view will have horizontal orientation.
public static final int VERTICAL If the android:orientation attribute is set to this value, the view will have vertical orientation.
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
RotarySelector(Context context)
RotarySelector(Context context, AttributeSet attrs)
Constructor used when this widget is created from a layout file.
Public Methods
boolean onTouchEvent(MotionEvent event)
Handle touch screen events.
void setLeftHandleResource(int resId)
Sets the left handle icon to a given resource.
void setOnDialTriggerListener(RotarySelector.OnDialTriggerListener l)
Registers a callback to be invoked when the dial is "triggered" by rotating it one way or the other.
void setRightHandleResource(int resId)
Sets the right handle icon to a given resource.
Protected Methods
void onDraw(Canvas canvas)
Implement this to do your drawing.
void onMeasure(int widthMeasureSpec, int heightMeasureSpec)

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

void onSizeChanged(int w, int h, int oldw, int oldh)
This is called during layout when the size of this view has changed.
[Expand]
Inherited Methods
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.accessibility.AccessibilityEventSource

XML Attributes

android:orientation

Since: API Level

Related Methods

Constants

public static final int LEFT_HANDLE_GRABBED

Since: API Level 2.5

The left handle is grabbed.

Constant Value: 1 (0x00000001)

public static final int NOTHING_GRABBED

Since: API Level 2.5

No handle is grabbed, either nothing has been grabbed yet, or a grabbed handle has been released.

Constant Value: 0 (0x00000000)

public static final int RIGHT_HANDLE_GRABBED

Since: API Level 2.5

The right handle is grabbed.

Constant Value: 2 (0x00000002)

Fields

public static final int HORIZONTAL

Since: API Level 2.5

If the android:orientation attribute is set to this value, the view will have horizontal orientation.

public static final int VERTICAL

Since: API Level 2.5

If the android:orientation attribute is set to this value, the view will have vertical orientation.

Public Constructors

public RotarySelector (Context context)

Since: API Level 2.5

public RotarySelector (Context context, AttributeSet attrs)

Since: API Level 2.5

Constructor used when this widget is created from a layout file.

Public Methods

public boolean onTouchEvent (MotionEvent event)

Since: API Level

Handle touch screen events.

Parameters
event The motion event.
Returns
  • True if the event was handled, false otherwise.

public void setLeftHandleResource (int resId)

Since: API Level 2.5

Sets the left handle icon to a given resource. The resource should refer to a Drawable object, or use 0 to remove the icon.

Parameters
resId the resource ID.

public void setOnDialTriggerListener (RotarySelector.OnDialTriggerListener l)

Since: API Level 2.5

Registers a callback to be invoked when the dial is "triggered" by rotating it one way or the other.

Parameters
l the OnDialTriggerListener to attach to this view

public void setRightHandleResource (int resId)

Since: API Level 2.5

Sets the right handle icon to a given resource. The resource should refer to a Drawable object, or use 0 to remove the icon.

Parameters
resId the resource ID.

Protected Methods

protected void onDraw (Canvas canvas)

Since: API Level

Implement this to do your drawing.

Parameters
canvas the canvas on which the background will be drawn

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.

protected void onSizeChanged (int w, int h, int oldw, int oldh)

Since: API Level

This is called during layout when the size of this view has changed. If you were just added to the view hierarchy, you're called with the old values of 0.

Parameters
w Current width of this view.
h Current height of this view.
oldw Old width of this view.
oldh Old height of this view.