Prevent crash

pull/215/head
M66B 7 months ago
parent 58c2018457
commit c2344e9340

@ -82,16 +82,16 @@ public class FragmentDialogCalendar extends FragmentDialogBase {
int colId = cursor.getColumnIndexOrThrow(CalendarContract.Calendars._ID); int colId = cursor.getColumnIndexOrThrow(CalendarContract.Calendars._ID);
int colAccount = cursor.getColumnIndexOrThrow(CalendarContract.Calendars.ACCOUNT_NAME); int colAccount = cursor.getColumnIndexOrThrow(CalendarContract.Calendars.ACCOUNT_NAME);
int colType = cursor.getColumnIndexOrThrow(CalendarContract.Calendars.ACCOUNT_TYPE); int colType = cursor.getColumnIndexOrThrow(CalendarContract.Calendars.ACCOUNT_TYPE);
int colPrimary = cursor.getColumnIndexOrThrow(CalendarContract.Calendars.IS_PRIMARY); int colPrimary = cursor.getColumnIndex(CalendarContract.Calendars.IS_PRIMARY);
int colVisible = cursor.getColumnIndexOrThrow(CalendarContract.Calendars.VISIBLE); int colVisible = cursor.getColumnIndex(CalendarContract.Calendars.VISIBLE);
int colDisplay = cursor.getColumnIndexOrThrow(CalendarContract.Calendars.CALENDAR_DISPLAY_NAME); int colDisplay = cursor.getColumnIndex(CalendarContract.Calendars.CALENDAR_DISPLAY_NAME);
while (cursor.moveToNext()) { while (cursor.moveToNext()) {
long id = cursor.getLong(colId); long id = cursor.getLong(colId);
String account = cursor.getString(colAccount); String account = cursor.getString(colAccount);
String type = cursor.getString(colType); String type = cursor.getString(colType);
boolean primary = (cursor.getInt(colPrimary) != 0); boolean primary = (colPrimary >= 0 && cursor.getInt(colPrimary) != 0);
boolean visible = (cursor.getInt(colVisible) != 0); boolean visible = (colVisible >= 0 && cursor.getInt(colVisible) != 0);
String name = cursor.getString(colDisplay); String name = (colDisplay >= 0 ? cursor.getString(colDisplay) : null);
if (account != null) if (account != null)
calendars.add(new Calendar(id, account, type, primary, visible, name)); calendars.add(new Calendar(id, account, type, primary, visible, name));
} }

Loading…
Cancel
Save