Fix a typo, and move a cursor.close() in a finally{} clause

Change-Id: Iac011ebb80b9430774c7dc5cd94728d05cef443f
main
Jean Chalard 2011-11-18 15:24:49 +09:00
parent 7800a313f1
commit 88562bec54
2 changed files with 8 additions and 5 deletions

View File

@ -193,7 +193,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
private UserDictionary mUserDictionary;
private UserBigramDictionary mUserBigramDictionary;
private UserUnigramDictionary mUserUnigramDictionary;
private boolean mIsUserDictionaryAvaliable;
private boolean mIsUserDictionaryAvailable;
// TODO: Create an inner class to group options and pseudo-options to improve readability.
// These variables are initialized according to the {@link EditorInfo#inputType}.
@ -552,7 +552,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
mUserDictionary = new UserDictionary(this, localeStr);
mSuggest.setUserDictionary(mUserDictionary);
mIsUserDictionaryAvaliable = mUserDictionary.isEnabled();
mIsUserDictionaryAvailable = mUserDictionary.isEnabled();
resetContactsDictionary(oldContactsDictionary);
@ -1951,7 +1951,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
// take a noticeable delay to update them which may feel uneasy.
}
if (showingAddToDictionaryHint) {
if (mIsUserDictionaryAvaliable) {
if (mIsUserDictionaryAvailable) {
mSuggestionsView.showAddToDictionaryHint(
suggestion, mSettingsValues.mHintToSaveText);
} else {

View File

@ -134,7 +134,11 @@ public class UserDictionary extends ExpandableDictionary {
final Cursor cursor = getContext().getContentResolver()
.query(Words.CONTENT_URI, PROJECTION_QUERY, request.toString(),
requestArguments, null);
addWords(cursor);
try {
addWords(cursor);
} finally {
if (null != cursor) cursor.close();
}
}
public boolean isEnabled() {
@ -242,6 +246,5 @@ public class UserDictionary extends ExpandableDictionary {
cursor.moveToNext();
}
}
cursor.close();
}
}