Skip to content
This repository has been archived by the owner on Jan 11, 2021. It is now read-only.

Commit

Permalink
Merge pull request #8 from alexstyl/fix_crash
Browse files Browse the repository at this point in the history
Fix NPE crash on NamedayDatabaseRefresher#loadSpecialNamedays()
  • Loading branch information
alexstyl authored Sep 2, 2016
2 parents 9c9ddcc + c1bbdde commit 6e9eb74
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ private void initialiseNamedaysIfEnabled() {
private List<ContactEvent> loadDeviceStaticNamedays() {
List<ContactEvent> namedayEvents = new ArrayList<>();
Cursor cursor = DeviceContactsQuery.query(contentResolver);
if (isInvalidCursor(cursor)) {
return namedayEvents;
}

Set<Long> contactIDs = new HashSet<>();

Expand Down Expand Up @@ -126,6 +129,9 @@ private List<ContactEvent> loadDeviceStaticNamedays() {
private List<ContactEvent> loadSpecialNamedays() {
List<ContactEvent> namedayEvents = new ArrayList<>();
Cursor cursor = DeviceContactsQuery.query(contentResolver);
if (isInvalidCursor(cursor)) {
return namedayEvents;
}

Set<Long> contactIDs = new HashSet<>();

Expand Down Expand Up @@ -164,6 +170,10 @@ private List<ContactEvent> loadSpecialNamedays() {
return namedayEvents;
}

private boolean isInvalidCursor(Cursor cursor) {
return cursor == null;
}

private String getDisplayName(Cursor cursor) {
return cursor.getString(DeviceContactsQuery.DISPLAY_NAME);
}
Expand Down

0 comments on commit 6e9eb74

Please sign in to comment.