diff options
author | 2011-12-14 01:48:46 -0800 | |
---|---|---|
committer | 2011-12-14 01:48:46 -0800 | |
commit | 014b755f8a22c9b5cfc70fa3c80355543445feed (patch) | |
tree | 9aaa1bf1ae5400212c2188ea25625c72b5226645 /java/src | |
parent | 64361bd66d2d764bd5fb6486e9b9de5a3f2fb240 (diff) | |
parent | 601e411c139ae42ddb5db17e6e02dda6edd83770 (diff) | |
download | latinime-014b755f8a22c9b5cfc70fa3c80355543445feed.tar.gz latinime-014b755f8a22c9b5cfc70fa3c80355543445feed.tar.xz latinime-014b755f8a22c9b5cfc70fa3c80355543445feed.zip |
Merge "Cleanup KeyboardId's hasCode method"
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/KeyboardId.java | 66 |
1 files changed, 36 insertions, 30 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardId.java b/java/src/com/android/inputmethod/keyboard/KeyboardId.java index 46285bfb3..db5d8a84c 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardId.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardId.java @@ -104,23 +104,45 @@ public class KeyboardId { this.mEditorInfo = editorInfo; - this.mHashCode = Arrays.hashCode(new Object[] { - locale, - orientation, - width, - mode, - xmlId, - elementState, - mNavigateAction, - mPasswordInput, - mSettingsKeyEnabled, - mClobberSettingsKey, - shortcutKeyEnabled, - hasShortcutKey, - mImeAction, + this.mHashCode = hashCode(this); + } + + private static int hashCode(KeyboardId id) { + return Arrays.hashCode(new Object[] { + id.mOrientation, + id.mElementState, + id.mMode, + id.mWidth, + id.mXmlId, + id.mNavigateAction, + id.mPasswordInput, + id.mSettingsKeyEnabled, + id.mClobberSettingsKey, + id.mShortcutKeyEnabled, + id.mHasShortcutKey, + id.mImeAction, + id.mLocale, }); } + private boolean equals(KeyboardId other) { + if (other == this) + return true; + return other.mOrientation == this.mOrientation + && other.mElementState == this.mElementState + && other.mMode == this.mMode + && other.mWidth == this.mWidth + && other.mXmlId == this.mXmlId + && other.mNavigateAction == this.mNavigateAction + && other.mPasswordInput == this.mPasswordInput + && other.mSettingsKeyEnabled == this.mSettingsKeyEnabled + && other.mClobberSettingsKey == this.mClobberSettingsKey + && other.mShortcutKeyEnabled == this.mShortcutKeyEnabled + && other.mHasShortcutKey == this.mHasShortcutKey + && other.mImeAction == this.mImeAction + && other.mLocale.equals(this.mLocale); + } + public KeyboardId cloneWithNewXml(int xmlId) { return new KeyboardId(xmlId, mElementState, mLocale, mOrientation, mWidth, mMode, mEditorInfo, false, false, false, false); @@ -171,22 +193,6 @@ public class KeyboardId { return other instanceof KeyboardId && equals((KeyboardId) other); } - private boolean equals(KeyboardId other) { - return other.mLocale.equals(this.mLocale) - && other.mOrientation == this.mOrientation - && other.mWidth == this.mWidth - && other.mMode == this.mMode - && other.mXmlId == this.mXmlId - && other.mElementState == this.mElementState - && other.mNavigateAction == this.mNavigateAction - && other.mPasswordInput == this.mPasswordInput - && other.mSettingsKeyEnabled == this.mSettingsKeyEnabled - && other.mClobberSettingsKey == this.mClobberSettingsKey - && other.mShortcutKeyEnabled == this.mShortcutKeyEnabled - && other.mHasShortcutKey == this.mHasShortcutKey - && other.mImeAction == this.mImeAction; - } - @Override public int hashCode() { return mHashCode; |