{"action":"created","issue":{"url":"https://api.github.com/repos/roomorama/Caldroid/issues/191","labels_url":"https://api.github.com/repos/roomorama/Caldroid/issues/191/labels{/name}","comments_url":"https://api.github.com/repos/roomorama/Caldroid/issues/191/comments","events_url":"https://api.github.com/repos/roomorama/Caldroid/issues/191/events","html_url":"https://github.com/roomorama/Caldroid/issues/191","id":50002974,"number":191,"title":"Event on day from database","user":{"login":"raghunandankavi2010","id":4216745,"avatar_url":"https://avatars.githubusercontent.com/u/4216745?v=3","gravatar_id":"","url":"https://api.github.com/users/raghunandankavi2010","html_url":"https://github.com/raghunandankavi2010","followers_url":"https://api.github.com/users/raghunandankavi2010/followers","following_url":"https://api.github.com/users/raghunandankavi2010/following{/other_user}","gists_url":"https://api.github.com/users/raghunandankavi2010/gists{/gist_id}","starred_url":"https://api.github.com/users/raghunandankavi2010/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raghunandankavi2010/subscriptions","organizations_url":"https://api.github.com/users/raghunandankavi2010/orgs","repos_url":"https://api.github.com/users/raghunandankavi2010/repos","events_url":"https://api.github.com/users/raghunandankavi2010/events{/privacy}","received_events_url":"https://api.github.com/users/raghunandankavi2010/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2014-11-25T10:11:00Z","updated_at":"2015-02-08T03:20:59Z","closed_at":"2014-11-28T08:41:35Z","body":"          final CaldroidListener listener = new CaldroidListener() {\r\n\r\n\t\t\t@Override\r\n\t\t\tpublic void onSelectDate(Date date, View view) {\r\n\t\t\t}\r\n\r\n\t\t\t@Override\r\n\t\t\tpublic void onChangeMonth(int month, int year) {\r\n\t\t\t\t\r\n\t\t\t\tString text = \"month: \" + month + \" year: \" + year;\r\n\t\t\t\tString monthS = String.valueOf(month);\r\n\t\t\t\tString yearS = String.valueOf(year);\r\n\t\t\t\r\n\t\t\t\tString[] args = { monthS , yearS };\t\r\n\t\t\t\tc= CaldroidSampleActivity.this.getContentResolver().query(CalendarProvider.CONTENT_URI,\r\n\t\t\t\t\t\tnew String[] {CalendarProvider.ID,CalendarProvider.EVENT,\r\n\t\t\t\t\t\tCalendarProvider.DESCRIPTION,CalendarProvider.LOCATION,\r\n\t\t\t\t\t\tCalendarProvider.YEAR,CalendarProvider.MONTH,CalendarProvider.DAY,\r\n\t\t\t\t\t\tCalendarProvider.HOURS,CalendarProvider.MINUTES},\"month=? and year=?\",args, null);\r\n\t\t\t\tnew GetEvents().execute();\r\n\t\t\r\n\t\t\t}\r\n\r\n\t\t\t@Override\r\n\t\t\tpublic void onLongClickDate(Date date, View view) {\r\n\t\t\t}\r\n\r\n\t\t\t@Override\r\n\t\t\tpublic void onCaldroidViewCreated() {\r\n\t\t\t\tif (caldroidFragment.getLeftArrowButton() != null) {\r\n\t\t\t\t\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t};\r\n\r\nIn AsyncTask i fetch the events from ContentProvider based on month and the year.\r\n\r\n       private class GetEvents extends AsyncTask<Void,Void,ArrayList<Event>>{\r\n\r\n\t\t@Override\r\n\t\tprotected ArrayList<Event> doInBackground(Void... params) {\r\n\t\t\tevents.clear();\r\n\r\n\t\t\t\r\n\t\t\r\n\t\t\tif( c.moveToFirst()){\r\n\t\t\t\tdo{\r\n\t\t\t\t\tEvent event = new Event();\r\n\t\t\r\n\t\t\t\t\t\t\tevent.setEVENT(c.getString(c.getColumnIndex(CalendarProvider.EVENT)));\r\n\t\t\t\t\t\t\tevent.setLOCATION(c.getString(c.getColumnIndex(CalendarProvider.LOCATION)));\r\n\t\t\t\t\t\t\tevent.setDESCRIPTION(c.getString(c.getColumnIndex(CalendarProvider.DESCRIPTION)));\t\r\n\t\t\t\t\t\t\tevent.setYEAR(c.getString(c.getColumnIndex(CalendarProvider.YEAR)));\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tevent.setMONTH(c.getString(c.getColumnIndex(CalendarProvider.MONTH)));\r\n\t\t\t\t\t\t\tevent.setDAY(c.getString(c.getColumnIndex(CalendarProvider.DAY)));\r\n\t\t\t\t\t\t\tevent.setHOURS(c.getString(c.getColumnIndex(CalendarProvider.HOURS)));\r\n\t\t\t\t\t\t\tevent.setMINUTES(c.getString(c.getColumnIndex(CalendarProvider.MINUTES)));\r\n\t\t\t\t\t\t\tevents.add(event);\r\n\t\t\t\t\t\t}while(c.moveToNext());\t\r\n\t\t\t\t\t\tc.close();\r\n\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\r\n\t\t\t\r\n\t\t\treturn events;\r\n\t\t}\r\n\t\t@Override\r\n\t\tprotected void onPostExecute(ArrayList<Event> result){\r\n\r\n\t\t\t\r\n\t\t\tfor(int i=0;i<result.size();i++)\r\n\t\t\t{\r\n\t\t\t\t\r\n\t\t\tint day = Integer.parseInt(result.get(i).getDAY());  //25\r\n\t\t\tint month = Integer.parseInt(result.get(i).getMONTH()); //12\r\n\t\t\tint year = Integer.parseInt(result.get(i).getYEAR()); // 1988\r\n\t\t\t\r\n\t\t\tCalendar c = Calendar.getInstance();\r\n\t\t\tc.set(year, month-1, day, 0, 0);  \r\n\t\t\tDate greenDate = c.getTime();\r\n\t\t\t;\r\n\t\t\t\r\n\t\t\tif (caldroidFragment != null) {\r\n\t\t\t\t\r\n\t\t\t\tcaldroidFragment.setBackgroundResourceForDate(R.color.blue,greenDate);\r\n\r\n\t\t\t}\r\n\t\t\t}\r\n\t\t\t\r\n\t\t}\r\n\t}\r\n\r\n\r\nThe problem\r\n\r\nAfter fetching the events form database i set the color to the date. \r\n\r\nExample : On Jan 1 2015 i have a event. So i change the color of the date. But this change is visible once i move to Feb and come back to Jan.  I am looking at the source and trying to figure out the issue.\r\n\r\nThis issue is not seen if i fetch events from database all at a time which is time consuming. So i would prefer fetching events based on month and year.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/roomorama/Caldroid/issues/comments/73395060","html_url":"https://github.com/roomorama/Caldroid/issues/191#issuecomment-73395060","issue_url":"https://api.github.com/repos/roomorama/Caldroid/issues/191","id":73395060,"user":{"login":"jithea23","id":10572805,"avatar_url":"https://avatars.githubusercontent.com/u/10572805?v=3","gravatar_id":"","url":"https://api.github.com/users/jithea23","html_url":"https://github.com/jithea23","followers_url":"https://api.github.com/users/jithea23/followers","following_url":"https://api.github.com/users/jithea23/following{/other_user}","gists_url":"https://api.github.com/users/jithea23/gists{/gist_id}","starred_url":"https://api.github.com/users/jithea23/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jithea23/subscriptions","organizations_url":"https://api.github.com/users/jithea23/orgs","repos_url":"https://api.github.com/users/jithea23/repos","events_url":"https://api.github.com/users/jithea23/events{/privacy}","received_events_url":"https://api.github.com/users/jithea23/received_events","type":"User","site_admin":false},"created_at":"2015-02-08T03:20:59Z","updated_at":"2015-02-08T03:20:59Z","body":"hey Sir! Why is it I am getting a result of 0? I put a toast inside the onPostExecute and I found out that it gives a result of 0, help sir..\r\n\r\n@Override\r\n        protected void onPostExecute(ArrayList<Event> result) {\r\n\r\n            Toast.makeText(getApplicationContext(),\r\n                    \"result \" + (result.size()),\r\n                    Toast.LENGTH_SHORT).show();\r\n            for (int i = 0; i < result.size(); i++) {\r\n                int day = Integer.parseInt(result.get(i).getDay());  //25\r\n                int month = Integer.parseInt(result.get(i).getMonth()); //12\r\n                int year = Integer.parseInt(result.get(i).getYear()); // 1988\r\n\r\n                Calendar c = Calendar.getInstance();\r\n                c.set(year, month-1, day, 0, 0);\r\n                Date greenDate = c.getTime();\r\n\r\n\r\n                if (caldroidFragment != null) {\r\n\r\n                    caldroidFragment.setBackgroundResourceForDate(R.color.BlueViolet, greenDate);\r\n\r\n                }\r\n\r\n            }\r\n\r\n        }"}}