aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2013-05-15 11:26:02 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-05-15 11:26:02 -0700
commit1e08d3d25930696e4614db53765d063a67e2b09a (patch)
tree485161327ad5f2b85062cfe00367bc7c9f604ac4 /java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java
parentd53fb22a97c4e769f5bb5b5d7bd4d30a96490d7f (diff)
parent6191026ce4e4cc756f47135223f58318d35d3143 (diff)
downloadlatinime-1e08d3d25930696e4614db53765d063a67e2b09a.tar.gz
latinime-1e08d3d25930696e4614db53765d063a67e2b09a.tar.xz
latinime-1e08d3d25930696e4614db53765d063a67e2b09a.zip
am 6191026c: am 0caf3f6a: Merge "Introduce MoreSuggestionsListener class"
* commit '6191026ce4e4cc756f47135223f58318d35d3143': Introduce MoreSuggestionsListener class
Diffstat (limited to 'java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java')
-rw-r--r--java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java25
1 files changed, 23 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java
index 6509f394b..d585b5c7f 100644
--- a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java
+++ b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java
@@ -18,15 +18,21 @@ package com.android.inputmethod.latin.suggestions;
import android.content.Context;
import android.util.AttributeSet;
+import android.util.Log;
+import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.MoreKeysKeyboardView;
import com.android.inputmethod.latin.R;
+import com.android.inputmethod.latin.SuggestedWords;
+import com.android.inputmethod.latin.suggestions.MoreSuggestions.MoreSuggestionsListener;
/**
* A view that renders a virtual {@link MoreSuggestions}. It handles rendering of keys and detecting
* key presses and touch movements.
*/
public final class MoreSuggestionsView extends MoreKeysKeyboardView {
+ private static final String TAG = MoreSuggestionsView.class.getSimpleName();
+
public MoreSuggestionsView(final Context context, final AttributeSet attrs) {
this(context, attrs, R.attr.moreSuggestionsViewStyle);
}
@@ -54,9 +60,24 @@ public final class MoreSuggestionsView extends MoreKeysKeyboardView {
@Override
public void onCodeInput(final int code, final int x, final int y) {
+ final Keyboard keyboard = getKeyboard();
+ if (!(keyboard instanceof MoreSuggestions)) {
+ Log.e(TAG, "Expected keyboard is MoreSuggestions, but found "
+ + keyboard.getClass().getName());
+ return;
+ }
+ final SuggestedWords suggestedWords = ((MoreSuggestions)keyboard).mSuggestedWords;
final int index = code - MoreSuggestions.SUGGESTION_CODE_BASE;
- if (index >= 0 && index < SuggestionStripView.MAX_SUGGESTIONS) {
- mListener.onCustomRequest(index);
+ if (index < 0 || index >= suggestedWords.size()) {
+ Log.e(TAG, "Selected suggestion has an illegal index: " + index);
+ return;
+ }
+ if (!(mListener instanceof MoreSuggestionsListener)) {
+ Log.e(TAG, "Expected mListener is MoreSuggestionsListener, but found "
+ + mListener.getClass().getName());
+ return;
}
+ ((MoreSuggestionsListener)mListener).onSuggestionSelected(
+ index, suggestedWords.getInfo(index));
}
}