{"action":"created","issue":{"url":"https://api.github.com/repos/alamkanak/Android-Week-View/issues/18","repository_url":"https://api.github.com/repos/alamkanak/Android-Week-View","labels_url":"https://api.github.com/repos/alamkanak/Android-Week-View/issues/18/labels{/name}","comments_url":"https://api.github.com/repos/alamkanak/Android-Week-View/issues/18/comments","events_url":"https://api.github.com/repos/alamkanak/Android-Week-View/issues/18/events","html_url":"https://github.com/alamkanak/Android-Week-View/issues/18","id":47077162,"number":18,"title":"Re: Question about setting weekview event","user":{"login":"shalinipk","id":8920346,"avatar_url":"https://avatars.githubusercontent.com/u/8920346?v=3","gravatar_id":"","url":"https://api.github.com/users/shalinipk","html_url":"https://github.com/shalinipk","followers_url":"https://api.github.com/users/shalinipk/followers","following_url":"https://api.github.com/users/shalinipk/following{/other_user}","gists_url":"https://api.github.com/users/shalinipk/gists{/gist_id}","starred_url":"https://api.github.com/users/shalinipk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shalinipk/subscriptions","organizations_url":"https://api.github.com/users/shalinipk/orgs","repos_url":"https://api.github.com/users/shalinipk/repos","events_url":"https://api.github.com/users/shalinipk/events{/privacy}","received_events_url":"https://api.github.com/users/shalinipk/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":23,"created_at":"2014-10-28T20:30:23Z","updated_at":"2016-12-08T09:34:54Z","closed_at":"2014-10-31T10:45:52Z","body":"Hello,\n\nThis is with reference to the issue I opened earlier, with the same title. I cannot reopen the issue, because it was not closed by me. Hence opening a new issue:\n\nQuestion :\nIs there a way to set the list of events in WeekView other than returning List of WeekViewEvents in onMonthChange() ?\n\nYour solution:\n\nCurrently the week view does not provide a ready-made solution for async event loading. But there is a simple hack. Use the following code to achieve what you want.\n\n@Override\npublic List onMonthChange(int newYear, int newMonth) {\n    // Populate the week view with some events.\n    List events = new ArrayList();\n\n```\n// Fetch events for the date user selected.\nfetchEventsinBackground();\n```\n\n}\n\n// Callback when fetchEvents finishes.\npublic void setEventList(Activity activity, final List eventModels) {\n\n```\n// Hide the progress dialog.\nif(mProgressDialog != null && mProgressDialog.isShowing()) {\n    mProgressDialog.dismiss();\n}\n\n// Refresh the week view.\nactivity.runOnUiThread(new Runnable() {\n    @Override\n    public void run() {\n        // Store the returned events in a global variable for later use.\n        mEventModels = eventModels;\n\n        // This line will trigger the method 'onMonthChange()' again.\n        mWeekView.notifyDatasetChanged();\n    }\n});\n```\n\n}\n\n@Override\npublic List<WeekViewEvent> onMonthChange(int year, int month) {\n    // TODO Be sure to check if the variables year and month equals the year and month of the events of mEventModels.\n    return getWeekViewEventsFromEventModels(mEventModels);\n}\n\nThank you for the response, however it did not work for me.\n\nJava doesn't support 2 methods with same signature, so I can't have something like this in the same class:\n\n@Override\npublic List<WeekViewEvent> onMonthChange(int year, int month) {\n    // TODO Be sure to check if the variables year and month equals the year and month of the events of mEventModels.\n    return getWeekViewEventsFromEventModels(mEventModels);\n}\n@Override\npublic List onMonthChange(int newYear, int newMonth) {\n    // Populate the week view with some events.\n    List events = new ArrayList();\n\n```\n// Fetch events for the date user selected.\nfetchEventsinBackground();\n```\n\n}\n If mWeekView.notifyDatasetChanged(); triggers onMonthChange() again, then it results in an infinite loop with fetchEventsinBackground() being called again & again!\n\nIs there a better way out ? Thanks for all the help!\n"},"comment":{"url":"https://api.github.com/repos/alamkanak/Android-Week-View/issues/comments/265695366","html_url":"https://github.com/alamkanak/Android-Week-View/issues/18#issuecomment-265695366","issue_url":"https://api.github.com/repos/alamkanak/Android-Week-View/issues/18","id":265695366,"user":{"login":"jas017","id":6624875,"avatar_url":"https://avatars.githubusercontent.com/u/6624875?v=3","gravatar_id":"","url":"https://api.github.com/users/jas017","html_url":"https://github.com/jas017","followers_url":"https://api.github.com/users/jas017/followers","following_url":"https://api.github.com/users/jas017/following{/other_user}","gists_url":"https://api.github.com/users/jas017/gists{/gist_id}","starred_url":"https://api.github.com/users/jas017/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jas017/subscriptions","organizations_url":"https://api.github.com/users/jas017/orgs","repos_url":"https://api.github.com/users/jas017/repos","events_url":"https://api.github.com/users/jas017/events{/privacy}","received_events_url":"https://api.github.com/users/jas017/received_events","type":"User","site_admin":false},"created_at":"2016-12-08T09:34:54Z","updated_at":"2016-12-08T09:34:54Z","body":"There is an error in your coce. The return type mentioned here is `boolean `and the `onMonthChange `method expects a list. \r\n```\r\nprivate boolean getWeekViewEventsFromEventModels(List eventModels, year, month) {\r\n    // TODO Filter the events from the eventModels by year and month. It would be good idea if you remove the events that are not in the desired range (i.e. where the month is not month+-1). This will release some memory.\r\n}\r\n```"}}
{"actor":{"display_login":"jas017"}}