Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events Not loading after asynchronous call #108

Open
williamkibira opened this issue Jun 24, 2018 · 0 comments
Open

Events Not loading after asynchronous call #108

williamkibira opened this issue Jun 24, 2018 · 0 comments

Comments

@williamkibira
Copy link

Hello , i have my network call set up to add events as shown below
Event Loading

@Override
    public void onSchedulesLoaded(int month, List<AntenatalSchedule> schedules) {
        scheduleLoader(schedules);
        weekView.notifyDatasetChanged();
    }
private void scheduleLoader(List<AntenatalSchedule> schedules) {
        weekViewEvents.clear();
        for (AntenatalSchedule schedule : schedules) {
            weekViewEvents.add(toWeekViewEvent(schedule));
            Log.d("APP", schedule.toString());
        }
    }
private WeekViewEvent toWeekViewEvent(AntenatalSchedule schedule) {
        Calendar now = Calendar.getInstance();
        Calendar startTime = (Calendar) now.clone();
        startTime.setTimeInMillis(schedule.getFrom().getMillis());
        startTime.set(Calendar.YEAR, now.get(Calendar.YEAR));
        startTime.set(Calendar.MONTH, now.get(Calendar.MONTH));
        startTime.set(Calendar.DAY_OF_MONTH, schedule.getFrom().getMonthOfYear());
        Calendar endTime = (Calendar) startTime.clone();
        endTime.setTimeInMillis(schedule.getTo().getMillis());
        endTime.set(Calendar.YEAR, endTime.get(Calendar.YEAR));
        endTime.set(Calendar.MONTH, endTime.get(Calendar.MONTH));
        endTime.set(Calendar.DAY_OF_MONTH, endTime.get(Calendar.DAY_OF_MONTH));
        // Create an week view event.
        WeekViewEvent weekViewEvent = new WeekViewEvent();
        weekViewEvent.setIdentifier(schedule.getId().toString());
        weekViewEvent.setName(schedule.getPatientName());
        weekViewEvent.setStartTime(startTime);
        weekViewEvent.setEndTime(endTime);
        weekViewEvent.setColor(Color.parseColor(schedule.getColorCode()));
        weekViewEvent.setLocation("");
        Log.d("APP",weekViewEvent.getStartTime().toString());
        Log.d("APP",weekViewEvent.getEndTime().toString());
        Log.d("APP",weekViewEvent.getName());
        Log.d("APP", weekViewEvent.toString());
        return weekViewEvent;
    }
weekView.setMonthChangeListener((newYear, newMonth) ->
        {
            Log.d("APP", "SCHEDULES ADDED TO VIEW");
            Log.d("APP", String.format("EVENT SIZE %d", weekViewEvents.size()));
            return weekViewEvents;
        });

i notice that the onMonthChange listener is triggered when a call to weekView.notifyDatasetChanged();
is called but, the events are not loaded .
I have also tried weekView.invalidate(); and nothing happens either .
Any advice on how to fix this problem would be greatly appreciated .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant