Skip to content

Commit

Permalink
Merge pull request #476 from kohlia/master
Browse files Browse the repository at this point in the history
fixing primary calendar issue
  • Loading branch information
EddyVerbruggen committed Jun 14, 2018
2 parents 55c39a7 + d34f232 commit cd37da5
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -282,18 +282,18 @@ public final JSONArray getActiveCalendars() throws JSONException {
return null;
}
JSONArray calendarsWrapper = new JSONArray();
int primaryColumnIndex;
if (cursor.moveToFirst()) {
do {
JSONObject calendar = new JSONObject();
calendar.put("id", cursor.getString(cursor.getColumnIndex(this.getKey(KeyIndex.CALENDARS_ID))));
calendar.put("name", cursor.getString(cursor.getColumnIndex(this.getKey(KeyIndex.CALENDARS_NAME))));
calendar.put("displayname", cursor.getString(cursor.getColumnIndex(this.getKey(KeyIndex.CALENDARS_DISPLAY_NAME))));
int unReliableIsPrimaryIndex = cursor.getColumnIndex(this.getKey(KeyIndex.IS_PRIMARY));
if(unReliableIsPrimaryIndex >= 0){
calendar.put("isPrimary", "1".equals(cursor.getString(unReliableIsPrimaryIndex)));
} else {
calendar.put("isPrimary", false);
primaryColumnIndex = cursor.getColumnIndex(this.getKey((KeyIndex.IS_PRIMARY)));
if (primaryColumnIndex == -1) {
primaryColumnIndex = cursor.getColumnIndex("COALESCE(isPrimary, ownerAccount = account_name)");
}
calendar.put("isPrimary", "1".equals(cursor.getString(primaryColumnIndex)));
calendarsWrapper.put(calendar);
} while (cursor.moveToNext());
cursor.close();
Expand Down

0 comments on commit cd37da5

Please sign in to comment.