From acd0a7baafb358de87dadbf68740a23e3d929a1e Mon Sep 17 00:00:00 2001 From: sota Date: Wed, 4 Jan 2017 18:14:48 +0900 Subject: [PATCH] Improvement of README.md code syntax highlight --- README.md | 75 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index 0885104..b8749fc 100644 --- a/README.md +++ b/README.md @@ -9,31 +9,31 @@ Usage ===== simply declare it in your layout +```xml + - - - - + android:id="@+id/calendar" + android:layout_height="match_parent" + android:layout_width="match_parent"/> + +``` get the view like you normally would - - ExtendedCalendarView calendar = (ExtendedCalendarView)findViewById(R.id.calendar); - +```java +ExtendedCalendarView calendar = (ExtendedCalendarView)findViewById(R.id.calendar); +``` Calendar Content Provider ========================= All events are stored in a content provider for easy access and the ability to have other app hook into your calendar if you choose. make sure you declare the content provider in your manifest - - - +```xml + +``` if you dont want other apps to have access to your database make you add this attribute to the provider android:permission="signature" @@ -55,25 +55,26 @@ Adding Events To add an event to the content provider you need the start time, end time, julian start day and julian end day. For now you will have to implement your own way to get all the information but eventually in the future I may create one that you can just call and use. - 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); - - Calendar cal = Calendar.getInstance(); - - cal.set(startDayYear, startDayMonth, startDayDay, startTimeHour, startTimeMin); - values.put(CalendarProvider.START, cal.getTimeInMillis()); - values.put(CalendarProvider.START_DAY, julianDay); - TimeZone tz = TimeZone.getDefault(); - - cal.set(endDayYear, endDayMonth, endDayDay, endTimeHour, endTimeMin); - 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); +```java +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); + +Calendar cal = Calendar.getInstance(); + +cal.set(startDayYear, startDayMonth, startDayDay, startTimeHour, startTimeMin); +values.put(CalendarProvider.START, cal.getTimeInMillis()); +values.put(CalendarProvider.START_DAY, julianDay); +TimeZone tz = TimeZone.getDefault(); + +cal.set(endDayYear, endDayMonth, endDayDay, endTimeHour, endTimeMin); +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 = getContentResolver().insert(CalendarProvider.CONTENT_URI, values); - +Uri uri = getContentResolver().insert(CalendarProvider.CONTENT_URI, values); +``` julian start day is generated for you when the month is built so all you would have to do it call day.getStartDay() on the day and it will give you the julian day