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

Add events without using on Listener - added when view is created #114

Open
llennoco opened this issue Feb 21, 2017 · 0 comments
Open

Add events without using on Listener - added when view is created #114

llennoco opened this issue Feb 21, 2017 · 0 comments

Comments

@llennoco
Copy link

Hi there,

I'm looking to add an event to the extendedCalendarView without using a listener. I have calculated the date and time in my onCreateView and wish to display this specific date on the calendar when the view is created.

`ExtendedCalendarView calendar = (ExtendedCalendarView) v.findViewById(R.id.calendar);

        try {
            ContentValues values = new ContentValues();
            values.put(CalendarProvider.COLOR, Event.COLOR_RED);
            values.put(CalendarProvider.DESCRIPTION, "Some Description");
            values.put(CalendarProvider.LOCATION, "Some location); ");
            values.put(CalendarProvider.EVENT, " Event name");

            sdf = new SimpleDateFormat("yyyy-MM-dd/HH:mm:ss");

            Date mDate = sdf.parse(combineString);
            long timeInMilliseconds = mDate.getTime();

            long timeNextInjection = timeInMilliseconds + 1210000000;
            Log.d("Test", "Time : " + timeNextInjection);
            TimeZone tz = TimeZone.getDefault();
            Calendar cal = Calendar.getInstance();


            cal.set(mDate.getYear(), mDate.getMonth(), (mDate.getDate()), mDate.getHours(), mDate.getMinutes());
            int StartDayJulian = Time.getJulianDay(cal.getTimeInMillis(), TimeUnit.MILLISECONDS.toSeconds(tz.getOffset(cal.getTimeInMillis())));
            values.put(CalendarProvider.START, cal.getTimeInMillis());
            values.put(CalendarProvider.START_DAY, StartDayJulian);


            mDate.setDate(mDate.getDate() + 14);
            cal.set(mDate.getYear(), mDate.getMonth(), (mDate.getDate()), mDate.getHours(), mDate.getMinutes());


           mDate.getMinutes());
            int endDayJulian = Time.getJulianDay(cal.getTimeInMillis(), TimeUnit.MILLISECONDS.toSeconds(tz.getOffset(cal.getTimeInMillis())));

            values.put(CalendarProvider.END, cal.getTimeInMillis());
            values.put(CalendarProvider.END_DAY, endDayJulian);

            Uri uri = getActivity().getContentResolver().insert(CalendarProvider.CONTENT_URI, values);

`

I have not edited the original files provided yet.

Any help would be so appreciated! I've been looking for a solution for a long time

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