Esempio n. 1
0
 private void invalidateDecorators() {
   final DayViewFacade facadeAccumulator = new DayViewFacade();
   for (DayView dayView : monthDayViews) {
     facadeAccumulator.reset();
     for (DecoratorResult result : decoratorResults) {
       if (result.decorator.shouldDecorate(dayView.getDate())) {
         result.result.applyTo(facadeAccumulator);
       }
     }
     dayView.applyFacade(facadeAccumulator);
   }
 }
 public void invalidateDecorators() {
   decoratorResults = new ArrayList<>();
   for (DayViewDecorator decorator : decorators) {
     DayViewFacade facade = new DayViewFacade();
     decorator.decorate(facade);
     if (facade.isDecorated()) {
       decoratorResults.add(new DecoratorResult(decorator, facade));
     }
   }
   for (MonthView monthView : currentViews) {
     monthView.setDayViewDecorators(decoratorResults);
   }
 }
  /** @param facade apply the facade to us */
  void applyFacade(DayViewFacade facade) {
    this.isDecoratedDisabled = facade.areDaysDisabled();
    setEnabled();

    setCustomBackground(facade.getBackgroundDrawable());
    setSelectionDrawable(facade.getSelectionDrawable());

    // Facade has spans
    List<DayViewFacade.Span> spans = facade.getSpans();
    if (!spans.isEmpty()) {
      String label = getLabel();
      SpannableString formattedLabel = new SpannableString(getLabel());
      for (DayViewFacade.Span span : spans) {
        formattedLabel.setSpan(span.span, 0, label.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
      }
      setText(formattedLabel);
    }
    // Reset in case it was customized previously
    else {
      setText(getLabel());
    }
  }