Skip to content

Commit 9abe968

Browse files
author
MedTrack
committed
fixing unreliable index
1 parent 2d84d38 commit 9abe968

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/android/nl/xservices/plugins/Calendar.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,12 @@ public void run() {
273273
}
274274
callback.sendPluginResult(new PluginResult(PluginResult.Status.OK, activeCalendars));
275275
} catch (JSONException e) {
276-
System.err.println("Exception: " + e.getMessage());
276+
System.err.println("JSONException: " + e.getMessage());
277277
callback.error(e.getMessage());
278-
}
278+
} catch (Exception ex) {
279+
System.err.println("Exception: " + ex.getMessage());
280+
callback.error(ex.getMessage());
281+
}
279282
}
280283
});
281284
}

src/android/nl/xservices/plugins/accessor/AbstractCalendarAccessor.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,12 @@ public final JSONArray getActiveCalendars() throws JSONException {
288288
calendar.put("id", cursor.getString(cursor.getColumnIndex(this.getKey(KeyIndex.CALENDARS_ID))));
289289
calendar.put("name", cursor.getString(cursor.getColumnIndex(this.getKey(KeyIndex.CALENDARS_NAME))));
290290
calendar.put("displayname", cursor.getString(cursor.getColumnIndex(this.getKey(KeyIndex.CALENDARS_DISPLAY_NAME))));
291-
calendar.put("isPrimary", "1".equals(cursor.getString(cursor.getColumnIndex(this.getKey(KeyIndex.IS_PRIMARY)))));
291+
int unReliableIsPrimaryIndex = cursor.getColumnIndex(this.getKey(KeyIndex.IS_PRIMARY));
292+
if(unReliableIsPrimaryIndex >= 0){
293+
calendar.put("isPrimary", "1".equals(cursor.getString(unReliableIsPrimaryIndex)));
294+
} else {
295+
calendar.put("isPrimary", false);
296+
}
292297
calendarsWrapper.put(calendar);
293298
} while (cursor.moveToNext());
294299
cursor.close();

0 commit comments

Comments
 (0)