diff options
author | 2013-04-17 19:41:18 -0700 | |
---|---|---|
committer | 2013-04-17 19:41:18 -0700 | |
commit | fda69c44393698306341c334af2541e72774280e (patch) | |
tree | 4cd3143ba237a269081989296f603024b0cfb48d /java/src/com/android/inputmethod/latin/CompletionInfoUtils.java | |
parent | 5351510deaf225a0d1bd3856f1847bc775d1ddfc (diff) | |
parent | 991b1ef83e8f92c29ddec6685d91c24f1875eeba (diff) | |
download | latinime-fda69c44393698306341c334af2541e72774280e.tar.gz latinime-fda69c44393698306341c334af2541e72774280e.tar.xz latinime-fda69c44393698306341c334af2541e72774280e.zip |
am 991b1ef8: am 02ce3dc2: Fix a bug with bad application completions
* commit '991b1ef83e8f92c29ddec6685d91c24f1875eeba':
Fix a bug with bad application completions
Diffstat (limited to 'java/src/com/android/inputmethod/latin/CompletionInfoUtils.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/CompletionInfoUtils.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/latin/CompletionInfoUtils.java b/java/src/com/android/inputmethod/latin/CompletionInfoUtils.java new file mode 100644 index 000000000..792a446c9 --- /dev/null +++ b/java/src/com/android/inputmethod/latin/CompletionInfoUtils.java @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.inputmethod.latin; + +import android.text.TextUtils; +import android.view.inputmethod.CompletionInfo; + +import java.util.Arrays; + +/** + * Utilities to do various stuff with CompletionInfo. + */ +public class CompletionInfoUtils { + private CompletionInfoUtils() { + // This utility class is not publicly instantiable. + } + + public static CompletionInfo[] removeNulls(final CompletionInfo[] src) { + int j = 0; + final CompletionInfo[] dst = new CompletionInfo[src.length]; + for (int i = 0; i < src.length; ++i) { + if (null != src[i] && !TextUtils.isEmpty(src[i].getText())) { + dst[j] = src[i]; + ++j; + } + } + return Arrays.copyOfRange(dst, 0, j); + } +} |