summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2011-07-21 03:16:12 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-07-21 03:16:12 -0700
commit212aa744edf10ba0acc1427d8e64b0bf55de6980 (patch)
tree93ff26b4cf82b479e540eb35cf18e9302ce06501 /src/com
parentba534408011905e657a143eeae9a4c0fa412e0ec (diff)
parentea41e087f98ebc226410e3621b9bca91c1688e0a (diff)
downloadpackages_apps_settings-212aa744edf10ba0acc1427d8e64b0bf55de6980.zip
packages_apps_settings-212aa744edf10ba0acc1427d8e64b0bf55de6980.tar.gz
packages_apps_settings-212aa744edf10ba0acc1427d8e64b0bf55de6980.tar.bz2
Merge "Do not crash when the user dictionary service is disabled."
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/settings/UserDictionarySettings.java19
-rw-r--r--src/com/android/settings/inputmethod/UserDictionaryList.java2
2 files changed, 12 insertions, 9 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) {
diff --git a/src/com/android/settings/inputmethod/UserDictionaryList.java b/src/com/android/settings/inputmethod/UserDictionaryList.java
index 5db2841..c9a7ef9 100644
--- a/src/com/android/settings/inputmethod/UserDictionaryList.java
+++ b/src/com/android/settings/inputmethod/UserDictionaryList.java
@@ -49,7 +49,7 @@ public class UserDictionaryList extends SettingsPreferenceFragment {
new String[] { UserDictionary.Words.LOCALE },
null, null, null);
final Set<String> localeList = new TreeSet<String>();
- if (cursor.moveToFirst()) {
+ if (null != cursor && cursor.moveToFirst()) {
final int columnIndex = cursor.getColumnIndex(UserDictionary.Words.LOCALE);
do {
String locale = cursor.getString(columnIndex);