Java Code Examples for com.prolificinteractive.materialcalendarview.CalendarDay#getDay()

The following examples show how to use com.prolificinteractive.materialcalendarview.CalendarDay#getDay() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MonthWeekMaterialCalendarView.java    From monthweekmaterialcalendarview with Apache License 2.0 6 votes vote down vote up
public int getCurrentItemPosition(CalendarDay calendarDay) {
        Calendar currentCanlendar = calendarDay.getCalendar();
        //先计算每个月第一天是周几
        currentCanlendar.set(Calendar.DAY_OF_MONTH,
                currentCanlendar.getActualMinimum(Calendar.DAY_OF_MONTH));
        int i = currentCanlendar.get(Calendar.DAY_OF_WEEK);
//        Calendar中每周是从我们中国人的周日(星期七)开始计算的,
//       所以要减一才是真正的周几,(当前选中日期数+每个月第一天是周几)/7
//       整除的结果就是选中的日期行数
        int result = calendarDay.getDay() + i - 1;
        int position = 0;
        if (result % 7 == 0) {
            position = result / 7;
            return position;
        }
        if (result % 7 != 0) {
            position = result / 7 + 1;
            return position;
        }
        return position;
    }
 
Example 2
Source File: CalendarManager.java    From ReactNativeCalendarAndroid with MIT License 5 votes vote down vote up
/**
 * Should update new value of minimum or maximum date
 *
 * Check if the new min or max date is different from the previous one, if yes we update otherwise we don't.
 *
 * @param minMaxDate
 * @param newDate
 * @return boolean
 */
private boolean shouldUpdateMinMaxDate(CalendarDay minMaxDate, Date newDate) {
    if (minMaxDate == null) {
        return true;
    }

    java.util.Calendar newDateCalendar = java.util.Calendar.getInstance();
    newDateCalendar.setTimeInMillis(newDate.getTime());

    return (minMaxDate.getYear() != newDateCalendar.get(java.util.Calendar.YEAR) &&
            minMaxDate.getMonth() != newDateCalendar.get(java.util.Calendar.MONTH) &&
            minMaxDate.getDay() != newDateCalendar.get(java.util.Calendar.DAY_OF_MONTH));
}
 
Example 3
Source File: DynamicSettersActivity.java    From material-calendarview with MIT License 5 votes vote down vote up
public static void showDatePickerDialog(
    Context context, CalendarDay day,
    DatePickerDialog.OnDateSetListener callback) {
  if (day == null) {
    day = CalendarDay.today();
  }
  DatePickerDialog dialog = new DatePickerDialog(
      context, 0, callback, day.getYear(), day.getMonth() - 1, day.getDay()
  );
  dialog.show();
}
 
Example 4
Source File: ColorDecorator.java    From monthweekmaterialcalendarview with Apache License 2.0 4 votes vote down vote up
@Override
public boolean shouldDecorate(CalendarDay day) {

    return calendarDay.getDay()==day.getDay();
}
 
Example 5
Source File: EnableOneToTenDecorator.java    From monthweekmaterialcalendarview with Apache License 2.0 4 votes vote down vote up
@Override
public boolean shouldDecorate(CalendarDay day) {
    return day.getDay() <= 10;
}
 
Example 6
Source File: PrimeDayDisableDecorator.java    From monthweekmaterialcalendarview with Apache License 2.0 4 votes vote down vote up
@Override
public boolean shouldDecorate(CalendarDay day) {
    return PRIME_TABLE[day.getDay()];
}
 
Example 7
Source File: DisableDaysActivity.java    From material-calendarview with MIT License 4 votes vote down vote up
@Override public boolean shouldDecorate(final CalendarDay day) {
  return PRIME_TABLE[day.getDay()];
}
 
Example 8
Source File: DisableDaysActivity.java    From material-calendarview with MIT License 4 votes vote down vote up
@Override
public boolean shouldDecorate(CalendarDay day) {
  return day.getDay() <= 10;
}