Search in sources :

Example 11 with DtStamp

use of net.fortuna.ical4j.model.property.DtStamp in project android by nextcloud.

the class SaveCalendar method getEvents.

private List<VEvent> getEvents(ContentResolver resolver, AndroidCalendar cal_src, Calendar cal_dst) {
    String where = Events.CALENDAR_ID + "=?";
    String[] args = new String[] { cal_src.mIdStr };
    String sortBy = Events.CALENDAR_ID + " ASC";
    Cursor cur;
    try {
        cur = resolver.query(Events.CONTENT_URI, mAllCols ? null : EVENT_COLS, where, args, sortBy);
    } catch (Exception except) {
        Log_OC.w(TAG, "Calendar provider is missing columns, continuing anyway");
        int n = 0;
        for (n = 0; n < EVENT_COLS.length; ++n) {
            if (EVENT_COLS[n] == null) {
                Log_OC.e(TAG, "Invalid EVENT_COLS index " + Integer.toString(n));
            }
        }
        cur = resolver.query(Events.CONTENT_URI, null, where, args, sortBy);
    }
    // Same timestamp for all events
    DtStamp timestamp = new DtStamp();
    // Collect up events and add them after any timezones
    List<VEvent> events = new ArrayList<>();
    while (cur.moveToNext()) {
        VEvent e = convertFromDb(cur, cal_dst, timestamp);
        if (e != null) {
            events.add(e);
            Log_OC.d(TAG, "Adding event: " + e.toString());
        }
    }
    cur.close();
    return events;
}
Also used : VEvent(net.fortuna.ical4j.model.component.VEvent) DtStamp(net.fortuna.ical4j.model.property.DtStamp) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor) URISyntaxException(java.net.URISyntaxException) ParseException(java.text.ParseException) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) IOException(java.io.IOException)

Aggregations

DtStamp (net.fortuna.ical4j.model.property.DtStamp)11 DateTime (net.fortuna.ical4j.model.DateTime)9 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)5 PropertyList (net.fortuna.ical4j.model.PropertyList)4 VEvent (net.fortuna.ical4j.model.component.VEvent)4 Uid (net.fortuna.ical4j.model.property.Uid)4 Calendar (net.fortuna.ical4j.model.Calendar)3 DtEnd (net.fortuna.ical4j.model.property.DtEnd)3 DtStart (net.fortuna.ical4j.model.property.DtStart)3 Summary (net.fortuna.ical4j.model.property.Summary)3 IOException (java.io.IOException)2 URISyntaxException (java.net.URISyntaxException)2 ParseException (java.text.ParseException)2 ArrayList (java.util.ArrayList)2 GregorianCalendar (java.util.GregorianCalendar)2 List (java.util.List)2 QName (javax.xml.namespace.QName)2 ParameterList (net.fortuna.ical4j.model.ParameterList)2 Property (net.fortuna.ical4j.model.Property)2 TimeZone (net.fortuna.ical4j.model.TimeZone)2