當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。