当前位置: 首页>>代码示例>>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;未经允许,请勿转载。