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

The following examples show how to use com.prolificinteractive.materialcalendarview.CalendarDay#from() . 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: BasicActivityDecorated.java    From material-calendarview with MIT License 6 votes vote down vote up
@Override
protected List<CalendarDay> doInBackground(@NonNull Void... voids) {
  try {
    Thread.sleep(2000);
  } catch (InterruptedException e) {
    e.printStackTrace();
  }
  LocalDate temp = LocalDate.now().minusMonths(2);
  final ArrayList<CalendarDay> dates = new ArrayList<>();
  for (int i = 0; i < 30; i++) {
    final CalendarDay day = CalendarDay.from(temp);
    dates.add(day);
    temp = temp.plusDays(5);
  }

  return dates;
}
 
Example 2
Source File: CalendarActivity.java    From monthweekmaterialcalendarview with Apache License 2.0 5 votes vote down vote up
private void AddDecorator() {
    //150天
    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.MONTH, -2);
    ArrayList<CalendarDay> dates = new ArrayList<>();
    for (int i = 0; i < 30; i++) {
        CalendarDay day = CalendarDay.from(calendar);
        dates.add(day);
        calendar.add(Calendar.DATE, 5);
    }
    //增加有红点标志
    monthWeekMaterialCalendarView.addDecorator(new EventDecorator(Color.RED, dates));
}
 
Example 3
Source File: CalendarSmoothActivity.java    From monthweekmaterialcalendarview with Apache License 2.0 5 votes vote down vote up
private void AddDecorator() {
    //150天
    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.MONTH, -2);
    ArrayList<CalendarDay> dates = new ArrayList<>();
    for (int i = 0; i < 30; i++) {
        CalendarDay day = CalendarDay.from(calendar);
        dates.add(day);
        calendar.add(Calendar.DATE, 5);
    }
    //增加有红点标志
    monthWeekMaterialCalendarView.addDecorator(new EventDecorator(Color.RED, dates));
}
 
Example 4
Source File: CustomizeCodeActivity.java    From material-calendarview with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_basic);
  ButterKnife.bind(this);

  widget.setShowOtherDates(MaterialCalendarView.SHOW_ALL);
  widget.setLeftArrow(R.drawable.ic_arrow_back);
  widget.setRightArrow(R.drawable.ic_arrow_forward);
  widget.setSelectionColor(getResources().getColor(R.color.sample_primary));
  widget.setWeekDayTextAppearance(R.style.CustomTextAppearance);
  widget.setHeaderTextAppearance(R.style.CustomTextAppearance);
  widget.setDateTextAppearance(R.style.CustomTextAppearance);
  widget.setTitleFormatter(new MonthArrayTitleFormatter(getResources().getTextArray(R.array.custom_months)));
  widget.setWeekDayFormatter(new ArrayWeekDayFormatter(getResources().getTextArray(R.array.custom_weekdays)));
  widget.setTileSize((int) TypedValue.applyDimension(
      TypedValue.COMPLEX_UNIT_DIP,
      36,
      getResources().getDisplayMetrics()
  ));
  widget.setTitleAnimationOrientation(MaterialCalendarView.VERTICAL);

  CalendarDay today = CalendarDay.from(2016, 5, 2);
  widget.setCurrentDate(today);
  widget.setSelectedDate(today);

  widget.state().edit()
      .setFirstDayOfWeek(DayOfWeek.WEDNESDAY)
      .setMinimumDate(CalendarDay.from(2016, 4, 3))
      .setMaximumDate(CalendarDay.from(2016, 5, 12))
      .setCalendarDisplayMode(CalendarMode.WEEKS)
      .commit();
}
 
Example 5
Source File: OneDayDecorator.java    From monthweekmaterialcalendarview with Apache License 2.0 4 votes vote down vote up
/**
 * We're changing the internals, so make sure to call {@linkplain MaterialCalendarView#invalidateDecorators()}
 */
public void setDate(Date date) {
    this.date = CalendarDay.from(date);
}
 
Example 6
Source File: SelectorDecorator.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
public void setDate(Date date) {
    this.date = CalendarDay.from(date);
}
 
Example 7
Source File: OneDayDecorator.java    From material-calendarview with MIT License 4 votes vote down vote up
/**
 * We're changing the internals, so make sure to call {@linkplain MaterialCalendarView#invalidateDecorators()}
 */
public void setDate(LocalDate date) {
  this.date = CalendarDay.from(date);
}