Example usage for android.view KeyEvent getAction

List of usage examples for android.view KeyEvent getAction

Introduction

In this page you can find the example usage for android.view KeyEvent getAction.

Prototype

public final int getAction() 

Source Link

Document

Retrieve the action of this key event.

Usage

From source file:study.tdcc.act.MainCalendar.java

/**
 * ??// ww  w  .  j ava2  s .  c  o m
 *
 * @param kEvent  
 * @return ?????true
 */
@Override
public boolean dispatchKeyEvent(KeyEvent kEvent) {
    Log.d("DEBUG", "MainCalendar dispatchKeyEvent Start");
    //?????
    if (kEvent.getAction() == KeyEvent.ACTION_DOWN) {
        //?????
        if (kEvent.getKeyCode() == KeyEvent.KEYCODE_BACK) {
            //?yes/no?
            showYesNoDialog(this, R.string.mes1_dialog, R.string.mes2_dialog,
                    new DialogInterface.OnClickListener() {
                        //??
                        public void onClick(DialogInterface dialog, int whith) {
                            if (whith == DialogInterface.BUTTON_POSITIVE) {
                                //
                                endActivity();
                            } else if (whith == DialogInterface.BUTTON_NEGATIVE) {
                                //
                                return;
                            }
                        }
                    });
        }
    }
    Log.d("DEBUG", "MainCalendar dispatchKeyEvent End");
    return super.dispatchKeyEvent(kEvent);
}

From source file:com.oakesville.mythling.MediaActivity.java

void initListViewDpadHandler() {
    if (getAppSettings().isTv()) {
        getListView().setOnKeyListener(new OnKeyListener() {
            public boolean onKey(View v, int keyCode, KeyEvent event) {
                if (event.getAction() == KeyEvent.ACTION_DOWN) {
                    if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_RIGHT) {
                        Listable listable = getListables().get(getSelItemIndex());
                        if (listable instanceof Category) {
                            getListView().performItemClick(getListAdapter().getView(selItemIndex, null, null),
                                    selItemIndex, getListAdapter().getItemId(selItemIndex));
                            return true;
                        } else if (isSplitView()) {
                            getListAdapter().setSelection(selItemIndex);
                            getListView().setItemChecked(selItemIndex, true);
                            showItemInDetailPane(selItemIndex, true);
                            return true;
                        }// w  w  w  . j a va 2 s .co m
                    } else if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_LEFT && !"".equals(getPath())) {
                        onBackPressed();
                        return true;
                    }
                }
                return false;
            }
        });
    }
}

From source file:com.tct.mail.ui.ConversationListFragment.java

@Override
public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {
    SwipeableListView list = (SwipeableListView) view;
    // Don't need to handle ENTER because it's auto-handled as a "click".
    if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
        if (keyEvent.getAction() == KeyEvent.ACTION_UP) {
            if (mKeyInitiatedFromList) {
                onListItemSelected(list.getSelectedView(), list.getSelectedItemPosition());
            }// w ww . j av a2s  .  com
            mKeyInitiatedFromList = false;
        } else if (keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
            mKeyInitiatedFromList = true;
        }
        return true;
    } else if (keyEvent.getAction() == KeyEvent.ACTION_UP) {
        if (keyCode == KeyEvent.KEYCODE_DPAD_UP || keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
            final int position = list.getSelectedItemPosition();
            final Object item = getAnimatedAdapter().getItem(position);
            if (item != null && item instanceof ConversationCursor) {
                final Conversation conv = ((ConversationCursor) item).getConversation();
                mCallbacks.onConversationFocused(conv);
            }
        }
    }
    return false;
}

From source file:beichen.douban.ui.view.LazyViewPager.java

/**
 * You can call this function yourself to have the scroll view perform
 * scrolling from a key event, just as if the event had been dispatched to
 * it by the view hierarchy./*w  w w. ja  va  2 s .c o m*/
 * 
 * @param event
 *            The key event to execute.
 * @return Return true if the event was handled, else false.
 */
public boolean executeKeyEvent(KeyEvent event) {
    boolean handled = false;
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_DPAD_LEFT:
            handled = arrowScroll(FOCUS_LEFT);
            break;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            handled = arrowScroll(FOCUS_RIGHT);
            break;
        case KeyEvent.KEYCODE_TAB:
            if (Build.VERSION.SDK_INT >= 11) {
                // The focus finder had a bug handling FOCUS_FORWARD and
                // FOCUS_BACKWARD
                // before Android 3.0. Ignore the tab key on those
                // devices.
                if (KeyEventCompat.hasNoModifiers(event)) {
                    handled = arrowScroll(FOCUS_FORWARD);
                } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) {
                    handled = arrowScroll(FOCUS_BACKWARD);
                }
            }
            break;
        }
    }
    return handled;
}

From source file:android.support.v7.widget.AbstractXpListPopupWindow.java

/**
 * Filter pre-IME key events. By forwarding {@link View#onKeyPreIme(int, KeyEvent)}
 * events to this function, views using ListPopupWindow can have it dismiss the popup
 * when the back key is pressed.//from  w  w w  .  ja  va 2s  . co m
 *
 * @param keyCode keyCode param passed to the host view's onKeyPreIme
 * @param event event param passed to the host view's onKeyPreIme
 * @return true if the event was handled, false if it was ignored.
 * @see #setModal(boolean)
 */
public boolean onKeyPreIme(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && isShowing()) {
        // special case for the back key, we do not even try to send it
        // to the drop down list but instead, consume it immediately
        final View anchorView = mDropDownAnchorView;
        if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
            KeyEvent.DispatcherState state = anchorView.getKeyDispatcherState();
            if (state != null) {
                state.startTracking(event, this);
            }
            return true;
        } else if (event.getAction() == KeyEvent.ACTION_UP) {
            KeyEvent.DispatcherState state = anchorView.getKeyDispatcherState();
            if (state != null) {
                state.handleUpEvent(event);
            }
            if (event.isTracking() && !event.isCanceled()) {
                dismiss();
                return true;
            }
        }
    }
    return false;
}

From source file:cn.xiaowen.news.view.LazyViewPager.java

/**
 * You can call this function yourself to have the scroll view perform
 * scrolling from a key event, just as if the event had been dispatched to
 * it by the view hierarchy./*from  w  ww . j  a va 2 s.  c o m*/
 * 
 * @param event
 *            The key event to execute.
 * @return Return true if the event was handled, else false.
 */
public boolean executeKeyEvent(KeyEvent event) {
    boolean handled = false;
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_DPAD_LEFT:
            handled = arrowScroll(FOCUS_LEFT);
            break;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            handled = arrowScroll(FOCUS_RIGHT);
            break;
        case KeyEvent.KEYCODE_TAB:
            if (Build.VERSION.SDK_INT >= 11) {
                // The focus finder had a bug handling FOCUS_FORWARD and
                // FOCUS_BACKWARD
                // before Android 3.0. Ignore the tab key on those devices.
                if (KeyEventCompat.hasNoModifiers(event)) {
                    handled = arrowScroll(FOCUS_FORWARD);
                } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) {
                    handled = arrowScroll(FOCUS_BACKWARD);
                }
            }
            break;
        }
    }
    return handled;
}

From source file:dev.memento.MainActivity.java

private void initUI() {

    mDateChosenButton = (Button) findViewById(R.id.dateChosen);
    mDateDisplayedView = (TextView) findViewById(R.id.dateDisplayed);
    mNowButton = (Button) findViewById(R.id.nowButton);
    mNowButton.setEnabled(false);//from w  ww .  ja  v  a 2 s  .c om

    mPageLoadingProgressBar = (ProgressBar) findViewById(R.id.pageLoadProgressBar);
    mPageLoadingProgressBar.setVisibility(View.GONE);

    mMementoProgressBar = (ProgressBar) findViewById(R.id.loadMementosProgressBar);
    mMementoProgressBar.setVisibility(View.GONE);

    mLocation = (AutoCompleteTextView) findViewById(R.id.locationEditText);

    // Load list of popular URLs so they are easier to enter 
    String[] defaultSites = getResources().getStringArray(R.array.defaultWebsites);
    if (mLocationAdapter == null)
        mLocationAdapter = new LocationAutoCompleteAdapter(this, android.R.layout.simple_dropdown_item_1line,
                defaultSites);

    mLocation.setAdapter(mLocationAdapter);
    mLocation.setFocusableInTouchMode(true);
    mLocation.setOnKeyListener(new OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {

            // Go to URL if user presses enter
            if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER) {

                String url = Utilities.fixUrl(mLocation.getText().toString());
                if (Utilities.isArchiveUrl(url)) {
                    // Don't do anything but load the URL
                    if (Log.LOG)
                        Log.d(LOG_TAG, "Loading archive URL " + url);
                } else if (Utilities.isValidUrl(url)) {
                    // Always bounce to the present when the user types a URL

                    mOriginalUrl = url;
                    if (Log.LOG)
                        Log.d(LOG_TAG, "Browsing to NOW " + url);

                    mLocationAdapter.add(url);
                    resetMementoButtons();
                    mCurrentMemento = null;

                    // Clear since we are visiting a different page in the present
                    mMementos.clear();

                    surfToUrl(mOriginalUrl);

                    // Hide the virtual keyboard
                    ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE))
                            .hideSoftInputFromWindow(mLocation.getWindowToken(), 0);

                    mWebview.requestFocus();

                    return true;
                } else {
                    MainActivity.this.showToast("Please enter a valid URL.");

                    // Put focus back in text box
                    mHandler.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            mLocation.requestFocus();

                            // Select all text
                            mLocation.setSelection(0, mLocation.getText().length());
                        }
                    }, 200);

                    return true;
                }
            }

            return false;
        }
    });

    mNextButton = (ImageButton) findViewById(R.id.next);
    setImageButtonEnabled(false, mNextButton, R.drawable.next_item);
    mNextButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // Advance to next Memento
            Memento nextMemento = null;

            // This could happen if the index has not been set yet
            if (mMementos.getCurrentIndex() < 0) {
                int index = mMementos.getIndexByDate(mDateDisplayed);
                if (index < 0) {
                    if (Log.LOG)
                        Log.d(LOG_TAG, "Could not find Memento with date " + mDateDisplayed + " ("
                                + mMementos.size() + " mementos). Try to find next another way.");

                    // Try alternative way of getting the next memento
                    nextMemento = mMementos.getNext(mDateDisplayed);
                } else {
                    mMementos.setCurrentIndex(index);
                    nextMemento = mMementos.getNext();
                }
            } else {
                // Locate the next Memento in the list
                nextMemento = mMementos.getNext();
            }

            if (nextMemento == null) {
                // This could happen if we got redirected to the memento and didn't know
                // it was the last memento, so the Next button was not disabled
                if (Log.LOG)
                    Log.d(LOG_TAG, "Still could not find next Memento.");
                if (Log.LOG)
                    Log.d(LOG_TAG, "Current index is " + mMementos.getCurrentIndex());
                setImageButtonEnabled(false, mNextButton, R.drawable.next_item);
            } else {
                SimpleDateTime date = nextMemento.getDateTime();
                //setChosenDate(nextMemento.getDateTime());
                showToast("Time traveling to next Memento on " + date.dateFormatted());
                if (Log.LOG)
                    Log.d(LOG_TAG, "Going to next Memento on " + date);

                mDateDisplayed = date;

                mCurrentMemento = nextMemento;
                String redirectUrl = nextMemento.getUrl();
                surfToUrl(redirectUrl);

                // Just in case it wasn't already enabled
                //mPreviousButton.setEnabled(true);
                MainActivity.this.setImageButtonEnabled(true, mPreviousButton, R.drawable.previous_item);

                // If this is the last memento, disable button
                if (mMementos.isLast(date))
                    setImageButtonEnabled(false, mNextButton, R.drawable.next_item);
            }
        }
    });

    mPreviousButton = (ImageButton) findViewById(R.id.previous);
    setImageButtonEnabled(false, mPreviousButton, R.drawable.previous_item);
    mPreviousButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // Advance to previous Memento
            Memento prevMemento = null;

            // This could happen if the index has not been set yet
            if (mMementos.getCurrentIndex() < 0) {
                int index = mMementos.getIndexByDate(mDateDisplayed);
                if (index < 0) {
                    if (Log.LOG)
                        Log.d(LOG_TAG, "Could not find Memento with date " + mDateDisplayed + " ("
                                + mMementos.size() + " mementos). Try to find previous" + " another way.");

                    // Try alternative way of getting the pervious memento
                    prevMemento = mMementos.getPrevious(mDateDisplayed);
                } else {
                    mMementos.setCurrentIndex(index);
                    prevMemento = mMementos.getPrevious();
                }
            } else {
                // Locate the prev Memento in the list
                prevMemento = mMementos.getPrevious();
            }

            if (prevMemento == null) {
                if (Log.LOG)
                    Log.d(LOG_TAG, "Still could not find previous Memento!");
                if (Log.LOG)
                    Log.d(LOG_TAG, "Current index is " + mMementos.getCurrentIndex());
                setImageButtonEnabled(false, mPreviousButton, R.drawable.previous_item);
            } else {
                SimpleDateTime date = prevMemento.getDateTime();

                showToast("Time traveling to previous Memento on " + date.dateFormatted());
                if (Log.LOG)
                    Log.d(LOG_TAG, "Going to previous Memento on " + date);

                mDateDisplayed = date;

                mCurrentMemento = prevMemento;
                String redirectUrl = prevMemento.getUrl();
                surfToUrl(redirectUrl);

                // Just in case it wasn't already enabled
                setImageButtonEnabled(true, mNextButton, R.drawable.next_item);

                // If this is the first memento, disable button
                if (mMementos.isFirst(date))
                    setImageButtonEnabled(false, mPreviousButton, R.drawable.previous_item);
            }
        }
    });

    // Idea to use placeholder and handle orientation changes ourself is from here:
    // http://www.devahead.com/blog/2012/01/preserving-the-state-of-an-android-webview-on-screen-orientation-change/
    webViewPlaceholder = ((FrameLayout) findViewById(R.id.webViewPlaceholder));
    if (mWebview == null) {
        mWebview = new WebView(this);
        mWebview.setLayoutParams(
                new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        mWebview.getSettings().setSupportZoom(true);
        mWebview.getSettings().setBuiltInZoomControls(true);
        mWebview.getSettings().setLoadWithOverviewMode(true);

        // Setting to true allows the zoom-in to work, but problems moving around.
        // Sometimes the underlying webview library also set faults and crashes the app
        // http://stackoverflow.com/questions/17187338/android-fatal-signal-11-sigsegv-in-webviewcorethre
        // Safer to leave off although zoom won't work. 
        //mWebview.getSettings().setUseWideViewPort(true);

        mWebview.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
        mWebview.setScrollbarFadingEnabled(true);
        mWebview.getSettings().setLoadsImagesAutomatically(true);
        mWebview.getSettings().setJavaScriptEnabled(true);
        mWebview.setWebViewClient(new MementoWebViewClient());
        mWebview.setWebChromeClient(new MementoWebChromClient());
        mWebview.getSettings().setUserAgentString(mUserAgent);

        // Must be declared before favicons will be received
        // http://stackoverflow.com/questions/3462582/display-the-android-webviews-favicon           
        WebIconDatabase.getInstance().open(getDir("icons", MODE_PRIVATE).getPath());

        surfToUrl(mCurrentUrl);

        // Get focus away from location field
        mWebview.requestFocus();
    }

    webViewPlaceholder.addView(mWebview);

    mWebview.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {

            // Hide the virtual keyboard
            ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE))
                    .hideSoftInputFromWindow(mLocation.getWindowToken(), 0);

            return false;
        }
    });
}

From source file:com.fishstix.dosboxfree.DBGLSurfaceView.java

private boolean handleKey(int keyCode, final KeyEvent event) {
    if (mDebug)//w w  w . j  a v  a  2  s  .c  o  m
        Log.d("DosBoxTurbo", "handleKey keyCode=" + keyCode);
    int tKeyCode = 0;

    // check for xperia play back case
    if (keyCode == KeyEvent.KEYCODE_BACK && event.isAltPressed()) {
        int backval = customMap.get(DosBoxPreferences.XPERIA_BACK_BUTTON);
        if (backval > 0) {
            // Special Sony XPeria Play case
            if (mEnableDpad) {
                // FIRE2
                if ((mInputMode == INPUT_MODE_MOUSE) || (mInputMode == INPUT_MODE_REAL_MOUSE)) {
                    DosBoxControl.nativeMouse(0, 0, 0, 0, (event.getAction() == KeyEvent.ACTION_DOWN) ? 0 : 1,
                            BTN_B);
                } else if ((mInputMode == INPUT_MODE_JOYSTICK) || (mInputMode == INPUT_MODE_REAL_JOYSTICK)) {
                    DosBoxControl.nativeJoystick(0, 0, (event.getAction() == KeyEvent.ACTION_DOWN) ? 0 : 1,
                            BTN_B);
                }
            } else {
                // sony xperia play O (circle) button
                DosBoxControl.sendNativeKey(backval, (event.getAction() == KeyEvent.ACTION_DOWN), mModifierCtrl,
                        mModifierAlt, mModifierShift);
                return true; // consume event
            }
        }
        return true; // consume event
    }

    // Handle all other keyevents
    int value = customMap.get(keyCode);

    if (value > 0) {
        // found a valid mapping
        tKeyCode = getMappedKeyCode(value, event);
        if (tKeyCode > MAP_NONE) {
            DosBoxControl.sendNativeKey(tKeyCode, (event.getAction() == KeyEvent.ACTION_DOWN), mModifierCtrl,
                    mModifierAlt, mModifierShift);
            return true; // consume KeyEvent
        } else if (tKeyCode == MAP_EVENT_CONSUMED) {
            return true;
        }
    }

    if (keyCode == KeyEvent.KEYCODE_BACK) {
        // fishstix, allow remap of Android back button
        // catch no mapping
        if (event.getAction() == KeyEvent.ACTION_UP) {
            DBMenuSystem.doConfirmQuit(mParent);
        }
        return true;
    }

    switch (keyCode) {
    case KeyEvent.KEYCODE_UNKNOWN:
        break;

    default:
        boolean down = (event.getAction() == KeyEvent.ACTION_DOWN);
        if (mDebug)
            Log.d("DosBoxTurbo", "handleKey (default) keyCode=" + keyCode + " down=" + down);

        if (!down || (event.getRepeatCount() == 0)) {
            int unicode = event.getUnicodeChar();

            // filter system generated keys, but not hardware keypresses
            if ((event.isAltPressed() || event.isShiftPressed()) && (unicode == 0)
                    && ((event.getFlags() & KeyEvent.FLAG_FROM_SYSTEM) == 0))
                break;

            //fixed alt key problem for physical keyboard with only left alt
            if ((!mUseLeftAltOn) && (keyCode == KeyEvent.KEYCODE_ALT_LEFT)) {
                break;
            }

            if ((!mUseLeftAltOn) && (keyCode == KeyEvent.KEYCODE_SHIFT_RIGHT)) {
                break;
            }

            if ((keyCode > 255) || (unicode > 255)) {
                //unknown keys
                break;
            }

            keyCode = keyCode | (unicode << 8);

            long diff = event.getEventTime() - event.getDownTime();

            if (!down && (diff < 50)) {
                //simulate as long press
                if (mDebug)
                    Log.d("DosBoxTurbo", "LongPress consumed keyCode=" + keyCode + " down=" + down);
                mKeyHandler.removeMessages(keyCode);
                mKeyHandler.sendEmptyMessageDelayed(keyCode, BUTTON_REPEAT_DELAY - diff);
            } else if (down && mKeyHandler.hasMessages(keyCode)) {
                if (mDebug)
                    Log.d("DosBoxTurbo", "KeyUp consumed keyCode=" + keyCode + " down=" + down);
                //there is an key up in queue, should be repeated event
            } else {
                boolean result = DosBoxControl.sendNativeKey(keyCode, down, mModifierCtrl, mModifierAlt,
                        mModifierShift);
                if (!down) {
                    mModifierCtrl = false;
                    mModifierAlt = false;
                    mModifierShift = false;
                }
                return result;
            }
        }
    }

    return false;
}

From source file:com.free.searcher.MainFragment.java

private void initFind() {
    container = (RelativeLayout) activity.findViewById(R.id.layoutId);
    findBox = (EditText) container.findViewById(R.id.findBox);
    findBox.setText(currentSearching);//from   w ww .j  av  a2s .c o m
    findBox.setTypeface(Typeface.DEFAULT, Typeface.BOLD);

    findBox.setOnKeyListener(new OnKeyListener() {
        @SuppressWarnings("deprecation")
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            Log.d("onKey", "keyCode=" + keyCode + ",event=" + event + ",v=" + v);
            if ((event.getAction() == KeyEvent.ACTION_DOWN) && ((keyCode == KeyEvent.KEYCODE_ENTER))) {
                webView.findAllAsync(findBox.getText().toString());
            }
            return false;
        }
    });

    //      findBox.setOnFocusChangeListener(new OnFocusChangeListener() {
    //            @Override
    //            public void onFocusChange(View p1, boolean p2) {
    //               webView.findAllAsync(findBox.getText().toString());
    //            }
    //         });

    findRet = (TextView) container.findViewById(R.id.findRet);

    backButton = (Button) container.findViewById(R.id.backButton);
    backButton.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
    backButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (findBox.isFocused()) {
                webView.findAllAsync(findBox.getText().toString());
            }
            webView.requestFocus();
            webView.findNext(false);
        }
    });

    nextButton = (Button) container.findViewById(R.id.nextButton);
    nextButton.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
    nextButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (findBox.isFocused()) {
                webView.findAllAsync(findBox.getText().toString());
            }
            webView.requestFocus();
            webView.findNext(true);
        }
    });

    clearButton = (Button) container.findViewById(R.id.clearButton);
    clearButton.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
    clearButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            findBox.setText("");
            webView.findAllAsync(findBox.getText().toString());
            findBox.requestFocus();
        }
    });

    closeButton = (Button) container.findViewById(R.id.closeButton);
    closeButton.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
    closeButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            showFind = false;
            container.setVisibility(View.INVISIBLE);
        }
    });

    webView.findAllAsync(findBox.getText().toString());
    webView.setFindListener(new WebView.FindListener() {
        @Override
        public void onFindResultReceived(int p1, int p2, boolean p3) {
            findRet.setText((p1 + (p2 > 0 ? 1 : 0)) + "/" + p2);
        }
    });
    if (showFind) {
        container.setVisibility(View.VISIBLE);
    } else {
        container.setVisibility(View.INVISIBLE);
    }
}

From source file:android.support.v7ox.app.AppCompatDelegateImplV7.java

@Override
boolean dispatchKeyEvent(KeyEvent event) {
    if (event.getKeyCode() == KeyEvent.KEYCODE_MENU) {
        // If this is a MENU event, let the Activity have a go.
        if (mOriginalWindowCallback.dispatchKeyEvent(event)) {
            return true;
        }//from  w  w w.  j  a  v  a  2  s  .co m
    }

    final int keyCode = event.getKeyCode();
    final int action = event.getAction();
    final boolean isDown = action == KeyEvent.ACTION_DOWN;

    return isDown ? onKeyDown(keyCode, event) : onKeyUp(keyCode, event);
}