Skip to content
This repository was archived by the owner on Jun 9, 2025. It is now read-only.

Commit 240f756

Browse files
authored
Fix cursor without next (#203)
* Check cursor has next value * Use getColumnIndexOrThrow for clarity * Fix linting
1 parent 21622fe commit 240f756

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/src/main/kotlin/at/bitfire/ical4android/AndroidEvent.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ abstract class AndroidEvent(
365365
// scheduling
366366
if (groupScheduled) {
367367
// ORGANIZER must only be set for group-scheduled events (= events with attendees)
368-
if (row.containsKey(Events.ORGANIZER) && groupScheduled)
368+
if (row.containsKey(Events.ORGANIZER))
369369
try {
370370
event.organizer = Organizer(URI("mailto", row.getAsString(Events.ORGANIZER), null))
371371
} catch (e: URISyntaxException) {
@@ -489,7 +489,7 @@ abstract class AndroidEvent(
489489
EXTNAME_URL ->
490490
try {
491491
event.url = URI(rawValue)
492-
} catch(e: URISyntaxException) {
492+
} catch(_: URISyntaxException) {
493493
logger.warning("Won't process invalid local URL: $rawValue")
494494
}
495495

@@ -703,9 +703,11 @@ abstract class AndroidEvent(
703703
var rebuild = false
704704
if (event.status == null)
705705
calendar.provider.query(eventSyncURI(), arrayOf(Events.STATUS), null, null, null)?.use { cursor ->
706-
cursor.moveToNext()
707-
if (!cursor.isNull(0)) // Events.STATUS != null
708-
rebuild = true
706+
if (cursor.moveToNext()) {
707+
val statusIndex = cursor.getColumnIndexOrThrow(Events.STATUS)
708+
if (!cursor.isNull(statusIndex))
709+
rebuild = true
710+
}
709711
}
710712

711713
if (rebuild) { // delete whole event and insert updated event

0 commit comments

Comments
 (0)