Search in sources :

Example 1 with MoreSuggestionKey

use of com.android.inputmethod.latin.suggestions.MoreSuggestions.MoreSuggestionKey in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class MoreSuggestionsView method onKeyInput.

@Override
protected void onKeyInput(final Key key, final int x, final int y) {
    if (!(key instanceof MoreSuggestionKey)) {
        Log.e(TAG, "Expected key is MoreSuggestionKey, but found " + key.getClass().getName());
        return;
    }
    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 = ((MoreSuggestionKey) key).mSuggestedWordIndex;
    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(suggestedWords.getInfo(index));
}
Also used : Keyboard(com.android.inputmethod.keyboard.Keyboard) MoreSuggestionKey(com.android.inputmethod.latin.suggestions.MoreSuggestions.MoreSuggestionKey) SuggestedWords(com.android.inputmethod.latin.SuggestedWords)

Aggregations

Keyboard (com.android.inputmethod.keyboard.Keyboard)1 SuggestedWords (com.android.inputmethod.latin.SuggestedWords)1 MoreSuggestionKey (com.android.inputmethod.latin.suggestions.MoreSuggestions.MoreSuggestionKey)1