當前位置: 首頁>>代碼示例>>Java>>正文


Java KeyEvent.ACTION_UP屬性代碼示例

本文整理匯總了Java中android.view.KeyEvent.ACTION_UP屬性的典型用法代碼示例。如果您正苦於以下問題:Java KeyEvent.ACTION_UP屬性的具體用法?Java KeyEvent.ACTION_UP怎麽用?Java KeyEvent.ACTION_UP使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.view.KeyEvent的用法示例。


在下文中一共展示了KeyEvent.ACTION_UP屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: dispatchKeyEvent

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    // To intercept hardware key, a view must have focus.
    if (mDelegate == null) return super.dispatchKeyEvent(event);

    if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
        KeyEvent.DispatcherState state = getKeyDispatcherState();
        if (state != null) {
            if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
                state.startTracking(event, this);
                return true;
            } else if (event.getAction() == KeyEvent.ACTION_UP && !event.isCanceled()
                    && state.isTracking(event)) {
                onBackPressed();
                return true;
            }
        }
    }

    return super.dispatchKeyEvent(event);
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:21,代碼來源:BookmarkSearchView.java

示例2: dispatchKeyEvent

@Override
public boolean dispatchKeyEvent(KeyEvent event)
{
	if(event.getAction() == KeyEvent.ACTION_DOWN)
	{
		switch(event.getKeyCode())
		{
			case KeyEvent.KEYCODE_BACK:
				mBackKeyDown = true;
				return true;
			default:
				mBackKeyDown = false;
				break;
		}
	}

	if(event.getAction() == KeyEvent.ACTION_UP)
	{
		switch(event.getKeyCode())
		{
			case KeyEvent.KEYCODE_BACK:
				if(mBackKeyDown)
				{
					mBackKeyDown = false;
					finish();
				}
				return true;

			default:
				mBackKeyDown = false;
				break;
		}
	}
	return super.dispatchKeyEvent(event);
}
 
開發者ID:monolifed,項目名稱:mininoteview,代碼行數:35,代碼來源:Settings.java

示例3: dispatchKeyEventPreIme

@Override
public boolean dispatchKeyEventPreIme(KeyEvent event) {
    if (event != null && event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
        return delegate != null && delegate.onPreIme() || super.dispatchKeyEventPreIme(event);
    }
    return super.dispatchKeyEventPreIme(event);
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:7,代碼來源:ActionBarLayout.java

示例4: onKeyPreIme

@Override
public boolean onKeyPreIme(int keyCode, KeyEvent event) {		
    if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
        if (mOnImeBack != null) mOnImeBack.onImeBack(this, this.getText().toString());
    }
    
    return super.dispatchKeyEvent(event);
}
 
開發者ID:Welloculus,項目名稱:MobileAppForPatient,代碼行數:8,代碼來源:AEditText.java

示例5: dispatchKeyEvent

/**
 * Called to process key events.  You can override this to intercept all
 * key events before they are dispatched to the window.  Be sure to call
 * this implementation for key events that should be handled normally.
 *
 * @param event The key event.
 *
 * @return boolean Return true if this event was consumed.
 */
public boolean dispatchKeyEvent(KeyEvent event) {
    onUserInteraction();

    // Let action bars open menus in response to the menu key prioritized over
    // the window handling it
    final int keyCode = event.getKeyCode();
    if (keyCode == KeyEvent.KEYCODE_MENU &&
            mActionBar != null && mActionBar.onMenuKeyEvent(event)) {
        return true;
    } else if (event.isCtrlPressed() &&
            event.getUnicodeChar(event.getMetaState() & ~KeyEvent.META_CTRL_MASK) == '<') {
        // Capture the Control-< and send focus to the ActionBar
        final int action = event.getAction();
        if (action == KeyEvent.ACTION_DOWN) {
            final ActionBar actionBar = getActionBar();
            if (actionBar != null && actionBar.isShowing() && actionBar.requestFocus()) {
                mEatKeyUpEvent = true;
                return true;
            }
        } else if (action == KeyEvent.ACTION_UP && mEatKeyUpEvent) {
            mEatKeyUpEvent = false;
            return true;
        }
    }

    Window win = getWindow();
    if (win.superDispatchKeyEvent(event)) {
        return true;
    }
    View decor = mDecor;
    if (decor == null) decor = win.getDecorView();
    return event.dispatch(this, decor != null
            ? decor.getKeyDispatcherState() : null, this);
}
 
開發者ID:JessYanCoding,項目名稱:ProgressManager,代碼行數:43,代碼來源:a.java

示例6: onKeyPreIme

@Override
public boolean onKeyPreIme(int keyCode, KeyEvent event) {
    if(event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
        onEditorAction(-1);
        dispatchKeyEvent(event);

        return false;
    }

    return super.onKeyPreIme(keyCode, event);
}
 
開發者ID:Samsung,項目名稱:microbit,代碼行數:11,代碼來源:ExtendedEditText.java

示例7: onKeyPreIme

@Override
public boolean onKeyPreIme(int keyCode, KeyEvent event) {
	if (event.getKeyCode() == KeyEvent.KEYCODE_BACK &&
				event.getAction() == KeyEvent.ACTION_UP) {
		if (mOnImeBack != null)
			mOnImeBack.onImeBack(this, this.getText().toString());
	}
	return super.dispatchKeyEvent(event);
}
 
開發者ID:SebastianRask,項目名稱:Pocket-Plays-for-Twitch,代碼行數:9,代碼來源:EditTextBackEvent.java

示例8: dispatchKeyEventPreIme

@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:Alcatraz323,項目名稱:MaterialOCR,代碼行數:12,代碼來源:FabSpeedDial.java

示例9: onKey

@Override
public boolean onKey(View view, int i, KeyEvent keyEvent) {
  if (keyEvent.getAction() == KeyEvent.ACTION_UP
      && keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
    tryMount();
    return true;
  }
  return false;
}
 
開發者ID:google,項目名稱:samba-documents-provider,代碼行數:9,代碼來源:MountServerActivity.java

示例10: dispatchKeyEvent

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    final int keyCode = event.getKeyCode();
    switch (keyCode) {
        case KeyEvent.KEYCODE_DPAD_CENTER:
        case KeyEvent.KEYCODE_ENTER:
            removeAllCallbacks();
            break;
        case KeyEvent.KEYCODE_DPAD_DOWN:
        case KeyEvent.KEYCODE_DPAD_UP:
            if (!mHasSelectorWheel) {
                break;
            }
            switch (event.getAction()) {
                case KeyEvent.ACTION_DOWN:
                    if (mWrapSelectorWheel || ((keyCode == KeyEvent.KEYCODE_DPAD_DOWN)
                            ? getValue() < getMaxValue() : getValue() > getMinValue())) {
                        requestFocus();
                        mLastHandledDownDpadKeyCode = keyCode;
                        removeAllCallbacks();
                        if (mFlingScroller.isFinished()) {
                            changeValueByOne(keyCode == KeyEvent.KEYCODE_DPAD_DOWN);
                        }
                        return true;
                    }
                    break;
                case KeyEvent.ACTION_UP:
                    if (mLastHandledDownDpadKeyCode == keyCode) {
                        mLastHandledDownDpadKeyCode = -1;
                        return true;
                    }
                    break;
            }
    }
    return super.dispatchKeyEvent(event);
}
 
開發者ID:Gericop,項目名稱:DateTimePicker,代碼行數:36,代碼來源:NumberPicker.java

示例11: dispatchKeyEvent

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (event.getKeyCode()) {
            case KeyEvent.KEYCODE_BACK:
                mBackDown = true;
                return true;
            case KeyEvent.KEYCODE_HOME:
                mHomeDown = true;
                return true;
        }
    } else if (event.getAction() == KeyEvent.ACTION_UP) {
        switch (event.getKeyCode()) {
            case KeyEvent.KEYCODE_BACK:
                if (!event.isCanceled()) {
                    // Do BACK behavior.
                }
                mBackDown = true;
                return true;
            case KeyEvent.KEYCODE_HOME:
                if (!event.isCanceled()) {
                    // Do HOME behavior.
                }
                mHomeDown = true;
                return true;
        }
    }

    return super.dispatchKeyEvent(event);
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:30,代碼來源:Home.java

示例12: onDispatchKeyEvent

@Override
public Boolean onDispatchKeyEvent(KeyEvent event) {
    int keyCode = event.getKeyCode();
    boolean isBackButton = keyCode == KeyEvent.KEYCODE_BACK;
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        if (isBackButton && mCustomView != null) {
            return true;
        } else if (boundKeyCodes.contains(keyCode)) {
            return true;
        } else if (isBackButton) {
            return engine.canGoBack();
        }
    } else if (event.getAction() == KeyEvent.ACTION_UP) {
        if (isBackButton && mCustomView != null) {
            hideCustomView();
            return true;
        } else if (boundKeyCodes.contains(keyCode)) {
            String eventName = null;
            switch (keyCode) {
                case KeyEvent.KEYCODE_VOLUME_DOWN:
                    eventName = "volumedownbutton";
                    break;
                case KeyEvent.KEYCODE_VOLUME_UP:
                    eventName = "volumeupbutton";
                    break;
                case KeyEvent.KEYCODE_SEARCH:
                    eventName = "searchbutton";
                    break;
                case KeyEvent.KEYCODE_MENU:
                    eventName = "menubutton";
                    break;
                case KeyEvent.KEYCODE_BACK:
                    eventName = "backbutton";
                    break;
            }
            if (eventName != null) {
                sendJavascriptEvent(eventName);
                return true;
            }
        } else if (isBackButton) {
            return engine.goBack();
        }
    }
    return null;
}
 
開發者ID:alex-shpak,項目名稱:keemob,代碼行數:45,代碼來源:CordovaWebViewImpl.java

示例13: onReceive

@Override
public void onReceive(final Context context, final Intent intent) {
    LogUtils.i(TAG, "Received intent: " + intent);
    final String intentAction = intent.getAction();
    if (AudioManager.ACTION_AUDIO_BECOMING_NOISY.equals(intentAction)) {
        startService(context, MusicServiceConstants.CMDPAUSE, System.currentTimeMillis());
    } else if (Intent.ACTION_MEDIA_BUTTON.equals(intentAction)) {
        final KeyEvent event = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
        if (event == null || event.getAction() != KeyEvent.ACTION_UP) {
            return;
        }

        String command = null;
        switch (event.getKeyCode()) {
            case KeyEvent.KEYCODE_HEADSETHOOK:
                command = MusicServiceConstants.CMDHEADSETHOOK;
                break;
            case KeyEvent.KEYCODE_MEDIA_STOP:
                command = MusicServiceConstants.CMDSTOP;
                break;
            case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
                command = MusicServiceConstants.CMDTOGGLEPAUSE;
                break;
            case KeyEvent.KEYCODE_MEDIA_NEXT:
                command = MusicServiceConstants.CMDNEXT;
                break;
            case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
                command = MusicServiceConstants.CMDPREVIOUS;
                break;
            case KeyEvent.KEYCODE_MEDIA_PAUSE:
                command = MusicServiceConstants.CMDPAUSE;
                break;
            case KeyEvent.KEYCODE_MEDIA_PLAY:
                command = MusicServiceConstants.CMDPLAY;
                break;
        }
        if (command != null) {
            startService(context, command, event.getEventTime());
            if (isOrderedBroadcast()) {
                abortBroadcast();
            }
        }
    }
}
 
開發者ID:komamj,項目名稱:KomaMusic,代碼行數:44,代碼來源:MediaButtonIntentReceiver.java

示例14: dispatchKeyEvent

@Override
public boolean dispatchKeyEvent(KeyEvent event)
{
	if(event.getAction() == KeyEvent.ACTION_DOWN)
	{
		switch(event.getKeyCode())
		{
			case KeyEvent.KEYCODE_MENU:
				myOpenMenu();
				return true;

			case KeyEvent.KEYCODE_BACK:
				mBackKeyDown = true;
				return true;

			case KeyEvent.KEYCODE_DPAD_LEFT:
				if(edit.getSelectionStart() == 0 && edit.getSelectionEnd() == 0)
				{
					closeFile();
					return true;
				}
			default:
				mBackKeyDown = false;
				break;
		}
	}

	if(event.getAction() == KeyEvent.ACTION_UP)
	{
		switch(event.getKeyCode())
		{
			case KeyEvent.KEYCODE_BACK:
				if(mBackKeyDown)
				{
					mBackKeyDown = false;
					closeFile();
					return true;
				}
				else
				{
					mBackKeyDown = false;
				}
			default:
				mBackKeyDown = false;
				break;
		}
	}
	return super.dispatchKeyEvent(event);
}
 
開發者ID:monolifed,項目名稱:mininoteview,代碼行數:49,代碼來源:TextEdit.java

示例15: onReceive

@Override
public void onReceive(Context context, Intent intent) {

    KeyEvent event = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
    if (event == null || event.getAction() != KeyEvent.ACTION_UP) {
        return;
    }

    IPlayControl control = MainActivity.getControl();
    if (control == null) {
        return;
    }

    try {

        switch (event.getKeyCode()) {
            case KeyEvent.KEYCODE_MEDIA_PLAY:
            case KeyEvent.KEYCODE_MEDIA_PAUSE:
            case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
            case KeyEvent.KEYCODE_HEADSETHOOK:
                // 暫停
                if (control.status() == PlayController.STATUS_PLAYING) {
                    control.pause();
                } else {
                    control.resume();
                }
                break;
            case KeyEvent.KEYCODE_MEDIA_NEXT:
                // 下一曲
                control.next();
                break;
            case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
                // 上一曲
                control.pre();
                break;
        }

    } catch (RemoteException e) {
        e.printStackTrace();
    }
}
 
開發者ID:DuanJiaNing,項目名稱:Musicoco,代碼行數:41,代碼來源:HeadphoneWireControlReceiver.java


注:本文中的android.view.KeyEvent.ACTION_UP屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。