Example usage for android.view KeyEvent getRepeatCount

List of usage examples for android.view KeyEvent getRepeatCount

Introduction

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

Prototype

public final int getRepeatCount() 

Source Link

Document

Retrieve the repeat count of the event.

Usage

From source file:com.ichi2.anki2.CardBrowser.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
        Log.i(AnkiDroidApp.TAG, "CardBrowser - onBackPressed()");
        if (mSearchEditText.getText().length() == 0) {
            closeCardBrowser(Activity.RESULT_OK);
        } else {/*from  w w w.  j a va 2s  .  c o  m*/
            mSearchEditText.setText("");
            mSearchEditText.setHint(R.string.downloaddeck_search);
            mSelectedTags.clear();
        }
        return true;
    }

    return super.onKeyDown(keyCode, event);
}

From source file:com.hichinaschool.flashcards.anki.CardBrowser.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
        // Log.i(AnkiDroidApp.TAG, "CardBrowser - onBackPressed()");
        if (mSearchEditText.getText().length() == 0) {
            closeCardBrowser(Activity.RESULT_OK);
        } else {/*from  ww  w .ja v a 2s  .com*/
            mSearchEditText.setText("");
            mSearchEditText.setHint(R.string.downloaddeck_search);
            mSelectedTags.clear();
        }
        return true;
    }

    return super.onKeyDown(keyCode, event);
}

From source file:org.wso2.iot.agent.activities.AuthenticationActivity.java

/**
 * Show the license text retrieved from the server.
 *
 * @param licenseText Message text to be shown as the license.
 * @param title   Title of the license./*from www  .  j  ava  2s. c  o  m*/
 */
private void showAgreement(final String licenseText, final String title) {
    AuthenticationActivity.this.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            final Dialog dialog = new Dialog(context, R.style.Dialog);
            dialog.setContentView(R.layout.dialog_license);
            dialog.setCancelable(false);

            WebView webView = (WebView) dialog.findViewById(R.id.webViewLicense);
            webView.loadDataWithBaseURL(null, licenseText, Constants.MIME_TYPE, Constants.ENCODING_METHOD,
                    null);

            TextView textViewTitle = (TextView) dialog.findViewById(R.id.textViewDeviceNameTitle);
            textViewTitle.setText(title);

            Button btnAgree = (Button) dialog.findViewById(R.id.dialogButtonOK);
            Button btnCancel = (Button) dialog.findViewById(R.id.dialogButtonCancel);

            btnAgree.setOnClickListener(new OnClickListener() {
                @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
                @Override
                public void onClick(View v) {
                    Preference.putBoolean(context, Constants.PreferenceFlag.IS_AGREED, true);
                    dialog.dismiss();
                    //load the next intent based on ownership type
                    startDeviceAdminPrompt();
                }
            });

            btnCancel.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    dialog.dismiss();
                    CommonUtils.clearClientCredentials(context);
                    cancelEntry();
                }
            });

            dialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
                @Override
                public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
                    if (keyCode == KeyEvent.KEYCODE_SEARCH
                            && event.getRepeatCount() == Constants.DEFAULT_REPEAT_COUNT) {
                        return true;
                    } else if (keyCode == KeyEvent.KEYCODE_BACK
                            && event.getRepeatCount() == Constants.DEFAULT_REPEAT_COUNT) {
                        return true;
                    }
                    return false;
                }
            });

            dialog.show();
        }
    });
}

From source file:com.speedtong.example.ui.chatting.ChattingActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
        LogUtil.d(TAG, "keycode back , chatfooter mode: " + mChattingFooter.getMode());
        if (!mChattingFooter.isButtomPanelNotVisibility()) {
            hideBottom();//from  www.  ja va2s. c o  m
            return true;
        }
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.esri.squadleader.view.SquadLeaderActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    boolean ret;//  w  ww  . j av  a  2  s .  c  o m
    if (KeyEvent.KEYCODE_BACK == keyCode && 0 == event.getRepeatCount()) {
        // Override the Back button when the feature popup bottom sheet is showing.
        ret = goBackFromPopupSheet();
        if (!ret) {
            ret = super.onKeyDown(keyCode, event);
        }
    } else {
        ret = super.onKeyDown(keyCode, event);
    }
    return ret;
}

From source file:com.hichinaschool.flashcards.anki.CardEditor.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
        // Log.i(AnkiDroidApp.TAG, "CardEditor - onBackPressed()");
        closeCardEditor();/*from   w  ww .j a v  a  2  s . com*/
        return true;
    }

    return super.onKeyDown(keyCode, event);
}

From source file:com.freerdp.freerdpcore.presentation.SessionActivity.java

@Override
public boolean onKeyDown(int keycode, KeyEvent event) {
    if (keycode == KeyEvent.KEYCODE_BACK && rladvertising.getVisibility() == View.VISIBLE) {
        try {/*from   ww  w.  j av a 2  s. c  o m*/
            connectCancelledByUser = true;
            rladvertising.stopPlay();
            rladvertising.getLock().notifyAll();
            LibFreeRDP.cancelConnection(session.getInstance());
        } catch (Exception e) {

        }
        finish();
        return false;
    }

    if (event.getRepeatCount() == 0 && keycode == KeyEvent.KEYCODE_BACK) {
        event.startTracking();
        return true;
    }

    return keyboardMapper.processAndroidKeyEvent(event);
}

From source file:org.yammp.app.MusicPlaybackActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {

    int repcnt = event.getRepeatCount();

    switch (keyCode) {

    case KeyEvent.KEYCODE_DPAD_LEFT:
        if (!useDpadMusicControl()) {
            break;
        }//from w ww.j a va  2 s.  c om
        if (!mPrevButton.hasFocus()) {
            mPrevButton.requestFocus();
        }
        scanBackward(repcnt, event.getEventTime() - event.getDownTime());
        return true;
    case KeyEvent.KEYCODE_DPAD_RIGHT:
        if (!useDpadMusicControl()) {
            break;
        }
        if (!mNextButton.hasFocus()) {
            mNextButton.requestFocus();
        }
        scanForward(repcnt, event.getEventTime() - event.getDownTime());
        return true;

    // case KeyEvent.KEYCODE_R:
    // toggleRepeat();
    // return true;
    //
    // case KeyEvent.KEYCODE_S:
    // toggleShuffle();
    // return true;

    case KeyEvent.KEYCODE_N:
        if (mService != null) {
            try {
                mService.next();
                return true;
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        } else
            return false;

    case KeyEvent.KEYCODE_P:
        if (mService != null) {
            try {
                mService.prev();
                return true;
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        } else
            return false;

    case KeyEvent.KEYCODE_DPAD_CENTER:
    case KeyEvent.KEYCODE_SPACE:
        doPauseResume();
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.android.app.MediaPlaybackActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    int direction = -1;
    int repcnt = event.getRepeatCount();

    if ((seekmethod == 0) ? seekMethod1(keyCode) : seekMethod2(keyCode))
        return true;

    switch (keyCode) {
    /*/*  w ww. j a  va  2  s.co m*/
    // image scale
    case KeyEvent.KEYCODE_Q: av.adjustParams(-0.05, 0.0, 0.0, 0.0, 0.0,-1.0); break;
    case KeyEvent.KEYCODE_E: av.adjustParams( 0.05, 0.0, 0.0, 0.0, 0.0, 1.0); break;
    // image translate
    case KeyEvent.KEYCODE_W: av.adjustParams(    0.0, 0.0,-1.0, 0.0, 0.0, 0.0); break;
    case KeyEvent.KEYCODE_X: av.adjustParams(    0.0, 0.0, 1.0, 0.0, 0.0, 0.0); break;
    case KeyEvent.KEYCODE_A: av.adjustParams(    0.0,-1.0, 0.0, 0.0, 0.0, 0.0); break;
    case KeyEvent.KEYCODE_D: av.adjustParams(    0.0, 1.0, 0.0, 0.0, 0.0, 0.0); break;
    // camera rotation
    case KeyEvent.KEYCODE_R: av.adjustParams(    0.0, 0.0, 0.0, 0.0, 0.0,-1.0); break;
    case KeyEvent.KEYCODE_U: av.adjustParams(    0.0, 0.0, 0.0, 0.0, 0.0, 1.0); break;
    // camera translate
    case KeyEvent.KEYCODE_Y: av.adjustParams(    0.0, 0.0, 0.0, 0.0,-1.0, 0.0); break;
    case KeyEvent.KEYCODE_N: av.adjustParams(    0.0, 0.0, 0.0, 0.0, 1.0, 0.0); break;
    case KeyEvent.KEYCODE_G: av.adjustParams(    0.0, 0.0, 0.0,-1.0, 0.0, 0.0); break;
    case KeyEvent.KEYCODE_J: av.adjustParams(    0.0, 0.0, 0.0, 1.0, 0.0, 0.0); break;
            
    */

    case KeyEvent.KEYCODE_SLASH:
        seekmethod = 1 - seekmethod;
        return true;

    case KeyEvent.KEYCODE_DPAD_LEFT:
        if (!useDpadMusicControl()) {
            break;
        }
        if (!mPrevButton.hasFocus()) {
            mPrevButton.requestFocus();
        }
        scanBackward(repcnt, event.getEventTime() - event.getDownTime());
        return true;
    case KeyEvent.KEYCODE_DPAD_RIGHT:
        if (!useDpadMusicControl()) {
            break;
        }
        if (!mNextButton.hasFocus()) {
            mNextButton.requestFocus();
        }
        scanForward(repcnt, event.getEventTime() - event.getDownTime());
        return true;

    case KeyEvent.KEYCODE_S:
        toggleShuffle();
        return true;

    case KeyEvent.KEYCODE_DPAD_CENTER:
    case KeyEvent.KEYCODE_SPACE:
        doPauseResume();
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:org.musicmod.android.app.MusicPlaybackActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {

    int repcnt = event.getRepeatCount();

    switch (keyCode) {

    case KeyEvent.KEYCODE_DPAD_LEFT:
        if (!useDpadMusicControl()) {
            break;
        }/*from  ww  w.  j a  v a  2  s. co  m*/
        if (!mPrevButton.hasFocus()) {
            mPrevButton.requestFocus();
        }
        scanBackward(repcnt, event.getEventTime() - event.getDownTime());
        return true;
    case KeyEvent.KEYCODE_DPAD_RIGHT:
        if (!useDpadMusicControl()) {
            break;
        }
        if (!mNextButton.hasFocus()) {
            mNextButton.requestFocus();
        }
        scanForward(repcnt, event.getEventTime() - event.getDownTime());
        return true;

    //         case KeyEvent.KEYCODE_R:
    //            toggleRepeat();
    //            return true;
    //
    //         case KeyEvent.KEYCODE_S:
    //            toggleShuffle();
    //            return true;

    case KeyEvent.KEYCODE_N:
        if (mService != null) {
            try {
                mService.next();
                return true;
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        } else {
            return false;
        }

    case KeyEvent.KEYCODE_P:
        if (mService != null) {
            try {
                mService.prev();
                return true;
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        } else {
            return false;
        }

    case KeyEvent.KEYCODE_DPAD_CENTER:
    case KeyEvent.KEYCODE_SPACE:
        doPauseResume();
        return true;
    }
    return super.onKeyDown(keyCode, event);
}