Example usage for android.view KeyEvent KEYCODE_DPAD_RIGHT

List of usage examples for android.view KeyEvent KEYCODE_DPAD_RIGHT

Introduction

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

Prototype

int KEYCODE_DPAD_RIGHT

To view the source code for android.view KeyEvent KEYCODE_DPAD_RIGHT.

Click Source Link

Document

Key code constant: Directional Pad Right key.

Usage

From source file:org.ligi.gobandroid_hd.ui.GoActivity.java

@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        final Cell ensuredTouchPosition = interaction_scope.getEnsuredTouchPosition();
        final BoardCell boardCell = getGame().getCalcBoard().getCell(ensuredTouchPosition);

        switch (keyCode) {
        case KeyEvent.KEYCODE_DPAD_UP:
            if (boardCell.up != null) {
                interaction_scope.touch_position = boardCell.up;
            } else {
                return false;
            }/* w  ww  .  j ava  2 s  .  co  m*/
            break;

        case KeyEvent.KEYCODE_DPAD_LEFT:
            if (boardCell.left != null) {
                interaction_scope.touch_position = boardCell.left;
            } else {
                return false;
            }
            break;

        case KeyEvent.KEYCODE_DPAD_DOWN:
            if (boardCell.down != null) {
                interaction_scope.touch_position = boardCell.down;
            } else {
                return false;
            }
            break;

        case KeyEvent.KEYCODE_DPAD_RIGHT:
            if (boardCell.right != null) {
                interaction_scope.touch_position = boardCell.right;
            } else {
                return false;
            }
            break;

        case KeyEvent.KEYCODE_DPAD_CENTER:
            doMoveWithUIFeedback(boardCell);
            break;

        default:

            return false;

        }

        go_board.postInvalidate();
        refreshZoomFragment();
        return true;
    }
    return false;
}

From source file:org.medcare.Dicom.DicomActivity.java

public boolean onKeyDown(int keyCode, KeyEvent event) {
    Log.e(TAG, "onKeyDown!!!!!!!!!!!!!!! " + keyCode);
    if (keyCode == KeyEvent.KEYCODE_PLUS) {
        Log.e(TAG, "zoomIn!!!!!!!!!!!!!!!");
        this.dicomView.dicomThread.action("zoomIn");
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_MINUS) {
        Log.e(TAG, "zoomOut!!!!!!!!!!!!!!!");
        this.dicomView.dicomThread.action("zoomOut");
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_DPAD_UP) {
        Log.e(TAG, "zoomIn!!!!!!!!!!!!!!!");
        this.dicomView.dicomThread.action("zoomIn");
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
        Log.e(TAG, "zoomOut!!!!!!!!!!!!!!!");
        this.dicomView.dicomThread.action("zoomOut");
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
        Log.e(TAG, "Del!!!!!!!!!!!!!!!");
        this.dicomView.dicomThread.action("Del");
    } else if (keyCode == KeyEvent.KEYCODE_DEL) {
        Log.e(TAG, "del!!!!!!!!!!!!!!!");
        this.dicomView.dicomThread.action("Del");
    } else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) {
        Log.e(TAG, "TAGS_INFO!!!!!!!!!!!!!!!");
        this.dicomView.dicomThread.action("TAGS_INFO");
    } else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
        Log.e(TAG, "TAGS_OFF!!!!!!!!!!!!!!!");
        this.dicomView.dicomThread.action("TAGS_OFF");
    }/* w  w w.j a v  a 2s.  c  o  m*/
    return false;
}

From source file:com.aretha.slidemenu.SlideMenu.java

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    if (KeyEvent.ACTION_UP == event.getAction()) {
        final boolean isOpen = isOpen();
        switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_BACK:
            if (isOpen) {
                close(true);/*from  w  ww .ja v  a2s .  c  o m*/
                return true;
            }
            break;
        case KeyEvent.KEYCODE_DPAD_LEFT:
            if (STATE_OPEN_LEFT == mCurrentState) {
                close(true);
                return true;
            } else if (!isOpen) {
                open(true, true);
                return true;
            }
            break;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            if (STATE_OPEN_RIGHT == mCurrentState) {
                close(true);
                return true;
            } else if (!isOpen) {
                open(false, true);
                return true;
            }
            break;
        }
    }
    return super.dispatchKeyEvent(event);
}

From source file:com.bitflake.counter.HorizontalPicker.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {

    if (!isEnabled()) {
        return super.onKeyDown(keyCode, event);
    }//from   w  w  w .  ja v a2  s .  co m

    switch (keyCode) {
    case KeyEvent.KEYCODE_DPAD_CENTER:
    case KeyEvent.KEYCODE_ENTER:
        selectItem();
        return true;
    case KeyEvent.KEYCODE_DPAD_LEFT:
        smoothScrollBy(-1);
        return true;
    case KeyEvent.KEYCODE_DPAD_RIGHT:
        smoothScrollBy(1);
        return true;
    default:
        return super.onKeyDown(keyCode, event);
    }

}

From source file:org.brandroid.openmanager.fragments.ContentFragment.java

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.content_layout, container, false);
    mGrid = (GridView) v.findViewById(R.id.content_grid);
    final OpenFragment me = this;
    mGrid.setOnKeyListener(new OnKeyListener() {
        @Override//from w  ww.j a  va2s . com
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (event.getAction() != KeyEvent.ACTION_DOWN)
                return false;
            int col = 0;
            int cols = 1;
            try {
                if (!OpenExplorer.BEFORE_HONEYCOMB) {
                    Method m = GridView.class.getMethod("getNumColumns", new Class[0]);
                    Object tmp = m.invoke(mGrid, new Object[0]);
                    if (tmp instanceof Integer) {
                        cols = (Integer) tmp;
                        col = mGrid.getSelectedItemPosition() % cols;
                    }
                }
            } catch (Exception e) {
            }
            Logger.LogDebug("ContentFragment.mGrid.onKey(" + keyCode + "," + event + ")@" + col);
            if (!OpenExplorer.BEFORE_HONEYCOMB)
                cols = (Integer) mGrid.getNumColumns();
            if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT && col == 0)
                return onFragmentDPAD(me, false);
            else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT && col == cols - 1)
                return onFragmentDPAD(me, true);
            else if (MenuUtils.getMenuShortcut(event) != null) {
                MenuItem item = MenuUtils.getMenuShortcut(event);
                if (onOptionsItemSelected(item)) {
                    Toast.makeText(v.getContext(), item.getTitle(), Toast.LENGTH_SHORT).show();
                    return true;
                }
            }
            return false;
        }
    });
    v.setOnLongClickListener(this);
    mGrid.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
        @Override
        public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
            getMenuInflater().inflate(R.menu.context_file, menu);
            onPrepareOptionsMenu(menu);
        }
    });
    //if(mProgressBarLoading == null)
    //   mProgressBarLoading = v.findViewById(R.id.content_progress);
    setProgressVisibility(false);
    super.onCreateView(inflater, container, savedInstanceState);
    //v.setBackgroundResource(R.color.lightgray);

    /*
    if (savedInstanceState != null && savedInstanceState.containsKey("location")) {
       String location = savedInstanceState.getString("location");
       if(location != null && !location.equals("") && location.startsWith("/"))
       {
    Logger.LogDebug("Content location restoring to " + location);
    mPath = new OpenFile(location);
    mData = getManager().getChildren(mPath);
    updateData(mData);
       }
       //setContentPath(path, false);
    }
    */

    return v;
}

From source file:com.malgon.applecrunch.Game3.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (loaded) {
        if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) {
            canonSprite.moveX(-moveCanonX);
        } else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
            canonSprite.moveX(moveCanonX);
        } else if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
            Sprite laserSprite = new Sprite(180, 80, laserTexture);
            Hotspot laserHotspot = new Hotspot(laserSprite);

            rokon.addSprite(laserSprite);
            rokon.addHotspot(laserHotspot);

            laserSprite.setXY(canonSprite.getX() + 20, canonSprite.getY());
            laserSprite.setVisible(true);

            laserSprite.setVelocityY(-laserVelocity);

            laserSprite.setCollisionHandler(collisionHandler);

            for (int i = 0; i < appleSpriteList.size(); i++)
                laserSprite.addCollisionSprite(appleSpriteList.get(i));

            for (int i = 0; i < androidSpriteList.size(); i++)
                laserSprite.addCollisionSprite(androidSpriteList.get(i));

            laserSpriteList.add(laserSprite);
            laserHotspotList.add(laserHotspot);
        }//from   w  w  w .j  a v a  2 s  .  c  o m
    }

    return super.onKeyDown(keyCode, event);
}

From source file:net.qiujuer.genius.ui.widget.GeniusAbsSeekBar.java

@Override
public boolean onKeyDown(int keyCode, @NonNull KeyEvent event) {
    boolean handled = false;
    boolean isAdd = false;
    if (isEnabled()) {
        int progress = getAnimatedProgress();
        switch (keyCode) {
        case KeyEvent.KEYCODE_DPAD_LEFT:
            handled = true;//from w  w w  .  ja  va 2 s. co m
            isAdd = isRtl();
            break;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            handled = true;
            isAdd = !isRtl();
            break;
        }

        if (handled) {
            if (isAdd) {
                if (progress < mMax)
                    animateSetProgress(progress + mKeyProgressIncrement);
            } else {
                if (progress > mMin)
                    animateSetProgress(progress - mKeyProgressIncrement);

            }
        }
    }

    return handled || super.onKeyDown(keyCode, event);
}

From source file:net.sourceforge.servestream.activity.MediaPlayerActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    int repcnt = event.getRepeatCount();

    if ((seekmethod == 0) ? seekMethod1(keyCode) : seekMethod2(keyCode))
        return true;

    switch (keyCode) {
    case KeyEvent.KEYCODE_SLASH:
        seekmethod = 1 - seekmethod;//w ww . j  a  va2s. c o  m
        return true;

    case KeyEvent.KEYCODE_DPAD_LEFT:
        if (!useDpadMusicControl()) {
            break;
        }
        if (!mPrevButton.hasFocus()) {
            mPrevButton.requestFocus();
        }
        scanBackward(repcnt, event.getEventTime() - event.getDownTime());
        return true;
    case KeyEvent.KEYCODE_DPAD_RIGHT:
        if (!useDpadMusicControl()) {
            break;
        }
        if (!mNextButton.hasFocus()) {
            mNextButton.requestFocus();
        }
        scanForward(repcnt, event.getEventTime() - event.getDownTime());
        return true;

    case KeyEvent.KEYCODE_S:
        toggleShuffle();
        return true;

    case KeyEvent.KEYCODE_DPAD_CENTER:
    case KeyEvent.KEYCODE_SPACE:
        doPauseResume();
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:uk.co.pjmobile.mobile_apps.page_turner_reader.ReadingActivity.java

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    int action = event.getAction();
    int keyCode = event.getKeyCode();

    if (isAnimating() && action == KeyEvent.ACTION_DOWN) {
        stopAnimating();/*from   w ww. j  av a 2 s  .  co  m*/
        return true;
    }

    switch (keyCode) {

    case KeyEvent.KEYCODE_VOLUME_DOWN:
        // Yes, this is nasty: if the setting is true, we fall through to
        // the next case.
        if (!config.isVolumeKeyNavEnabled()) {
            return false;
        }

    case KeyEvent.KEYCODE_DPAD_RIGHT:

        if (action == KeyEvent.ACTION_DOWN) {
            pageDown(Orientation.HORIZONTAL);
        }

        return true;

    case KeyEvent.KEYCODE_VOLUME_UP:
        // Same dirty trick.
        if (!config.isVolumeKeyNavEnabled()) {
            return false;
        }

    case KeyEvent.KEYCODE_DPAD_LEFT:
        if (action == KeyEvent.ACTION_DOWN) {
            pageUp(Orientation.HORIZONTAL);
        }

        return true;

    case KeyEvent.KEYCODE_BACK:
        if (action == KeyEvent.ACTION_DOWN) {

            if (titleBarLayout.getVisibility() == View.VISIBLE) {
                hideTitleBar();
            } else if (bookView.hasPrevPosition()) {
                bookView.goBackInHistory();

                return true;
            } else {
                this.finish();
            }
        }

    }

    return false;
}