aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/compat/TextInfoCompatUtils.java
diff options
context:
space:
mode:
authorYohei Yukawa <yukawa@google.com>2014-07-09 14:59:20 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-07-09 14:59:20 +0000
commit757964ae46928536b3d19ef335147c10bd11050b (patch)
tree7d58c7ed98d5f90b2266fe00464f7335f3019e83 /java/src/com/android/inputmethod/compat/TextInfoCompatUtils.java
parent46111b79e6f11ef47c430e8f7050d2151fce1130 (diff)
parentfc137f35c8d7b03676475fbdeabdf82f89782419 (diff)
downloadlatinime-757964ae46928536b3d19ef335147c10bd11050b.tar.gz
latinime-757964ae46928536b3d19ef335147c10bd11050b.tar.xz
latinime-757964ae46928536b3d19ef335147c10bd11050b.zip
am fc137f35: Simplify the wrapper for TextInfo#getCharSequence
* commit 'fc137f35c8d7b03676475fbdeabdf82f89782419': Simplify the wrapper for TextInfo#getCharSequence
Diffstat (limited to 'java/src/com/android/inputmethod/compat/TextInfoCompatUtils.java')
-rw-r--r--java/src/com/android/inputmethod/compat/TextInfoCompatUtils.java14
1 files changed, 11 insertions, 3 deletions
diff --git a/java/src/com/android/inputmethod/compat/TextInfoCompatUtils.java b/java/src/com/android/inputmethod/compat/TextInfoCompatUtils.java
index 8bd919749..09f39a756 100644
--- a/java/src/com/android/inputmethod/compat/TextInfoCompatUtils.java
+++ b/java/src/com/android/inputmethod/compat/TextInfoCompatUtils.java
@@ -22,7 +22,6 @@ import com.android.inputmethod.annotations.UsedForTesting;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
-import java.util.Locale;
@UsedForTesting
public final class TextInfoCompatUtils {
@@ -50,9 +49,18 @@ public final class TextInfoCompatUtils {
sequenceNumber);
}
+ /**
+ * Returns the result of {@link TextInfo#getCharSequence()} when available. Otherwise returns
+ * the result of {@link TextInfo#getText()} as fall back.
+ * @param textInfo the instance for which {@link TextInfo#getCharSequence()} or
+ * {@link TextInfo#getText()} is called.
+ * @return the result of {@link TextInfo#getCharSequence()} when available. Otherwise returns
+ * the result of {@link TextInfo#getText()} as fall back. If {@code textInfo} is {@code null},
+ * returns {@code null}.
+ */
@UsedForTesting
- public static CharSequence getCharSequence(final TextInfo textInfo,
- final CharSequence defaultValue) {
+ public static CharSequence getCharSequenceOrString(final TextInfo textInfo) {
+ final CharSequence defaultValue = (textInfo == null ? null : textInfo.getText());
return (CharSequence) CompatUtils.invoke(textInfo, defaultValue,
TEXT_INFO_GET_CHAR_SEQUENCE);
}