Example usage for android.view KeyEvent getRepeatCount

List of usage examples for android.view KeyEvent getRepeatCount

Introduction

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

Prototype

public final int getRepeatCount() 

Source Link

Document

Retrieve the repeat count of the event.

Usage

From source file:com.shurik.droidzebra.ZebraActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
        //            try {
        //                mZebraThread.undoMove();
        //            } catch (EngineError e) {
        //                FatalError(e.msg);
        //            }
        showQuitDialog();/*from w w w  .j  ava2  s . c  o m*/
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:org.andstatus.app.account.AccountSettingsActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
        closeAndGoBack();//from   ww  w.j av a2  s.c o m
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.shurik.droidzebra.DroidZebra.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
        try {/* ww w  . j  av  a2 s .c  o m*/
            mZebraThread.undoMove();
        } catch (EngineError e) {
            FatalError(e.msg);
        }
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.ichi2.anki2.Info.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
        if (mType == TYPE_SHARED_DECKS && mWebView.canGoBack()) {
            mWebView.goBack();/*from   ww  w .ja  v  a 2  s .  c  o m*/
        } else if (mType == TYPE_UPGRADE_DECKS && mUpgradeStage != UPGRADE_SCREEN_BASIC1) {
            Intent result = new Intent();
            result.putExtra(TYPE_ANIMATION_RIGHT, true);
            switch (mUpgradeStage) {
            case UPGRADE_SCREEN_BASIC2:
                result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC1);
                break;

            case UPGRADE_SCREEN_MORE_OPTIONS:
                result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC1);
                break;

            case UPGRADE_SCREEN_WEB_UPGRADE:
                result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC2);
                break;

            case UPGRADE_SCREEN_PC_UPGRADE:
                result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC2);
                break;

            case UPGRADE_SCREEN_MANUAL_UPGRADE:
                result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC2);
                break;

            case UPGRADE_SCREEN_AUTO_UPGRADE:
                result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_PC_UPGRADE);
                break;
            }
            setResult(RESULT_OK, result);
            finishWithAnimation(false);
        } else {
            Log.i(AnkiDroidApp.TAG, "Info - onBackPressed()");
            setResult(RESULT_CANCELED);
            finishWithAnimation();
        }
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.hichinaschool.flashcards.anki.Info.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
        if (mType == TYPE_SHARED_DECKS && mWebView.canGoBack()) {
            mWebView.goBack();/*  ww  w.j  a  va2 s. co  m*/
        } else if (mType == TYPE_UPGRADE_DECKS && mUpgradeStage != UPGRADE_SCREEN_BASIC1) {
            Intent result = new Intent();
            result.putExtra(TYPE_ANIMATION_RIGHT, true);
            switch (mUpgradeStage) {
            case UPGRADE_SCREEN_BASIC2:
                result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC1);
                break;

            case UPGRADE_SCREEN_MORE_OPTIONS:
                result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC1);
                break;

            case UPGRADE_SCREEN_WEB_UPGRADE:
                result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC2);
                break;

            case UPGRADE_SCREEN_PC_UPGRADE:
                result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC2);
                break;

            case UPGRADE_SCREEN_MANUAL_UPGRADE:
                result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC2);
                break;

            case UPGRADE_SCREEN_AUTO_UPGRADE:
                result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_PC_UPGRADE);
                break;
            }
            setResult(RESULT_OK, result);
            finishWithAnimation(false);
        } else {
            // Log.i(AnkiDroidApp.TAG, "Info - onBackPressed()");
            setResult(RESULT_CANCELED);
            finishWithAnimation();
        }
        return true;
    }
    return 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;/*from w  w  w  . jav  a2  s .  co 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:org.uoyabause.android.YabauseHandler.java

@Override
public boolean dispatchKeyEvent(KeyEvent event) {

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

    if (keyCode == KeyEvent.KEYCODE_BACK) {

        if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {

            Fragment fg = getSupportFragmentManager().findFragmentByTag(StateListFragment.TAG);
            if (fg != null) {
                this.cancelStateLoad();
                FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
                transaction.remove(fg);//from   w ww  . j  av a  2 s.  c om
                transaction.commit();
                View mainv = findViewById(R.id.yabause_view);
                mainv.setActivated(true);
                mainv.requestFocus();
                waiting_reault = false;
                YabauseRunnable.resume();
                audio.unmute(audio.SYSTEM);
                return true;
            }

            fg = getSupportFragmentManager().findFragmentByTag(TabBackupFragment.TAG);
            if (fg != null) {
                FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
                transaction.remove(fg);
                transaction.commit();
                View mainv = findViewById(R.id.yabause_view);
                mainv.setActivated(true);
                mainv.requestFocus();
                waiting_reault = false;
                YabauseRunnable.resume();
                audio.unmute(audio.SYSTEM);
                return true;
            }
            showBottomMenu();
        }
        return true;
    }

    if (menu_showing) {
        return super.dispatchKeyEvent(event);
    }

    if (this.waiting_reault) {
        return super.dispatchKeyEvent(event);
    }

    //Log.d("dispatchKeyEvent","device:" + event.getDeviceId() + ",action:" + action +",keyCoe:" + keyCode );
    if (action == KeyEvent.ACTION_UP) {
        int rtn = padm.onKeyUp(keyCode, event);
        if (rtn != 0) {
            return true;
        }
    } else if (action == KeyEvent.ACTION_MULTIPLE) {

    } else if (action == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
        int rtn = padm.onKeyDown(keyCode, event);
        if (rtn != 0) {
            return true;
        }
    }
    return super.dispatchKeyEvent(event);
}

From source file:com.ichi2.anki.Info.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
        if (mType == TYPE_SHARED_DECKS && mWebView.canGoBack()) {
            mWebView.goBack();/*from   w  w w.j  a v  a2 s .  c om*/
        } else if (mType == TYPE_UPGRADE_DECKS && mUpgradeStage != UPGRADE_SCREEN_BASIC1) {
            Intent result = new Intent();
            result.putExtra(TYPE_ANIMATION_RIGHT, true);
            switch (mUpgradeStage) {
            case UPGRADE_SCREEN_BASIC2:
                result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC1);
                break;

            case UPGRADE_SCREEN_MORE_OPTIONS:
                result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC1);
                break;

            case UPGRADE_SCREEN_WEB_UPGRADE:
                result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC2);
                break;

            case UPGRADE_SCREEN_PC_UPGRADE:
                result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC2);
                break;

            case UPGRADE_SCREEN_MANUAL_UPGRADE:
                result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC2);
                break;

            case UPGRADE_SCREEN_AUTO_UPGRADE:
                result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_PC_UPGRADE);
                break;
            }
            setResult(RESULT_OK, result);
            finishWithAnimation(false);
        } else {
            Timber.i("onBackPressed()");
            setResult(RESULT_CANCELED);
            finishWithAnimation();
        }
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:org.mortbay.ijetty.IJetty.java

License:asdf

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    Log.w(TAG, "onKeyDown");
    if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {

        Log.w(TAG, "onKeyDown, KEYCODE_BACK");
        if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
            //??  
            if (MyFloatView.mPlayViewPrepareStatus) {
                Log.e("smallstar", "MyFloatView.mPlayViewPrepareStatus is true!");
                MyFloatView.mPlayViewStatus = false;
                MyFloatView.onExit();//w ww .  j  a  va  2  s.co  m
            }

            if (mWebView.getOriginalUrl().equals("http://localhost:8080/console/settings/basicsettings.html")) {
                stopService(new Intent(this, DaemonService.class));
                stopService(new Intent(this, IJettyService.class));
                finish();
            } else {
                //mWebView.loadUrl("http://localhost:8080/console/settings/index.html");
                mWebView.loadUrl("http://localhost:8080/console/settings/basicsettings.html");
            }
        }
        return true;
    }
    return super.dispatchKeyEvent(event);
}

From source file:website.openeng.anki.CardBrowser.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
        Timber.i("CardBrowser:: CardBrowser - onBackPressed()");
        Intent data = new Intent();
        if (getIntent().hasExtra("selectedDeck")) {
            data.putExtra("originalDeck", getIntent().getLongExtra("selectedDeck", 0L));
        }// w w  w . j av  a2  s .  c om
        closeCardBrowser(Activity.RESULT_OK, data);
        return true;
    }

    return super.onKeyDown(keyCode, event);
}