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

Inherited fields

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 GridViewPager.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

Public constructors

DotsPageIndicator

public DotsPageIndicator (Context context)

Parameters
context Context

DotsPageIndicator

public DotsPageIndicator (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

DotsPageIndicator

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

Parameters
context Context

attrs AttributeSet

defStyleAttr int

Public methods

getDotColor

public 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

public int getDotColorSelected ()

Returns the color of the dot for the selected page.

Returns
int the color used for the selected page dot

getDotFadeInDuration

public int getDotFadeInDuration ()

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

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

getDotFadeOutDelay

public 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

public int getDotFadeOutDuration ()

Returns the duration of fade out animation, in milliseconds.

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

getDotFadeWhenIdle

public boolean getDotFadeWhenIdle ()

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

Returns
boolean whether the dots fade out when idle

getDotRadius

public float getDotRadius ()

Gets the radius of the page dots.

Returns
float the radius of the page dots

getDotRadiusSelected

public float getDotRadiusSelected ()

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

Returns
float the radius of the selected page dot

getDotShadowColor

public int getDotShadowColor ()

Returns the color of the shadows drawn beneath the dots.

Returns
int the color of the shadows drawn beneath the dots

getDotShadowDx

public float getDotShadowDx ()

Returns the horizontal offset of shadows drawn beneath the dots.

Returns
float the horizontal offset of shadows drawn beneath the dots

getDotShadowDy

public float getDotShadowDy ()

Returns the vertical offset of shadows drawn beneath the dots.

Returns
float the vertical offset of shadows drawn beneath the dots

getDotShadowRadius

public float getDotShadowRadius ()

Sets the pixel radius of shadows drawn beneath the dots.

Returns
float the pixel radius of shadows rendered beneath the dots

getDotSpacing

public float getDotSpacing ()

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

Returns
float the distance between page dots

onAdapterChanged

public void onAdapterChanged (GridPagerAdapter oldAdapter, 
                GridPagerAdapter newAdapter)

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

Parameters
oldAdapter GridPagerAdapter

newAdapter GridPagerAdapter

onDataSetChanged

public void onDataSetChanged ()

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

onPageScrollStateChanged

public 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

public 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

public 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

public 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

public 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

public 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

public 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

public 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

public 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

public void setDotRadius (int radius)

Sets the radius of the page dots.

Parameters
radius int: the radius of the page dots

setDotRadiusSelected

public 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

public 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

public 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

public 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

public 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

public void setDotSpacing (int spacing)

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

Parameters
spacing int: the distance between page dots

setOnAdapterChangeListener

public 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

public 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

public 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

protected void onDraw (Canvas canvas)

Parameters
canvas Canvas

onMeasure

protected void onMeasure (int widthMeasureSpec, 
                int heightMeasureSpec)

Parameters
widthMeasureSpec int

heightMeasureSpec int