本文整理汇总了Java中android.view.KeyEvent.getRepeatCount方法的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.getRepeatCount方法的具体用法?Java KeyEvent.getRepeatCount怎么用?Java KeyEvent.getRepeatCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.KeyEvent
的用法示例。
在下文中一共展示了KeyEvent.getRepeatCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onKeyDown
import android.view.KeyEvent; //导入方法依赖的package包/类
/**
* 重写物理返回键
*
* @param keyCode
* @param event
* @return
*/
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
if (isSingleProductOrder){//如果是单项订单,返回到订单列表
// 返回订单列表页面
Intent intent = new Intent(this, OrderListNewActivity.class);
startActivity(intent);
finish();
}else{
callJs("andriodGoBack");
callJs("androidGoBack");
if (top_bar.getVisibility() == View.VISIBLE) {//如果加载了错误页面,那么点击返回回到应用首页
finish();
}
}
return true;
}
return super.onKeyDown(keyCode, event);
}
示例2: handleMovementKey
import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
protected boolean handleMovementKey(TextView widget, Spannable buffer, int keyCode,
int movementMetaState, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_CENTER:
case KeyEvent.KEYCODE_ENTER:
if (KeyEvent.metaStateHasNoModifiers(movementMetaState)) {
if (event.getAction() == KeyEvent.ACTION_DOWN &&
event.getRepeatCount() == 0 && action(CLICK, widget, buffer)) {
return true;
}
}
break;
}
return super.handleMovementKey(widget, buffer, keyCode, movementMetaState, event);
}
示例3: onKeyDown
import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
if (event.getRepeatCount() == 0 && mInputView != null) {
if (mInputView.handleBack()) {
return true;
}
}
break;
case KeyEvent.KEYCODE_DEL:
//if there is a currently composing text, modifying that instead of letting the app delete itself
if (mComposing.length() > 0) {
onKey(Keyboard.KEYCODE_DELETE, null);
return true;
}
break;
case KeyEvent.KEYCODE_ENTER:
//letting the underlying text editor always handle these
return false;
}
return super.onKeyDown(keyCode, event);
}
示例4: onKeyDown
import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
closeDrawerLayout();
}else {
if ((System.currentTimeMillis() - exitTime) > 2000) {
showToast(getString(R.string.confirm_exit_app));
exitTime = System.currentTimeMillis();
} else {
exitApp();
}
}
}
return true;
}
示例5: onKey
import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (mPopup == null || mPopup.getListView() == null) return false;
if (event.getKeyCode() == KeyEvent.KEYCODE_MENU) {
if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
event.startTracking();
v.getKeyDispatcherState().startTracking(event, this);
return true;
} else if (event.getAction() == KeyEvent.ACTION_UP) {
v.getKeyDispatcherState().handleUpEvent(event);
if (event.isTracking() && !event.isCanceled()) {
dismiss();
return true;
}
}
}
return false;
}
示例6: KeyUpAction
import android.view.KeyEvent; //导入方法依赖的package包/类
private void KeyUpAction(KeyEvent event, boolean longpressmode, int type) {
if (longpressmode) {
if (event.getRepeatCount() == 0) {
LongPressed = true;
setLongPressThread(type);
}
} else {
if (Methods.getLongPressCustom(sp)) {
if (event.getRepeatCount() == 0) {
LongPressed = true;
setLongPressThread(type);
}
} else {
int code;
if (type == 2) {
code = Methods.getKeyCodeDown(sp);
} else if (type == 1) {
code = Methods.getKeyCodeUp(sp);
} else {
code = 0;
}
Methods.sendKeyCode(this, code, process, output, Methods.getLongPressSend(sp));
}
}
}
示例7: onKeyDown
import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
// do something for activity
finish();
return true;
}
return super.onKeyDown(keyCode, event);
}
示例8: onKeyBackGoHome
import android.view.KeyEvent; //导入方法依赖的package包/类
public static boolean onKeyBackGoHome(Activity activity, int keyCode, KeyEvent event) {
if (!(keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0)) {
return false; // continue
}
activity.startActivity(new Intent()
.setAction(Intent.ACTION_MAIN)
.addCategory(Intent.CATEGORY_HOME));
return true;
}
示例9: handleKeyEvent
import android.view.KeyEvent; //导入方法依赖的package包/类
private void handleKeyEvent(KeyEvent event)
{
if (event.getAction() != KeyEvent.ACTION_DOWN || event.getRepeatCount() > 0)
{
return;
}
switch (event.getKeyCode())
{
case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
case KeyEvent.KEYCODE_HEADSETHOOK:
downloadService.togglePlayPause();
break;
case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
downloadService.previous();
break;
case KeyEvent.KEYCODE_MEDIA_NEXT:
if (downloadService.getCurrentPlayingIndex() < downloadService.size() - 1)
{
downloadService.next();
}
break;
case KeyEvent.KEYCODE_MEDIA_STOP:
downloadService.stop();
break;
case KeyEvent.KEYCODE_MEDIA_PLAY:
if (downloadService.getPlayerState() != PlayerState.STARTED)
{
downloadService.start();
}
break;
case KeyEvent.KEYCODE_MEDIA_PAUSE:
downloadService.pause();
break;
default:
break;
}
}
示例10: dispatchKeyEventPreIme
import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public boolean dispatchKeyEventPreIme(KeyEvent event) {
if (isMenuOpen()
&& event.getKeyCode() == KeyEvent.KEYCODE_BACK
&& event.getAction() == KeyEvent.ACTION_UP
&& event.getRepeatCount() == 0) {
closeMenu();
return true;
}
return super.dispatchKeyEventPreIme(event);
}
示例11: onKeyDown
import android.view.KeyEvent; //导入方法依赖的package包/类
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode != 4 || event.getRepeatCount() != 0 || !this.isLitePlayer) {
return super.onKeyDown(keyCode, event);
}
finish();
ActivityUtils.getInstance().removeAll();
return true;
}
示例12: onKeyDown
import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
this.finish();
}
return super.onKeyDown(keyCode, event);
}
示例13: onKeyDown
import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ECLAIR
&& keyCode == KeyEvent.KEYCODE_BACK
&& event.getRepeatCount() == 0) {
onBackPressed();
}
return super.onKeyDown(keyCode, event);
}
示例14: onKeyDown
import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
Log.d(TAG,"keyCode->" + keyCode);
if (KeyEvent.KEYCODE_HEADSETHOOK == keyCode) { //按下了耳机键
if (event.getRepeatCount() == 0) { //如果长按的话,getRepeatCount值会一直变大
//短按
Log.i(TAG,"短按->");
} else {
//长按
Log.i(TAG,"长按->" + event.getRepeatCount());
}
}
return super.onKeyDown(keyCode,event);
}
示例15: onKeyDown
import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
// First check if we're paused in continuous mode, and if so, just unpause.
if (isPaused) {
Log.d(TAG, "only resuming continuous recognition, not quitting...");
resumeContinuousDecoding();
return true;
}
// Exit the app if we're not viewing an OCR result.
if (lastResult == null) {
setResult(RESULT_CANCELED);
finish();
return true;
} else {
// Go back to previewing in regular OCR mode.
resetStatusView();
if (handler != null) {
handler.sendEmptyMessage(R.id.restart_preview);
}
return true;
}
} else if (keyCode == KeyEvent.KEYCODE_CAMERA) {
if (isContinuousModeActive) {
onShutterButtonPressContinuous();
} else {
handler.hardwareShutterButtonClick();
}
return true;
} else if (keyCode == KeyEvent.KEYCODE_FOCUS) {
// Only perform autofocus if user is not holding down the button.
if (event.getRepeatCount() == 0) {
cameraManager.requestAutoFocus(500L);
}
return true;
}
return super.onKeyDown(keyCode, event);
}