Fixed added calendar events by display name

This commit is contained in:
M66B 2023-03-15 09:18:54 +01:00
parent 69ded38d17
commit 134d3082d0
1 changed files with 12 additions and 8 deletions

View File

@ -72,7 +72,6 @@ public class CalendarHelper {
static void insert(Context context, ICalendar icalendar, VEvent event, int status,
String selectedAccount, String selectedName, EntityMessage message) {
String organizer = (event.getOrganizer() == null ? null : event.getOrganizer().getEmail());
String summary = (event.getSummary() == null ? null : event.getSummary().getValue());
@ -92,19 +91,24 @@ public class CalendarHelper {
String uid = (event.getUid() == null ? null : event.getUid().getValue());
if (TextUtils.isEmpty(uid) || start == null || end == null)
if (TextUtils.isEmpty(uid) || start == null || end == null) {
EntityLog.log(context, EntityLog.Type.General, message,
"Event uid=" + uid + " start=" + start + " end=" + end);
return;
}
ContentResolver resolver = context.getContentResolver();
try (Cursor cursor = resolver.query(CalendarContract.Calendars.CONTENT_URI,
new String[]{CalendarContract.Calendars._ID},
CalendarContract.Calendars.VISIBLE + " <> 0 AND " +
CalendarContract.Calendars.ACCOUNT_NAME + " = ?" +
(selectedName == null
? ""
: " AND " + CalendarContract.Calendars.CALENDAR_DISPLAY_NAME + " = ?"),
CalendarContract.Calendars.VISIBLE + " <> 0" +
" AND " + CalendarContract.Calendars.ACCOUNT_NAME + " = ?" +
" AND " + (selectedName == null
? "(" + CalendarContract.Calendars.CALENDAR_DISPLAY_NAME + " IS NULL" +
" OR " + CalendarContract.Calendars.CALENDAR_DISPLAY_NAME + " = ''" +
" OR " + CalendarContract.Calendars.CALENDAR_DISPLAY_NAME + " = ?)"
: CalendarContract.Calendars.CALENDAR_DISPLAY_NAME + " = ?"),
selectedName == null
? new String[]{selectedAccount}
? new String[]{selectedAccount, selectedAccount}
: new String[]{selectedAccount, selectedName},
null)) {
if (cursor.getCount() == 0)