DayViewDecorator

public abstract class DayViewDecorator


A decorator which allows customizing the day of month views within a MaterialDatePicker.

Summary

Public constructors

Public methods

ColorStateList
getBackgroundColor(
    Context context,
    int year,
    int month,
    int day,
    boolean valid,
    boolean selected
)

Override this method to return a custom color to be applied to the background drawable of the day view corresponding to the provided date.

Drawable
getCompoundDrawableBottom(
    Context context,
    int year,
    int month,
    int day,
    boolean valid,
    boolean selected
)

Override this method to return a bottom compound drawable for the day view corresponding to the provided date.

Drawable
getCompoundDrawableLeft(
    Context context,
    int year,
    int month,
    int day,
    boolean valid,
    boolean selected
)

Override this method to return a left compound drawable for the day view corresponding to the provided date.

Drawable
getCompoundDrawableRight(
    Context context,
    int year,
    int month,
    int day,
    boolean valid,
    boolean selected
)

Override this method to return a right compound drawable for the day view corresponding to the provided date.

Drawable
getCompoundDrawableTop(
    Context context,
    int year,
    int month,
    int day,
    boolean valid,
    boolean selected
)

Override this method to return a top compound drawable for the day view corresponding to the provided date.

CharSequence
getContentDescription(
    Context context,
    int year,
    int month,
    int day,
    boolean valid,
    boolean selected,
    CharSequence originalContentDescription
)

Override this method to return the day view's content description.

ColorStateList
getTextColor(
    Context context,
    int year,
    int month,
    int day,
    boolean valid,
    boolean selected
)

Override this method to return a custom color to be applied to the text of the day view corresponding to the provided date.

void
initialize(Context context)

Optionally override this method to do any initializing for your DayViewDecorator instance.

Public constructors

DayViewDecorator

public DayViewDecorator()

Public methods

getBackgroundColor

public ColorStateList getBackgroundColor(
    Context context,
    int year,
    int month,
    int day,
    boolean valid,
    boolean selected
)

Override this method to return a custom color to be applied to the background drawable of the day view corresponding to the provided date.

Parameters
Context context

The context of the day view

int year

The year number corresponding to the day view (see YEAR)

int month

The month number (0-11) corresponding to the day view (see MONTH)

int day

The day of month number corresponding to the day view (see DAY_OF_MONTH)

boolean valid

Boolean for whether the day view is in a valid state (if not valid, the day view will likely look and behave disabled)

boolean selected

Boolean for whether the day view is in a selected state (if selected, the day view will likely have a filled color background)

Returns
ColorStateList

The background color ColorStateList or null

getCompoundDrawableBottom

public Drawable getCompoundDrawableBottom(
    Context context,
    int year,
    int month,
    int day,
    boolean valid,
    boolean selected
)

Override this method to return a bottom compound drawable for the day view corresponding to the provided date.

Parameters
Context context

The context of the day view

int year

The year number corresponding to the day view (see YEAR)

int month

The month number (0-11) corresponding to the day view (see MONTH)

int day

The day of month number corresponding to the day view (see DAY_OF_MONTH)

boolean valid

Boolean for whether the day view is in a valid state (if not valid, the day view will likely look and behave disabled)

boolean selected

Boolean for whether the day view is in a selected state (if selected, the day view will likely have a filled color background)

Returns
Drawable

The bottom compound drawable or null

getCompoundDrawableLeft

public Drawable getCompoundDrawableLeft(
    Context context,
    int year,
    int month,
    int day,
    boolean valid,
    boolean selected
)

Override this method to return a left compound drawable for the day view corresponding to the provided date.

Parameters
Context context

The context of the day view

int year

The year number corresponding to the day view (see YEAR)

int month

The month number (0-11) corresponding to the day view (see MONTH)

int day

The day of month number corresponding to the day view (see DAY_OF_MONTH)

boolean valid

Boolean for whether the day view is in a valid state (if not valid, the day view will likely look and behave disabled)

boolean selected

Boolean for whether the day view is in a selected state (if selected, the day view will likely have a filled color background)

Returns
Drawable

The left compound drawable or null

getCompoundDrawableRight

public Drawable getCompoundDrawableRight(
    Context context,
    int year,
    int month,
    int day,
    boolean valid,
    boolean selected
)

Override this method to return a right compound drawable for the day view corresponding to the provided date.

Parameters
Context context

The context of the day view

int year

The year number corresponding to the day view (see YEAR)

int month

The month number (0-11) corresponding to the day view (see MONTH)

int day

The day of month number corresponding to the day view (see DAY_OF_MONTH)

boolean valid

Boolean for whether the day view is in a valid state (if not valid, the day view will likely look and behave disabled)

boolean selected

Boolean for whether the day view is in a selected state (if selected, the day view will likely have a filled color background)

Returns
Drawable

The right compound drawable or null

getCompoundDrawableTop

public Drawable getCompoundDrawableTop(
    Context context,
    int year,
    int month,
    int day,
    boolean valid,
    boolean selected
)

Override this method to return a top compound drawable for the day view corresponding to the provided date.

Parameters
Context context

The context of the day view

int year

The year number corresponding to the day view (see YEAR)

int month

The month number (0-11) corresponding to the day view (see MONTH)

int day

The day of month number corresponding to the day view (see DAY_OF_MONTH)

boolean valid

Boolean for whether the day view is in a valid state (if not valid, the day view will likely look and behave disabled)

boolean selected

Boolean for whether the day view is in a selected state (if selected, the day view will likely have a filled color background)

Returns
Drawable

The top compound drawable or null

getContentDescription

public CharSequence getContentDescription(
    Context context,
    int year,
    int month,
    int day,
    boolean valid,
    boolean selected,
    CharSequence originalContentDescription
)

Override this method to return the day view's content description.

Parameters
Context context

The context of the day view

int year

The year number corresponding to the day view (see YEAR)

int month

The month number (0-11) corresponding to the day view (see MONTH)

int day

The day of month number corresponding to the day view (see DAY_OF_MONTH)

boolean valid

Boolean for whether the day view is in a valid state (if not valid, the day view will likely look and behave disabled)

boolean selected

Boolean for whether the day view is in a selected state (if selected, the day view will likely have a filled color background)

CharSequence originalContentDescription

The original day view's content description

Returns
CharSequence

The content description

getTextColor

public ColorStateList getTextColor(
    Context context,
    int year,
    int month,
    int day,
    boolean valid,
    boolean selected
)

Override this method to return a custom color to be applied to the text of the day view corresponding to the provided date.

Parameters
Context context

The context of the day view

int year

The year number corresponding to the day view (see YEAR)

int month

The month number (0-11) corresponding to the day view (see MONTH)

int day

The day of month number corresponding to the day view (see DAY_OF_MONTH)

boolean valid

Boolean for whether the day view is in a valid state (if not valid, the day view will likely look and behave disabled)

boolean selected

Boolean for whether the day view is in a selected state (if selected, the day view will likely have a filled color background)

Returns
ColorStateList

The text color ColorStateList or null

initialize

public void initialize(Context context)

Optionally override this method to do any initializing for your DayViewDecorator instance.

This method will be called whenever the date picker view is created, which can be important if, e.g., your decorator's compound drawables are dependent on configurations such as screen orientation.