diff options
author | Patrick Lang <72232737+patrickunterwegs@users.noreply.github.com> | 2022-01-24 00:24:12 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-24 00:24:12 +0300 |
commit | 04dcf5ca80a1c6f5efc24bda63633ea4d150ddd0 (patch) | |
tree | 7e8ebd3d406b39574d72f6e2f54039d40894a4f9 | |
parent | d7ef7a2acf2de831b819f409379df0f12efd572a (diff) |
Refactored ics-generation, using ical4android now
-rw-r--r-- | src/main/java/at/bitfire/ical4android/JtxICalObject.kt | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/main/java/at/bitfire/ical4android/JtxICalObject.kt b/src/main/java/at/bitfire/ical4android/JtxICalObject.kt index a71fbdb..7a9218c 100644 --- a/src/main/java/at/bitfire/ical4android/JtxICalObject.kt +++ b/src/main/java/at/bitfire/ical4android/JtxICalObject.kt @@ -535,11 +535,11 @@ open class JtxICalObject( } /** - * Takes the current JtxICalObject, transforms it to an iCalendar and writes it in an OutputStream - * @param [os] OutputStream where iCalendar should be written to + * Takes the current JtxICalObject and transforms it to a Calendar (ical4j) + * @return The current JtxICalObject transformed into a ical4j Calendar */ @UsesThreadContextClassLoader - fun write(os: OutputStream) { + fun getICalendarFormat(): Calendar? { Ical4Android.checkThreadContextClassLoader() val ical = Calendar() @@ -549,7 +549,7 @@ open class JtxICalObject( val calComponent = when (component) { JtxContract.JtxICalObject.Component.VTODO.name -> VToDo(true /* generates DTSTAMP */) JtxContract.JtxICalObject.Component.VJOURNAL.name -> VJournal(true /* generates DTSTAMP */) - else -> return + else -> return null } ical.components += calComponent addProperties(calComponent.properties) @@ -625,7 +625,17 @@ open class JtxICalObject( } ICalendar.softValidate(ical) - CalendarOutputter(false).output(ical, os) + return ical + } + + /** + * Takes the current JtxICalObject, transforms it to an iCalendar and writes it in an OutputStream + * @param [os] OutputStream where iCalendar should be written to + */ + @UsesThreadContextClassLoader + fun write(os: OutputStream) { + Ical4Android.checkThreadContextClassLoader() + CalendarOutputter(false).output(this.getICalendarFormat(), os) } /** |