@Test public void testNullInitArguments() throws Exception { final Date validDate = today.getTime(); try { view.init(validDate, validDate, timeZone, locale) .inMode(SINGLE) .withSelectedDate(null); fail("Should not have been able to pass in a null startDate"); } catch (IllegalArgumentException expected) { } try { view.init(null, validDate, timeZone, locale) .inMode(SINGLE) .withSelectedDate(validDate); fail("Should not have been able to pass in a null minDate"); } catch (IllegalArgumentException expected) { } try { view.init(validDate, null, timeZone, locale) .inMode(SINGLE) .withSelectedDate(validDate); fail("Should not have been able to pass in a null maxDate"); } catch (IllegalArgumentException expected) { } try { view.init(validDate, validDate, (Locale) null) .inMode(SINGLE) .withSelectedDate(validDate); fail("Should not have been able to pass in a null locale"); } catch (IllegalArgumentException expected) { } try { view.init(validDate, validDate, (TimeZone) null) .inMode(SINGLE) .withSelectedDate(validDate); fail("Should not have been able to pass in a null time zone"); } catch (IllegalArgumentException expected) { } }
public FluentInitializer init(Date minDate, Date maxDate, TimeZone timeZone, Locale locale) { if (minDate == null || maxDate == null) { throw new IllegalArgumentException( "minDate and maxDate must be non-null. " + dbg(minDate, maxDate)); } if (minDate.after(maxDate)) { throw new IllegalArgumentException( "minDate must be before maxDate. " + dbg(minDate, maxDate)); } if (locale == null) { throw new IllegalArgumentException("Locale is null."); } if (timeZone == null) { throw new IllegalArgumentException("Time zone is null."); } this.timeZone = timeZone; this.locale = locale; today = Calendar.getInstance(timeZone, locale); minCal = Calendar.getInstance(timeZone, locale); maxCal = Calendar.getInstance(timeZone, locale); monthCounter = Calendar.getInstance(timeZone, locale); for (MonthDescriptor month : months) { month.setLabel(formatMonthDate(month.getDate())); } weekdayNameFormat = new SimpleDateFormat(getContext().getString(R.string.day_name_format), locale); weekdayNameFormat.setTimeZone(timeZone); fullDateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, locale); fullDateFormat.setTimeZone(timeZone); monthFormatter = new Formatter(monthBuilder, locale); this.selectionMode = SelectionMode.SINGLE; selectedCals.clear(); selectedCells.clear(); highlightedCals.clear(); highlightedCells.clear(); cells.clear(); months.clear(); minCal.setTime(minDate); maxCal.setTime(maxDate); setMidnight(minCal); setMidnight(maxCal); displayOnly = false; maxCal.add(MINUTE, -1); monthCounter.setTime(minCal.getTime()); final int maxMonth = maxCal.get(MONTH); final int maxYear = maxCal.get(YEAR); while ((monthCounter.get(MONTH) <= maxMonth || monthCounter.get(YEAR) < maxYear) && monthCounter.get(YEAR) < maxYear + 1) { Date date = monthCounter.getTime(); MonthDescriptor month = new MonthDescriptor(monthCounter.get(MONTH), monthCounter.get(YEAR), date, formatMonthDate(date)); cells.put(monthKey(month), getMonthCells(month, monthCounter)); Logr.d("Adding month %s", month); months.add(month); monthCounter.add(MONTH, 1); } validateAndUpdate(); return new FluentInitializer(); }
CalendarPickerView extends ListView { public FluentInitializer init(Date minDate, Date maxDate, TimeZone timeZone, Locale locale) { if (minDate == null || maxDate == null) { throw new IllegalArgumentException( "minDate and maxDate must be non-null. " + dbg(minDate, maxDate)); } if (minDate.after(maxDate)) { throw new IllegalArgumentException( "minDate must be before maxDate. " + dbg(minDate, maxDate)); } if (locale == null) { throw new IllegalArgumentException("Locale is null."); } if (timeZone == null) { throw new IllegalArgumentException("Time zone is null."); } this.timeZone = timeZone; this.locale = locale; today = Calendar.getInstance(timeZone, locale); minCal = Calendar.getInstance(timeZone, locale); maxCal = Calendar.getInstance(timeZone, locale); monthCounter = Calendar.getInstance(timeZone, locale); for (MonthDescriptor month : months) { month.setLabel(formatMonthDate(month.getDate())); } weekdayNameFormat = new SimpleDateFormat(getContext().getString(R.string.day_name_format), locale); weekdayNameFormat.setTimeZone(timeZone); fullDateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, locale); fullDateFormat.setTimeZone(timeZone); monthFormatter = new Formatter(monthBuilder, locale); this.selectionMode = SelectionMode.SINGLE; selectedCals.clear(); selectedCells.clear(); highlightedCals.clear(); highlightedCells.clear(); cells.clear(); months.clear(); minCal.setTime(minDate); maxCal.setTime(maxDate); setMidnight(minCal); setMidnight(maxCal); displayOnly = false; maxCal.add(MINUTE, -1); monthCounter.setTime(minCal.getTime()); final int maxMonth = maxCal.get(MONTH); final int maxYear = maxCal.get(YEAR); while ((monthCounter.get(MONTH) <= maxMonth || monthCounter.get(YEAR) < maxYear) && monthCounter.get(YEAR) < maxYear + 1) { Date date = monthCounter.getTime(); MonthDescriptor month = new MonthDescriptor(monthCounter.get(MONTH), monthCounter.get(YEAR), date, formatMonthDate(date)); cells.put(monthKey(month), getMonthCells(month, monthCounter)); Logr.d("Adding month %s", month); months.add(month); monthCounter.add(MONTH, 1); } validateAndUpdate(); return new FluentInitializer(); } }
CalendarPickerView extends ListView { public FluentInitializer init(Date minDate, Date maxDate, TimeZone timeZone, Locale locale) { if (minDate == null || maxDate == null) { throw new IllegalArgumentException( "minDate and maxDate must be non-null. " + dbg(minDate, maxDate)); } if (minDate.after(maxDate)) { throw new IllegalArgumentException( "minDate must be before maxDate. " + dbg(minDate, maxDate)); } if (locale == null) { throw new IllegalArgumentException("Locale is null."); } if (timeZone == null) { throw new IllegalArgumentException("Time zone is null."); } this.timeZone = timeZone; this.locale = locale; today = Calendar.getInstance(timeZone, locale); minCal = Calendar.getInstance(timeZone, locale); maxCal = Calendar.getInstance(timeZone, locale); monthCounter = Calendar.getInstance(timeZone, locale); for (MonthDescriptor month : months) { month.setLabel(formatMonthDate(month.getDate())); } weekdayNameFormat = new SimpleDateFormat(getContext().getString(R.string.day_name_format), locale); weekdayNameFormat.setTimeZone(timeZone); fullDateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, locale); fullDateFormat.setTimeZone(timeZone); monthFormatter = new Formatter(monthBuilder, locale); this.selectionMode = SelectionMode.SINGLE; selectedCals.clear(); selectedCells.clear(); highlightedCals.clear(); highlightedCells.clear(); cells.clear(); months.clear(); minCal.setTime(minDate); maxCal.setTime(maxDate); setMidnight(minCal); setMidnight(maxCal); displayOnly = false; maxCal.add(MINUTE, -1); monthCounter.setTime(minCal.getTime()); final int maxMonth = maxCal.get(MONTH); final int maxYear = maxCal.get(YEAR); while ((monthCounter.get(MONTH) <= maxMonth || monthCounter.get(YEAR) < maxYear) && monthCounter.get(YEAR) < maxYear + 1) { Date date = monthCounter.getTime(); MonthDescriptor month = new MonthDescriptor(monthCounter.get(MONTH), monthCounter.get(YEAR), date, formatMonthDate(date)); cells.put(monthKey(month), getMonthCells(month, monthCounter)); Logr.d("Adding month %s", month); months.add(month); monthCounter.add(MONTH, 1); } validateAndUpdate(); return new FluentInitializer(); } CalendarPickerView(Context context, AttributeSet attrs); }
CalendarPickerView extends ListView { public FluentInitializer init(Date minDate, Date maxDate, TimeZone timeZone, Locale locale) { if (minDate == null || maxDate == null) { throw new IllegalArgumentException( "minDate and maxDate must be non-null. " + dbg(minDate, maxDate)); } if (minDate.after(maxDate)) { throw new IllegalArgumentException( "minDate must be before maxDate. " + dbg(minDate, maxDate)); } if (locale == null) { throw new IllegalArgumentException("Locale is null."); } if (timeZone == null) { throw new IllegalArgumentException("Time zone is null."); } this.timeZone = timeZone; this.locale = locale; today = Calendar.getInstance(timeZone, locale); minCal = Calendar.getInstance(timeZone, locale); maxCal = Calendar.getInstance(timeZone, locale); monthCounter = Calendar.getInstance(timeZone, locale); for (MonthDescriptor month : months) { month.setLabel(formatMonthDate(month.getDate())); } weekdayNameFormat = new SimpleDateFormat(getContext().getString(R.string.day_name_format), locale); weekdayNameFormat.setTimeZone(timeZone); fullDateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, locale); fullDateFormat.setTimeZone(timeZone); monthFormatter = new Formatter(monthBuilder, locale); this.selectionMode = SelectionMode.SINGLE; selectedCals.clear(); selectedCells.clear(); highlightedCals.clear(); highlightedCells.clear(); cells.clear(); months.clear(); minCal.setTime(minDate); maxCal.setTime(maxDate); setMidnight(minCal); setMidnight(maxCal); displayOnly = false; maxCal.add(MINUTE, -1); monthCounter.setTime(minCal.getTime()); final int maxMonth = maxCal.get(MONTH); final int maxYear = maxCal.get(YEAR); while ((monthCounter.get(MONTH) <= maxMonth || monthCounter.get(YEAR) < maxYear) && monthCounter.get(YEAR) < maxYear + 1) { Date date = monthCounter.getTime(); MonthDescriptor month = new MonthDescriptor(monthCounter.get(MONTH), monthCounter.get(YEAR), date, formatMonthDate(date)); cells.put(monthKey(month), getMonthCells(month, monthCounter)); Logr.d("Adding month %s", month); months.add(month); monthCounter.add(MONTH, 1); } validateAndUpdate(); return new FluentInitializer(); } CalendarPickerView(Context context, AttributeSet attrs); void setDecorators(List<CalendarCellDecorator> decorators); List<CalendarCellDecorator> getDecorators(); FluentInitializer init(Date minDate, Date maxDate, TimeZone timeZone, Locale locale); FluentInitializer init(Date minDate, Date maxDate); FluentInitializer init(Date minDate, Date maxDate, TimeZone timeZone); FluentInitializer init(Date minDate, Date maxDate, Locale locale); boolean scrollToDate(Date date); void fixDialogDimens(); void setTitleTypeface(Typeface titleTypeface); void setDateTypeface(Typeface dateTypeface); void setTypeface(Typeface typeface); void unfixDialogDimens(); Date getSelectedDate(); List<Date> getSelectedDates(); boolean selectDate(Date date); boolean selectDate(Date date, boolean smoothScroll); void highlightDates(Collection<Date> dates); void clearSelectedDates(); void clearHighlightedDates(); void setOnDateSelectedListener(OnDateSelectedListener listener); void setOnInvalidDateSelectedListener(OnInvalidDateSelectedListener listener); void setDateSelectableFilter(DateSelectableFilter listener); void setCustomDayView(DayViewAdapter dayViewAdapter); void setCellClickInterceptor(CellClickInterceptor listener); }
CalendarPickerView extends ListView { public FluentInitializer init(Date minDate, Date maxDate, TimeZone timeZone, Locale locale) { if (minDate == null || maxDate == null) { throw new IllegalArgumentException( "minDate and maxDate must be non-null. " + dbg(minDate, maxDate)); } if (minDate.after(maxDate)) { throw new IllegalArgumentException( "minDate must be before maxDate. " + dbg(minDate, maxDate)); } if (locale == null) { throw new IllegalArgumentException("Locale is null."); } if (timeZone == null) { throw new IllegalArgumentException("Time zone is null."); } this.timeZone = timeZone; this.locale = locale; today = Calendar.getInstance(timeZone, locale); minCal = Calendar.getInstance(timeZone, locale); maxCal = Calendar.getInstance(timeZone, locale); monthCounter = Calendar.getInstance(timeZone, locale); for (MonthDescriptor month : months) { month.setLabel(formatMonthDate(month.getDate())); } weekdayNameFormat = new SimpleDateFormat(getContext().getString(R.string.day_name_format), locale); weekdayNameFormat.setTimeZone(timeZone); fullDateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, locale); fullDateFormat.setTimeZone(timeZone); monthFormatter = new Formatter(monthBuilder, locale); this.selectionMode = SelectionMode.SINGLE; selectedCals.clear(); selectedCells.clear(); highlightedCals.clear(); highlightedCells.clear(); cells.clear(); months.clear(); minCal.setTime(minDate); maxCal.setTime(maxDate); setMidnight(minCal); setMidnight(maxCal); displayOnly = false; maxCal.add(MINUTE, -1); monthCounter.setTime(minCal.getTime()); final int maxMonth = maxCal.get(MONTH); final int maxYear = maxCal.get(YEAR); while ((monthCounter.get(MONTH) <= maxMonth || monthCounter.get(YEAR) < maxYear) && monthCounter.get(YEAR) < maxYear + 1) { Date date = monthCounter.getTime(); MonthDescriptor month = new MonthDescriptor(monthCounter.get(MONTH), monthCounter.get(YEAR), date, formatMonthDate(date)); cells.put(monthKey(month), getMonthCells(month, monthCounter)); Logr.d("Adding month %s", month); months.add(month); monthCounter.add(MONTH, 1); } validateAndUpdate(); return new FluentInitializer(); } CalendarPickerView(Context context, AttributeSet attrs); void setDecorators(List<CalendarCellDecorator> decorators); List<CalendarCellDecorator> getDecorators(); FluentInitializer init(Date minDate, Date maxDate, TimeZone timeZone, Locale locale); FluentInitializer init(Date minDate, Date maxDate); FluentInitializer init(Date minDate, Date maxDate, TimeZone timeZone); FluentInitializer init(Date minDate, Date maxDate, Locale locale); boolean scrollToDate(Date date); void fixDialogDimens(); void setTitleTypeface(Typeface titleTypeface); void setDateTypeface(Typeface dateTypeface); void setTypeface(Typeface typeface); void unfixDialogDimens(); Date getSelectedDate(); List<Date> getSelectedDates(); boolean selectDate(Date date); boolean selectDate(Date date, boolean smoothScroll); void highlightDates(Collection<Date> dates); void clearSelectedDates(); void clearHighlightedDates(); void setOnDateSelectedListener(OnDateSelectedListener listener); void setOnInvalidDateSelectedListener(OnInvalidDateSelectedListener listener); void setDateSelectableFilter(DateSelectableFilter listener); void setCustomDayView(DayViewAdapter dayViewAdapter); void setCellClickInterceptor(CellClickInterceptor listener);  }