DotsPageIndicator

public class DotsPageIndicator
extends View implements GridViewPager.OnPageChangeListener, GridViewPager.OnAdapterChangeListener

java.lang.Object
   ↳ android.view.View
     ↳ android.support.wearable.view.DotsPageIndicator


This class is deprecated.
starting with Android Wear 2.0 we no longer encourage bi-directional spacial models for apps. If you are looking to implement vertical paging pattern, consider using the SnapHelper and a RecyclerView instead.

A page indicator for GridViewPager which identifies the current page in relation to all available pages on the current row. Pages are represented as dots. The current page can be highlighted with a different color or size dot.

The default behavior is to fade out the dots when the pager is idle (not settling or being dragged). This can be changed with setDotFadeWhenIdle(boolean).

Use setPager(GridViewPager) to connect this view to a pager instance.

Summary

Inherited constants

From class android.view.View

Inherited fields

From class android.view.View

Public constructors

DotsPageIndicator(Context context)
DotsPageIndicator(Context context, AttributeSet attrs)
DotsPageIndicator(Context context, AttributeSet attrs, int defStyleAttr)

Public methods

int getDotColor()

Returns the color used for dots other than the selected page.

int getDotColorSelected()

Returns the color of the dot for the selected page.

int getDotFadeInDuration()

Returns the duration of the fade in duration, in milliseconds.

int getDotFadeOutDelay()

Sets the delay between the pager arriving at an idle state, and the fade out animation beginning, in milliseconds.

int getDotFadeOutDuration()

Returns the duration of fade out animation, in milliseconds.

boolean getDotFadeWhenIdle()

Indicates if the dots fade out when the pager is idle.

float getDotRadius()

Gets the radius of the page dots.

float getDotRadiusSelected()

Gets the radius of the page dot for the selected page.

int getDotShadowColor()

Returns the color of the shadows drawn beneath the dots.

float getDotShadowDx()

Returns the horizontal offset of shadows drawn beneath the dots.

float getDotShadowDy()

Returns the vertical offset of shadows drawn beneath the dots.

float getDotShadowRadius()

Sets the pixel radius of shadows drawn beneath the dots.

float getDotSpacing()

Gets the center-to-center distance between page dots.

void onAdapterChanged(GridPagerAdapter oldAdapter, GridPagerAdapter newAdapter)

Called when the adapter is changed with setAdapter(GridPagerAdapter).

void onDataSetChanged()

Called when a change is made to the content of the current adapter.

void onPageScrollStateChanged(int state)

Called when the scroll state changes.

void onPageScrolled(int row, int column, float rowOffset, float columnOffset, int rowOffsetPixels, int columnOffsetPixels)

This method will be invoked when the current page is scrolled, either as part of a programmatically initiated smooth scroll or a user initiated touch scroll.

void onPageSelected(int row, int column)

This method is called when a new page becomes selected.

void setDotColor(int color)

Sets the color used for dots other than the selected page.

void setDotColorSelected(int color)

Sets the color of the dot for the selected page.

void setDotFadeInDuration(int duration, TimeUnit unit)

Sets the duration of the fade in animation.

void setDotFadeOutDelay(int delay)

Sets the delay between the pager arriving at an idle state, and the fade out animation beginning, in milliseconds.

void setDotFadeOutDuration(int duration, TimeUnit unit)

Sets the duration of the fade out animation.

void setDotFadeWhenIdle(boolean fade)

Sets whether the dots fade out when the pager is idle.

void setDotRadius(int radius)

Sets the radius of the page dots.

void setDotRadiusSelected(int radius)

Sets the radius of the page dot for the selected page.

void setDotShadowColor(int color)

Sets the color of the shadows drawn beneath the dots.

void setDotShadowDx(float dx)

Sets the horizontal offset of shadows drawn beneath the dots.

void setDotShadowDy(float dy)

Sets the vertical offset of shadows drawn beneath the dots.

void setDotShadowRadius(float radius)

Sets the pixel radius of shadows drawn beneath the dots.

void setDotSpacing(int spacing)

Sets the center-to-center distance between page dots.

void setOnAdapterChangeListener(GridViewPager.OnAdapterChangeListener listener)

Sets a listener to receive the adapter change events that are provided to the page indicator.

void setOnPageChangeListener(GridViewPager.OnPageChangeListener listener)

Sets a listener to receive the page change events that are provided to the page indicator.

void setPager(GridViewPager pager)

Supplies the GridViewPager instance, and attaches this views GridViewPager.OnPageChangeListener and GridViewPager.OnAdapterChangeListener listeners to the pager.

Protected methods

void onDraw(Canvas canvas)
void onMeasure(int widthMeasureSpec, int heightMeasureSpec)

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
From interface android.support.wearable.view.GridViewPager.OnPageChangeListener
From interface android.support.wearable.view.GridViewPager.OnAdapterChangeListener

Public constructors

DotsPageIndicator

DotsPageIndicator (Context context)

Parameters
context Context

DotsPageIndicator

DotsPageIndicator (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

DotsPageIndicator

DotsPageIndicator (Context context, 
                AttributeSet attrs, 
                int defStyleAttr)

Parameters
context Context

attrs AttributeSet

defStyleAttr int

Public methods

getDotColor

int getDotColor ()

Returns the color used for dots other than the selected page.

Returns
int color the color used for dots other than the selected page

getDotColorSelected

int getDotColorSelected ()

Returns the color of the dot for the selected page.

Returns
int the color used for the selected page dot

getDotFadeInDuration

int getDotFadeInDuration ()

Returns the duration of the fade in duration, in milliseconds.

Returns
int the duration of the fade in duration, in milliseconds

getDotFadeOutDelay

int getDotFadeOutDelay ()

Sets the delay between the pager arriving at an idle state, and the fade out animation beginning, in milliseconds.

Returns
int the delay before the fade out animation begins, in milliseconds

getDotFadeOutDuration

int getDotFadeOutDuration ()

Returns the duration of fade out animation, in milliseconds.

Returns
int the duration of the fade out animation, in milliseconds

getDotFadeWhenIdle

boolean getDotFadeWhenIdle ()

Indicates if the dots fade out when the pager is idle.

Returns
boolean whether the dots fade out when idle

getDotRadius

float getDotRadius ()

Gets the radius of the page dots.

Returns
float the radius of the page dots

getDotRadiusSelected

float getDotRadiusSelected ()

Gets the radius of the page dot for the selected page.

Returns
float the radius of the selected page dot

getDotShadowColor

int getDotShadowColor ()

Returns the color of the shadows drawn beneath the dots.

Returns
int the color of the shadows drawn beneath the dots

getDotShadowDx

float getDotShadowDx ()

Returns the horizontal offset of shadows drawn beneath the dots.

Returns
float the horizontal offset of shadows drawn beneath the dots

getDotShadowDy

float getDotShadowDy ()

Returns the vertical offset of shadows drawn beneath the dots.

Returns
float the vertical offset of shadows drawn beneath the dots

getDotShadowRadius

float getDotShadowRadius ()

Sets the pixel radius of shadows drawn beneath the dots.

Returns
float the pixel radius of shadows rendered beneath the dots

getDotSpacing

float getDotSpacing ()

Gets the center-to-center distance between page dots.

Returns
float the distance between page dots

onAdapterChanged

void onAdapterChanged (GridPagerAdapter oldAdapter, 
                GridPagerAdapter newAdapter)

Called when the adapter is changed with setAdapter(GridPagerAdapter).

Parameters
oldAdapter GridPagerAdapter

newAdapter GridPagerAdapter

onDataSetChanged

void onDataSetChanged ()

Called when a change is made to the content of the current adapter.

onPageScrollStateChanged

void onPageScrollStateChanged (int state)

Called when the scroll state changes. Useful for discovering when the user begins dragging, when the pager is automatically settling to the current page, or when it is fully stopped/idle.

Parameters
state int: The new scroll state.

onPageScrolled

void onPageScrolled (int row, 
                int column, 
                float rowOffset, 
                float columnOffset, 
                int rowOffsetPixels, 
                int columnOffsetPixels)

This method will be invoked when the current page is scrolled, either as part of a programmatically initiated smooth scroll or a user initiated touch scroll.

Parameters
row int: Vertical position index of the new selected page row position+1 will be visible if positionOffset is nonzero

column int: Horizontal position index of the new selected page

rowOffset float: Value from [0, 1) indicating the offset from the row

columnOffset float: Value from [0, 1) indicating the offset from the column

rowOffsetPixels int: Value in pixels indicating the offset from row

columnOffsetPixels int: Value in pixels indicating the offset from column

onPageSelected

void onPageSelected (int row, 
                int column)

This method is called when a new page becomes selected. The page may still be settling into final position.

Parameters
row int: Vertical position index of the new selected page

column int: Horizontal position index of the new selected page

setDotColor

void setDotColor (int color)

Sets the color used for dots other than the selected page.

Parameters
color int: the color used for dots other than the selected page

setDotColorSelected

void setDotColorSelected (int color)

Sets the color of the dot for the selected page.

Parameters
color int: the color of the dot for the selected page

setDotFadeInDuration

void setDotFadeInDuration (int duration, 
                TimeUnit unit)

Sets the duration of the fade in animation.

Parameters
duration int: the duration of the fade in animation

unit TimeUnit

setDotFadeOutDelay

void setDotFadeOutDelay (int delay)

Sets the delay between the pager arriving at an idle state, and the fade out animation beginning, in milliseconds.

Parameters
delay int: the delay before the fade out animation begins, in milliseconds

setDotFadeOutDuration

void setDotFadeOutDuration (int duration, 
                TimeUnit unit)

Sets the duration of the fade out animation.

Parameters
duration int: the duration of the fade out animation

unit TimeUnit

setDotFadeWhenIdle

void setDotFadeWhenIdle (boolean fade)

Sets whether the dots fade out when the pager is idle.

Parameters
fade boolean: whether the dots fade out when idle

setDotRadius

void setDotRadius (int radius)

Sets the radius of the page dots.

Parameters
radius int: the radius of the page dots

setDotRadiusSelected

void setDotRadiusSelected (int radius)

Sets the radius of the page dot for the selected page.

Parameters
radius int: the radius of the selected page dot

setDotShadowColor

void setDotShadowColor (int color)

Sets the color of the shadows drawn beneath the dots.

Parameters
color int: the color of the shadows drawn beneath the dots

setDotShadowDx

void setDotShadowDx (float dx)

Sets the horizontal offset of shadows drawn beneath the dots.

Parameters
dx float: the horizontal offset of shadows drawn beneath the dots

setDotShadowDy

void setDotShadowDy (float dy)

Sets the vertical offset of shadows drawn beneath the dots.

Parameters
dy float: the vertical offset of shadows drawn beneath the dots

setDotShadowRadius

void setDotShadowRadius (float radius)

Sets the pixel radius of shadows drawn beneath the dots.

Parameters
radius float: the pixel radius of shadows rendered beneath the dots

setDotSpacing

void setDotSpacing (int spacing)

Sets the center-to-center distance between page dots.

Parameters
spacing int: the distance between page dots

setOnAdapterChangeListener

void setOnAdapterChangeListener (GridViewPager.OnAdapterChangeListener listener)

Sets a listener to receive the adapter change events that are provided to the page indicator. This allows an additional component to respond to these events without the need for additional code.

Parameters
listener GridViewPager.OnAdapterChangeListener: the listener for adapter change events

setOnPageChangeListener

void setOnPageChangeListener (GridViewPager.OnPageChangeListener listener)

Sets a listener to receive the page change events that are provided to the page indicator. This allows an additional component to respond to these events without the need for additional code.

Parameters
listener GridViewPager.OnPageChangeListener: the listener for page change events

setPager

void setPager (GridViewPager pager)

Supplies the GridViewPager instance, and attaches this views GridViewPager.OnPageChangeListener and GridViewPager.OnAdapterChangeListener listeners to the pager.

Parameters
pager GridViewPager: the pager for the page indicator

Protected methods

onDraw

void onDraw (Canvas canvas)

Parameters
canvas Canvas

onMeasure

void onMeasure (int widthMeasureSpec, 
                int heightMeasureSpec)

Parameters
widthMeasureSpec int

heightMeasureSpec int