badoualy / datepicker-timeline

An infinite scrolling timeline to pick a date
MIT License
464 stars 71 forks source link

Supply labels at runtime #8

Closed drparasmehta closed 7 years ago

drparasmehta commented 7 years ago

Suppose I want to fetch labels from server upon selection of date. And then reflect the fetched data as label. (Label means the text shown below date, which is supplied by DateLabelAdapter as per your sample).

How do I do it? How do I refresh labels with data fetched from server.

badoualy commented 7 years ago

In your DateLabelAdapter implementation, you return empty string (or null should be ok too) if you don't have the data yet, if you do, return the data.

Once you get your result from your server, just call getTimelineView().notifyDatasetChanged(); (or itemChanged if you have a precise position) on your DatePickerTimeline instance.

notifyDatasetChanged > onBindView > internally call DateLabelAdapter to get label > update view :)

Close ticket if everything is good :)

drparasmehta commented 7 years ago

Perfect man. The only correction is that, I had to use..

getTimelineView().getAdapter().notifyDataSetChanged();