diff options
author | 2013-04-10 22:05:34 +0900 | |
---|---|---|
committer | 2013-04-12 20:53:06 +0900 | |
commit | 02ce3dc2d11aba2b521f85223af1f870207b81dc (patch) | |
tree | cc92e97d9c34236d4cdbf770dc0dd0366e92e6dd /java/src/com/android/inputmethod/latin/CompletionInfoUtils.java | |
parent | d24f93971292451c7a16456fecb8eff5deaa2c37 (diff) | |
download | latinime-02ce3dc2d11aba2b521f85223af1f870207b81dc.tar.gz latinime-02ce3dc2d11aba2b521f85223af1f870207b81dc.tar.xz latinime-02ce3dc2d11aba2b521f85223af1f870207b81dc.zip |
Fix a bug with bad application completions
Bug: 8561056
Change-Id: I91fb0ac76dabfc841bafc0e2c0ea9f63e6f604f9
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); + } +} |