Skip to content

Commit e7c9680

Browse files
committed
Fixed 'boolean android.database.Cursor.moveToNext()' on a null object reference error
Closes #259 Closes #255
1 parent 4560a2f commit e7c9680

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

android/src/main/java/com/calendarevents/RNCalendarEvents.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ private void createAttendeesForEvent(ContentResolver resolver, int eventID, Read
806806
Cursor cursor = CalendarContract.Attendees.query(resolver, eventID, new String[] {
807807
CalendarContract.Attendees._ID
808808
});
809-
809+
810810
while (cursor.moveToNext()) {
811811
long attendeeId = cursor.getLong(0);
812812
Uri attendeeUri = ContentUris.withAppendedId(CalendarContract.Attendees.CONTENT_URI, attendeeId);
@@ -1135,12 +1135,13 @@ private WritableNativeMap serializeEvent(Cursor cursor) {
11351135
private WritableNativeArray serializeEventCalendars(Cursor cursor) {
11361136
WritableNativeArray results = new WritableNativeArray();
11371137

1138-
while (cursor.moveToNext()) {
1139-
results.pushMap(serializeEventCalendar(cursor));
1138+
if (cursor != null) {
1139+
while (cursor.moveToNext()) {
1140+
results.pushMap(serializeEventCalendar(cursor));
1141+
}
1142+
cursor.close();
11401143
}
11411144

1142-
cursor.close();
1143-
11441145
return results;
11451146
}
11461147

0 commit comments

Comments
 (0)