Example usage for android.view KeyEvent getKeyCode

List of usage examples for android.view KeyEvent getKeyCode

Introduction

In this page you can find the example usage for android.view KeyEvent getKeyCode.

Prototype

public final int getKeyCode() 

Source Link

Document

Retrieve the key code of the key event.

Usage

From source file:org.uoyabause.android.tv.GameSelectActivity.java

@Override
public boolean dispatchKeyEvent(KeyEvent event) {

    InputDevice dev = InputDevice.getDevice(event.getDeviceId());
    if (dev != null && dev.getName().contains("HuiJia")) {
        if (event.getKeyCode() > 200) {
            return true;
        }//from  ww w .  j a  v  a  2s  .c  o m

    }
    return super.dispatchKeyEvent(event);
}

From source file:com.fragmentmaster.app.EventDispatcher.java

@Override
public boolean dispatchKeyShortcutEvent(KeyEvent event) {
    return mActivity.onKeyShortcut(event.getKeyCode(), event);
}

From source file:com.aevi.simpleexample.SecureCommunicationsActivity.java

private void setupSearchTextEnterListener() {
    EditText searchText = (EditText) findViewById(R.id.searchText);
    searchText.setImeActionLabel("Search", KeyEvent.KEYCODE_ENTER);

    searchText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override//from   w  w w.j  av  a  2  s  .c  o  m
        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if (keyEvent != null && keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER
                    && keyEvent.getAction() == keyEvent.ACTION_DOWN) {
                searchProjectsClick(textView);
                return true;
            }
            return false;
        }
    });
}

From source file:com.fragmentmaster.app.EventDispatcher.java

@Override
public boolean dispatchKeyShortcutEvent(KeyEvent event) {
    return mMasterFragment.onKeyShortcut(event.getKeyCode(), event);
}

From source file:com.mercandalli.android.apps.files.user.RegistrationFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_registration, container, false);
    this.mUsername = (EditText) rootView.findViewById(R.id.fragment_registration_username);
    this.mPassword = (EditText) rootView.findViewById(R.id.fragment_registration_password);

    ((CheckBox) rootView.findViewById(R.id.fragment_registration_auto_connection))
            .setChecked(Config.isAutoConnection());
    ((CheckBox) rootView.findViewById(R.id.fragment_registration_auto_connection))
            .setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override/*from   w ww . ja v a 2 s . c  om*/
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    Config.setAutoConnection(getContext(), isChecked);
                }
            });

    this.mUsername.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER))
                    || (actionId == EditorInfo.IME_ACTION_DONE)) {
                RegistrationFragment.this.mPassword.requestFocus();
                return true;
            }
            return false;
        }
    });

    this.mPassword.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER))
                    || (actionId == EditorInfo.IME_ACTION_DONE)) {
                inscription();
                return true;
            }
            return false;
        }
    });

    return rootView;
}

From source file:org.videolan.vlc.gui.MRLPanelFragment.java

@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
    if (keyCode == EditorInfo.IME_ACTION_DONE || keyCode == EditorInfo.IME_ACTION_GO
            || event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
        return processUri();
    }//ww  w .j  av a  2s  .c  o  m
    return false;
}

From source file:com.app.blockydemo.ui.fragment.FormulaEditorListFragment.java

@Override
public void onListItemClick(ListView listView, View view, int position, long id) {
    FormulaEditorFragment formulaEditor = (FormulaEditorFragment) getActivity().getSupportFragmentManager()
            .findFragmentByTag(FormulaEditorFragment.FORMULA_EDITOR_FRAGMENT_TAG);
    if (formulaEditor != null) {
        formulaEditor.addResourceToActiveFormula(itemsIds[position]);
        formulaEditor.updateButtonViewOnKeyboard();
    }/*from w w w .  j  ava2  s .com*/
    KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK);
    onKey(null, keyEvent.getKeyCode(), keyEvent);
}

From source file:com.github.yuukis.businessmap.app.MainActivity.java

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_BACK:
            // ?// w ww .j a  v  a 2  s  . c  o  m
            ContactsListFragment listFragment = (ContactsListFragment) getSupportFragmentManager()
                    .findFragmentById(R.id.contacts_list);
            if (listFragment != null && listFragment.getVisibility()) {
                // ????????
                listFragment.setVisibility(false);
                return true;
            }
        }
    }
    return super.dispatchKeyEvent(event);
}

From source file:com.mobivery.greent.MVYBatteryManagerActivityFragment.java

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    if (MVYBatterySaverManager.getInstance().areConnectionsManaged()) {
        if (event.getAction() == KeyEvent.ACTION_DOWN) {
            switch (event.getKeyCode()) {
            case KeyEvent.KEYCODE_BACK:
                m_isSendingToBackground = true;
                MVYBatterySaverManager.getInstance().sendAppToBackground();
                break;
            }//from  ww w.  j av a2  s.  c  o  m
        }
    }
    return super.dispatchKeyEvent(event);
}

From source file:net.zorgblub.typhon.activity.ReadingActivity.java

@Override
public boolean dispatchKeyEvent(KeyEvent event) {

    int action = event.getAction();
    int keyCode = event.getKeyCode();

    if (action == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_BACK && isDrawerOpen()) {
        closeNavigationDrawer();/*w w  w.  jav  a  2  s.  c  o  m*/
        return true;
    }

    if (readingFragment.dispatchKeyEvent(event)) {
        return true;
    }

    return super.dispatchKeyEvent(event);
}