summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/UserDictionarySettings.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2011-07-21 18:10:20 +0900
committerJean Chalard <jchalard@google.com>2011-07-21 19:08:04 +0900
commitea41e087f98ebc226410e3621b9bca91c1688e0a (patch)
tree36458ab8d7b368c28b2ec3a9a6404c77d70143fe /src/com/android/settings/UserDictionarySettings.java
parentc29c6d3f8cec4e326cb1ca7417f383253eb717c9 (diff)
downloadpackages_apps_Settings-ea41e087f98ebc226410e3621b9bca91c1688e0a.zip
packages_apps_Settings-ea41e087f98ebc226410e3621b9bca91c1688e0a.tar.gz
packages_apps_Settings-ea41e087f98ebc226410e3621b9bca91c1688e0a.tar.bz2
Do not crash when the user dictionary service is disabled.
This still does not remove the UI. It only prevents the Settings application from crashing. Bug: 5024166 Change-Id: I6e8c0a8953af6c02273de2a881e85a5248cb8bd6
Diffstat (limited to 'src/com/android/settings/UserDictionarySettings.java')
-rw-r--r--src/com/android/settings/UserDictionarySettings.java19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/com/android/settings/UserDictionarySettings.java b/src/com/android/settings/UserDictionarySettings.java
index e5002c9..3b61064 100644
--- a/src/com/android/settings/UserDictionarySettings.java
+++ b/src/com/android/settings/UserDictionarySettings.java
@@ -223,6 +223,7 @@ public class UserDictionarySettings extends ListFragment implements DialogCreata
}
private String getWord(int position) {
+ if (null == mCursor) return null;
mCursor.moveToPosition(position);
// Handle a possible race-condition
if (mCursor.isAfterLast()) return null;
@@ -298,7 +299,7 @@ public class UserDictionarySettings extends ListFragment implements DialogCreata
FREQUENCY_FOR_USER_DICTIONARY_ADDS, UserDictionary.Words.LOCALE_TYPE_CURRENT);
Locale.setDefault(prevLocale);
}
- if (!mCursor.requery()) {
+ if (null != mCursor && !mCursor.requery()) {
throw new IllegalStateException("can't requery on already-closed cursor.");
}
mAddedWordAlready = true;
@@ -333,23 +334,25 @@ public class UserDictionarySettings extends ListFragment implements DialogCreata
super(context, layout, c, from, to);
mSettings = settings;
- int wordColIndex = c.getColumnIndexOrThrow(UserDictionary.Words.WORD);
- String alphabet = context.getString(
- com.android.internal.R.string.fast_scroll_alphabet);
- mIndexer = new AlphabetIndexer(c, wordColIndex, alphabet);
+ if (null != c) {
+ final String alphabet = context.getString(
+ com.android.internal.R.string.fast_scroll_alphabet);
+ final int wordColIndex = c.getColumnIndexOrThrow(UserDictionary.Words.WORD);
+ mIndexer = new AlphabetIndexer(c, wordColIndex, alphabet);
+ }
setViewBinder(mViewBinder);
}
public int getPositionForSection(int section) {
- return mIndexer.getPositionForSection(section);
+ return null == mIndexer ? 0 : mIndexer.getPositionForSection(section);
}
public int getSectionForPosition(int position) {
- return mIndexer.getSectionForPosition(position);
+ return null == mIndexer ? 0 : mIndexer.getSectionForPosition(position);
}
public Object[] getSections() {
- return mIndexer.getSections();
+ return null == mIndexer ? null : mIndexer.getSections();
}
public void onClick(View v) {