当前位置: 首页>>代码示例>>Java>>正文


Java KeyEvent.getRepeatCount方法代码示例

本文整理汇总了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);
    }
 
开发者ID:AlpacaNotSheep,项目名称:hybrid,代码行数:27,代码来源:IndexWebActivity.java

示例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);
}
 
开发者ID:l465659833,项目名称:Bigbang,代码行数:17,代码来源:CountLinkMovementMethod.java

示例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);
}
 
开发者ID:YehtutHl,项目名称:myan,代码行数:26,代码来源:SmartMyan.java

示例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;
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:17,代码来源:HotspotMainActivity.java

示例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;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:20,代码来源:AppMenu.java

示例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));
        }
    }
}
 
开发者ID:XFY9326,项目名称:EarPhoneKeySet,代码行数:26,代码来源:EarPhoneSetService.java

示例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);
}
 
开发者ID:shenhuanet,项目名称:OpenEyesReading-android,代码行数:10,代码来源:BaseActivity.java

示例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;
}
 
开发者ID:treasure-lau,项目名称:Linphone4Android,代码行数:11,代码来源:LinphoneUtils.java

示例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;
	}
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:39,代码来源:DownloadServiceLifecycleSupport.java

示例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);
}
 
开发者ID:gigabytedevelopers,项目名称:FireFiles,代码行数:13,代码来源:FabSpeedDial.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:9,代码来源:LitePlayerStartActivity.java

示例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);
}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:8,代码来源:UserCouponActivity.java

示例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);
}
 
开发者ID:eyeRS,项目名称:eyeRS,代码行数:11,代码来源:ShareActivity.java

示例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);
}
 
开发者ID:zhuangzaiku,项目名称:AndroidCollection,代码行数:15,代码来源:EarphoneActivity.java

示例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);
}
 
开发者ID:mercuriete,项目名称:android-mrz-reader,代码行数:41,代码来源:CaptureActivity.java


注:本文中的android.view.KeyEvent.getRepeatCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。