List of usage examples for android.view KeyEvent getRepeatCount
public final int getRepeatCount()
From source file:com.chuhan.privatecalc.fragment.os.FragmentActivity.java
/** * Take care of calling onBackPressed() for pre-Eclair platforms. */// ww w. ja v a 2s . c o m @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (android.os.Build.VERSION.SDK_INT < 5 /* ECLAIR */ && keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { // Take care of calling this method on earlier versions of // the platform where it doesn't exist. onBackPressed(); return true; } return super.onKeyDown(keyCode, event); }
From source file:butter.droid.tv.fragments.TVPlaybackOverlayFragment.java
@Override public boolean handleInputEvent(@NonNull InputEvent event) { if (event instanceof KeyEvent) { KeyEvent keyEvent = (KeyEvent) event; if (keyEvent.getKeyCode() != KeyEvent.KEYCODE_DPAD_CENTER) return false; if (keyEvent.getAction() == KeyEvent.ACTION_DOWN) { if (mFastForwardAction != null && mSelectedActionId == mFastForwardAction.getId()) { if (keyEvent.getRepeatCount() == 0) { mCurrentMode = MODE_FAST_FORWARD; invokeFastForwardAction(); }/*from ww w .j a v a 2s. co m*/ } else if (mRewindAction != null && mSelectedActionId == mRewindAction.getId()) { if (keyEvent.getRepeatCount() == 0) { mCurrentMode = MODE_REWIND; invokeRewindAction(); } } } else if (keyEvent.getAction() == KeyEvent.ACTION_UP) { mCurrentMode = MODE_NOTHING; } } return false; }
From source file:org.hw.parlance.ParlanceActivity.java
public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_MENU && statusFragment != null) { if (event.getRepeatCount() < 1) { statusFragment.openOrCloseStatusBar(true); }/*www. j a va 2 s .c o m*/ } return super.onKeyDown(keyCode, event); }
From source file:org.mariotaku.harmony.activity.MusicPlaybackActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (mService == null) return super.onKeyDown(keyCode, event); final int repcnt = event.getRepeatCount(); switch (keyCode) { case KeyEvent.KEYCODE_DPAD_LEFT: if (!useDpadMusicControl()) { break; }//from w ww .j a v a 2s . c o 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: { doNext(); return true; } case KeyEvent.KEYCODE_P: { doPrev(); return true; } case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_SPACE: { doPauseResume(); return true; } } return super.onKeyDown(keyCode, event); }
From source file:com.xorcode.andtweet.PreferencesActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0 && overrideBackButton) { finish();//from w w w. j av a 2s. com this.sendBroadcast(new Intent(this, TweetListActivity.class)); return true; } // TODO Auto-generated method stub return super.onKeyDown(keyCode, event); }
From source file:dev.datvt.cloudtracks.song_player.PlayMusicActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { showFullAds();//w w w.j a v a 2 s .com Intent intent = new Intent(this, MainActivity.class); intent.putExtra("pos", curPos); setResult(ConstantHelper.RESULT_CODE_SHOW, intent); finish(); return true; } return super.onKeyDown(keyCode, event); }
From source file:org.puder.trs80.EmulatorActivity.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { if (gameController.dispatchKeyEvent(event)) { return true; }//from www. ja va2s. c o m boolean consumed = false; if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) { consumed = keyboardManager.keyDown(event); } if (event.getAction() == KeyEvent.ACTION_UP && event.getRepeatCount() == 0) { consumed = keyboardManager.keyUp(event); } return consumed || super.dispatchKeyEvent(event); }
From source file:com.yunluo.android.arcadehub.GameListActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { super.onKeyDown(keyCode, event); if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { exit();/*from ww w. j ava 2 s. c o m*/ return true; } return super.onKeyDown(keyCode, event); }
From source file:org.videolan.vlc.RemoteControlClientReceiver.java
@Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); KeyEvent event = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT); if (event != null && action.equalsIgnoreCase(Intent.ACTION_MEDIA_BUTTON)) { if (event.getKeyCode() != KeyEvent.KEYCODE_HEADSETHOOK && event.getKeyCode() != KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE && event.getAction() != KeyEvent.ACTION_DOWN) { super.onReceive(context, intent); return; }//from w w w . j a va 2 s .c o m Intent i = null; switch (event.getKeyCode()) { /* * one click => play/pause * long click => previous * double click => next */ case KeyEvent.KEYCODE_HEADSETHOOK: case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: long time = SystemClock.uptimeMillis(); switch (event.getAction()) { case KeyEvent.ACTION_DOWN: if (event.getRepeatCount() <= 0) mHeadsetDownTime = time; break; case KeyEvent.ACTION_UP: if (AndroidDevices.hasTsp()) { //no backward/forward on TV if (time - mHeadsetDownTime >= 1000) { // long click i = new Intent(PlaybackService.ACTION_REMOTE_BACKWARD, null, VLCApplication.getAppContext(), PlaybackService.class); break; } else if (time - mHeadsetUpTime <= 500) { // double click i = new Intent(PlaybackService.ACTION_REMOTE_FORWARD, null, VLCApplication.getAppContext(), PlaybackService.class); break; } } // one click i = new Intent(PlaybackService.ACTION_REMOTE_PLAYPAUSE, null, VLCApplication.getAppContext(), PlaybackService.class); mHeadsetUpTime = time; break; } break; case KeyEvent.KEYCODE_MEDIA_PLAY: context.startService(new Intent(PlaybackService.ACTION_REMOTE_PLAY, null, VLCApplication.getAppContext(), PlaybackService.class)); return; case KeyEvent.KEYCODE_MEDIA_PAUSE: i = new Intent(PlaybackService.ACTION_REMOTE_PAUSE, null, VLCApplication.getAppContext(), PlaybackService.class); break; case KeyEvent.KEYCODE_MEDIA_STOP: i = new Intent(PlaybackService.ACTION_REMOTE_STOP, null, VLCApplication.getAppContext(), PlaybackService.class); break; case KeyEvent.KEYCODE_MEDIA_NEXT: i = new Intent(PlaybackService.ACTION_REMOTE_FORWARD, null, VLCApplication.getAppContext(), PlaybackService.class); break; case KeyEvent.KEYCODE_MEDIA_PREVIOUS: i = new Intent(PlaybackService.ACTION_REMOTE_BACKWARD, null, VLCApplication.getAppContext(), PlaybackService.class); break; } if (isOrderedBroadcast()) abortBroadcast(); if (i != null) { context.startService(i); return; } } else if (action.equals(PlaybackService.ACTION_REMOTE_PLAYPAUSE)) { intent = new Intent(context, PlaybackService.class); intent.setAction(PlaybackService.ACTION_REMOTE_PLAYPAUSE); context.startService(intent); return; } super.onReceive(context, intent); }
From source file:org.wso2.emm.agent.AuthenticationActivity.java
/** * Show the license text retrieved from the server. * * @param message Message text to be shown as the license. * @param title Title of the license./*from ww w. java 2s . c o m*/ */ private void showAgreement(final String message, String title) { AuthenticationActivity.this.runOnUiThread(new Runnable() { @Override public void run() { final Dialog dialog = new Dialog(context); dialog.setContentView(R.layout.custom_terms_popup); dialog.setTitle(Constants.EULA_TITLE); dialog.setCancelable(false); WebView webView = (WebView) dialog.findViewById(R.id.webview); webView.loadDataWithBaseURL(null, message, Constants.MIME_TYPE, Constants.ENCODING_METHOD, null); Button dialogButton = (Button) dialog.findViewById(R.id.dialogButtonOK); Button cancelButton = (Button) dialog.findViewById(R.id.dialogButtonCancel); dialogButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Preference.putBoolean(context, Constants.PreferenceFlag.IS_AGREED, true); dialog.dismiss(); //load the next intent based on ownership type checkManifestPermissions(); } }); cancelButton.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.DEFAILT_REPEAT_COUNT) { return true; } else if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == Constants.DEFAILT_REPEAT_COUNT) { return true; } return false; } }); dialog.show(); } }); }