Skip to content

Commit

Permalink
Fix for NPE that user reported, also made calendar picking logic more…
Browse files Browse the repository at this point in the history
… robust.
  • Loading branch information
Tim Su committed May 29, 2010
1 parent 5d94340 commit 9d21f7b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,9 @@ public synchronized void open() throws SQLException {
/** Closes database resource */
@Override
public void close() {
tagDatabase.close();
tagToTaskMapDatabase.close();
if(tagDatabase != null)
tagDatabase.close();
if(tagToTaskMapDatabase != null)
tagToTaskMapDatabase.close();
}
}
5 changes: 3 additions & 2 deletions astrid/src-legacy/com/timsu/astrid/utilities/Calendars.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static void initCalendarsPreference(Context context,

int currentSettingIndex = -1;

if (c == null) {
if (c == null || c.getCount() == 0) {
// Something went wrong when querying calendars
// Let's keep the "Astrid default" only.
listPreference
Expand All @@ -104,7 +104,6 @@ public static void initCalendarsPreference(Context context,
String[] entries = new String[calendarCount];
String[] entryValues = new String[calendarCount];


// Iterate calendars one by one, and fill up the list preference
try {
int row = 0;
Expand Down Expand Up @@ -135,6 +134,8 @@ public static void initCalendarsPreference(Context context,
.getString(R.string.prefs_defaultCalendar_default) });
listPreference.setValueIndex(0);
listPreference.setEnabled(true);
} else if(currentSettingIndex >= entryValues.length) {
currentSettingIndex = 0;
}

listPreference.setEntries(entries);
Expand Down

0 comments on commit 9d21f7b

Please sign in to comment.