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.tedx.alcatraz.SpeakerResultActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ECLAIR
            && keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
        // Take care of calling this method on earlier versions of
        // the platform where it doesn't exist.
        onBackPressed();//from ww  w  . j  a va 2s .  c  o  m
    }

    return super.onKeyDown(keyCode, event);
}

From source file:com.HskPackage.HskNamespace.HSK1ProjectActivity.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
        finish();/*  w w w. j a v a 2  s.  c  om*/
        return true;
    }
    return super.onKeyUp(keyCode, event);
}

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

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
        finish();//from  w w  w  .j a  v a 2 s .c  om
        overridePendingTransition(R.anim.right_in, R.anim.right_out);
    }
    return super.onKeyDown(keyCode, event);
}

From source file:dheeraj.com.trafficsolution.FeedsActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (Integer.parseInt(android.os.Build.VERSION.SDK) > 5 && keyCode == KeyEvent.KEYCODE_BACK
            && event.getRepeatCount() == 0) {
        onBackPressed();/*from   w ww  .  ja va  2  s.c  o  m*/
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:own.projects.lemiroapp.OptionsActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
        new AlertDialog.Builder(THIS).setIcon(android.R.drawable.ic_dialog_info).setTitle("Quit?")
                .setMessage("Do you want to quit?")
                .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        setResult(RESULT_CANCELED);
                        finish();//w  ww  . j  a v a 2s  .co m
                    }
                }).setNegativeButton("No", null).show();
    }
    return super.onKeyDown(keyCode, event);
}

From source file:org.geometerplus.android.fbreader.network.NetworkCatalogActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
        doStopLoading();//from   w ww.j  ava  2  s. co m
    }
    return super.onKeyDown(keyCode, event);
}

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

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
        Log.i(AnkiDroidApp.TAG, "StudyOptions - onBackPressed()");
        if (mCurrentFragment == null || !mCurrentFragment.congratsShowing()) {
            closeStudyOptions();//  w  ww . j av a 2s  .com
        }
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:org.solovyev.android.calculator.CalculatorActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0 && useBackAsPrevious) {
        history.undo();//  w  ww.  j  a  v a 2  s.  c  o m
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.example.android.LevelChooserActivity.java

/**
 * onKeyDown overrides onKeyDown and allows code to be executed when the
 * back button is pushed in the simulator / on the mobile phone Since
 * pushing "back" won't necessarily call the destroy method as far as I
 * understand it./*from  w w w. ja  va  2 s  .c o m*/
 * 
 * @param keyCode
 *            : code of the key pressed
 * @param event
 *            : the event for the key pressed
 */
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == zero) {

        //This code cannot be in onStop in LevelChooserActivity because
        //it also kills the ticking noise as Game begins
        //cancel any noises and abandon focus
        SoundPlayer.stop();
        if (focusHelper != null) {
            focusHelper.abandonFocus();
        }

        // continue backwards (kills current activity calling onDestroy)
        finish();

        return true;
    }

    return super.onKeyDown(keyCode, event);
}

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

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
        // Log.i(AnkiDroidApp.TAG, "StudyOptions - onBackPressed()");
        if (mCurrentFragment != null && mCurrentFragment.congratsShowing()) {
            mCurrentFragment.finishCongrats();
            return true;
        }/*from w ww .jav a 2s .  c  o  m*/
        closeStudyOptions();
        return true;
    }
    return super.onKeyDown(keyCode, event);
}