Search code examples
androidmultithreadingandroid-custom-view

Where to use CalendarPickerView's highlight() so that it has effect?


IDEA:

I want to highlight some days in the calendarPickerView to indicate that user cannot choose them.


WHAT I DO:

These days are fetched from a webservice using Retrofit. The problem is that retrofit takes some time in order to give me the result and because of that the calendarPickerView is already drawn and because of that highlight() method doesn't have any effect...!


MY THOUGHTS:

  1. Somehow make the fragment wait for retrofit call to finish before drawing.
  2. Call some method in CalendarPickerView so that I see the effects(I tried invalidate() but it did not work)

I don't get it why CalendarPickerView does not redraw himself after calling highlight() method. Does anyone know why I cannot see the effects of this method right away??


Solution

  • Actually it was a silly mistake. The CalendarPickerView is redrawing itself every time I call its highligh() method.

    What I did was that for some reason I called init() multiple time in different lines:

    calendarViewSquare.init(prevYear.getTime(), nextYear.getTime())
                    .inMode(CalendarPickerView.SelectionMode.MULTIPLE)
                    .withSelectedDates(dates);
    

    and when you do that I observed that everything is cleared, meaning you lose your highlighted days. Which means that if you have setted your highlighted days and then call init again then you will not see the results..