// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/format/DayFormatter.java
// public interface DayFormatter {
// 
//   /**
//    * Default format for displaying the day.
//    */
//   String DEFAULT_FORMAT = "d";
// 
//   /**
//    * Default implementation used by {@linkplain com.prolificinteractive.materialcalendarview.MaterialCalendarView}
//    */
//   DayFormatter DEFAULT = new DateFormatDayFormatter();
// 
//   /**
//    * Format a given day into a string
//    *
//    * @param day the day
//    * @return a label for the day
//    */
//   @NonNull String format(@NonNull CalendarDay day);
// }
// 
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/MaterialCalendarView.java
// public static boolean showDecoratedDisabled(@ShowOtherDates int showOtherDates) {
//   return (showOtherDates & SHOW_DECORATED_DISABLED) != 0;
// }
// 
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/MaterialCalendarView.java
// public static boolean showOtherMonths(@ShowOtherDates int showOtherDates) {
//   return (showOtherDates & SHOW_OTHER_MONTHS) != 0;
// }
// 
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/MaterialCalendarView.java
// public static boolean showOutOfRange(@ShowOtherDates int showOtherDates) {
//   return (showOtherDates & SHOW_OUT_OF_RANGE) != 0;
// }


import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.RippleDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.StateListDrawable;
import android.graphics.drawable.shapes.OvalShape;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.v7.widget.AppCompatCheckedTextView;
import android.text.SpannableString;
import android.text.Spanned;
import android.view.Gravity;
import android.view.View;
import com.prolificinteractive.materialcalendarview.MaterialCalendarView.ShowOtherDates;
import com.prolificinteractive.materialcalendarview.format.DayFormatter;
import java.util.List;
import static com.prolificinteractive.materialcalendarview.MaterialCalendarView.showDecoratedDisabled;
import static com.prolificinteractive.materialcalendarview.MaterialCalendarView.showOtherMonths;
import static com.prolificinteractive.materialcalendarview.MaterialCalendarView.showOutOfRange;
  public void setDayFormatter(DayFormatter formatter) {
    this.contentDescriptionFormatter = contentDescriptionFormatter == this.formatter ?
                                       formatter : contentDescriptionFormatter;
    this.formatter = formatter == null ? DayFormatter.DEFAULT : formatter;
    CharSequence currentLabel = getText();
    Object[] spans = null;
    if (currentLabel instanceof Spanned) {
      spans = ((Spanned) currentLabel).getSpans(0, currentLabel.length(), Object.class);
    }
    SpannableString newLabel = new SpannableString(getLabel());
    if (spans != null) {
      for (Object span : spans) {
        newLabel.setSpan(span, 0, newLabel.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
      }
    }
    setText(newLabel);
  }

  /**
   * Set the new content description formatter and reformat the current content description.
   *
   * @param formatter new content description formatter
   */
  public void setDayFormatterContentDescription(DayFormatter formatter) {
    this.contentDescriptionFormatter = formatter == null ? this.formatter : formatter;
    setContentDescription(getContentDescriptionLabel());
  }

  @NonNull
  public String getLabel() {
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/format/DayFormatter.java
// public interface DayFormatter {
// 
//   /**
//    * Default format for displaying the day.
//    */
//   String DEFAULT_FORMAT = "d";
// 
//   /**
//    * Default implementation used by {@linkplain com.prolificinteractive.materialcalendarview.MaterialCalendarView}
//    */
//   DayFormatter DEFAULT = new DateFormatDayFormatter();
// 
//   /**
//    * Format a given day into a string
//    *
//    * @param day the day
//    * @return a label for the day
//    */
//   @NonNull String format(@NonNull CalendarDay day);
// }
// 
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/MaterialCalendarView.java
// public static boolean showDecoratedDisabled(@ShowOtherDates int showOtherDates) {
//   return (showOtherDates & SHOW_DECORATED_DISABLED) != 0;
// }
// 
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/MaterialCalendarView.java
// public static boolean showOtherMonths(@ShowOtherDates int showOtherDates) {
//   return (showOtherDates & SHOW_OTHER_MONTHS) != 0;
// }
// 
// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/MaterialCalendarView.java
// public static boolean showOutOfRange(@ShowOtherDates int showOtherDates) {
//   return (showOtherDates & SHOW_OUT_OF_RANGE) != 0;
// }


// Path: library/src/main/java/com/prolificinteractive/materialcalendarview/DayView.java
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.RippleDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.StateListDrawable;
import android.graphics.drawable.shapes.OvalShape;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.v7.widget.AppCompatCheckedTextView;
import android.text.SpannableString;
import android.text.Spanned;
import android.view.Gravity;
import android.view.View;
import com.prolificinteractive.materialcalendarview.MaterialCalendarView.ShowOtherDates;
import com.prolificinteractive.materialcalendarview.format.DayFormatter;
import java.util.List;
import static com.prolificinteractive.materialcalendarview.MaterialCalendarView.showDecoratedDisabled;
import static com.prolificinteractive.materialcalendarview.MaterialCalendarView.showOtherMonths;
import static com.prolificinteractive.materialcalendarview.MaterialCalendarView.showOutOfRange;

  public void setDayFormatter(DayFormatter formatter) {
    this.contentDescriptionFormatter = contentDescriptionFormatter == this.formatter ?
                                       formatter : contentDescriptionFormatter;
    this.formatter = formatter == null ? DayFormatter.DEFAULT : formatter;
    CharSequence currentLabel = getText();
    Object[] spans = null;
    if (currentLabel instanceof Spanned) {
      spans = ((Spanned) currentLabel).getSpans(0, currentLabel.length(), Object.class);
    }
    SpannableString newLabel = new SpannableString(getLabel());
    if (spans != null) {
      for (Object span : spans) {
        newLabel.setSpan(span, 0, newLabel.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
      }
    }
    setText(newLabel);
  }

  /**
   * Set the new content description formatter and reformat the current content description.
   *
   * @param formatter new content description formatter
   */
  public void setDayFormatterContentDescription(DayFormatter formatter) {
    this.contentDescriptionFormatter = formatter == null ? this.formatter : formatter;
    setContentDescription(getContentDescriptionLabel());
  }

  @NonNull
  public String getLabel() {
    return formatter.format(date);