Merge "Cleanup."

This commit is contained in:
Jean Chalard 2011-11-21 00:53:49 -08:00 committed by Android (Google) Code Review
commit ce86e39e00
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 UserDictionary mUserDictionary;
private UserBigramDictionary mUserBigramDictionary; private UserBigramDictionary mUserBigramDictionary;
private UserUnigramDictionary mUserUnigramDictionary; private UserUnigramDictionary mUserUnigramDictionary;
private boolean mIsUserDictionaryAvaliable; private boolean mIsUserDictionaryAvailable;
// TODO: Create an inner class to group options and pseudo-options to improve readability. // TODO: Create an inner class to group options and pseudo-options to improve readability.
// These variables are initialized according to the {@link EditorInfo#inputType}. // These variables are initialized according to the {@link EditorInfo#inputType}.
@ -582,7 +582,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
mUserDictionary = new UserDictionary(this, localeStr); mUserDictionary = new UserDictionary(this, localeStr);
mSuggest.setUserDictionary(mUserDictionary); mSuggest.setUserDictionary(mUserDictionary);
mIsUserDictionaryAvaliable = mUserDictionary.isEnabled(); mIsUserDictionaryAvailable = mUserDictionary.isEnabled();
resetContactsDictionary(oldContactsDictionary); resetContactsDictionary(oldContactsDictionary);
@ -2007,7 +2007,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
// take a noticeable delay to update them which may feel uneasy. // take a noticeable delay to update them which may feel uneasy.
} }
if (showingAddToDictionaryHint) { if (showingAddToDictionaryHint) {
if (mIsUserDictionaryAvaliable) { if (mIsUserDictionaryAvailable) {
mSuggestionsView.showAddToDictionaryHint( mSuggestionsView.showAddToDictionaryHint(
suggestion, mSettingsValues.mHintToSaveText); suggestion, mSettingsValues.mHintToSaveText);
} else { } else {

View file

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