List of usage examples for android.view KeyEvent KEYCODE_BACK
int KEYCODE_BACK
To view the source code for android.view KeyEvent KEYCODE_BACK.
Click Source Link
From source file:com.ryan.ryanreader.activities.CommentEditActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getTitle().equals(getString(R.string.comment_edit_save))) { final ProgressDialog progressDialog = new ProgressDialog(this); progressDialog.setTitle(getString(R.string.comment_reply_submitting_title)); progressDialog.setMessage(getString(R.string.comment_reply_submitting_message)); progressDialog.setIndeterminate(true); progressDialog.setCancelable(true); progressDialog.setCanceledOnTouchOutside(false); progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(final DialogInterface dialogInterface) { General.quickToast(CommentEditActivity.this, R.string.comment_reply_oncancel); progressDialog.dismiss(); }/*from w w w. ja va2 s.c o m*/ }); progressDialog.setOnKeyListener(new DialogInterface.OnKeyListener() { public boolean onKey(final DialogInterface dialogInterface, final int keyCode, final KeyEvent keyEvent) { if (keyCode == KeyEvent.KEYCODE_BACK) { General.quickToast(CommentEditActivity.this, R.string.comment_reply_oncancel); progressDialog.dismiss(); } return true; } }); final APIResponseHandler.ActionResponseHandler handler = new APIResponseHandler.ActionResponseHandler( this) { @Override protected void onSuccess() { new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { if (progressDialog.isShowing()) progressDialog.dismiss(); General.quickToast(CommentEditActivity.this, R.string.comment_edit_done); finish(); } }); } @Override protected void onCallbackException(Throwable t) { BugReportActivity.handleGlobalError(CommentEditActivity.this, t); } @Override protected void onFailure(RequestFailureType type, Throwable t, StatusLine status, String readableMessage) { final RRError error = General.getGeneralErrorForFailure(context, type, t, status); new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { General.showResultDialog(CommentEditActivity.this, error); if (progressDialog.isShowing()) progressDialog.dismiss(); } }); } @Override protected void onFailure(final APIFailureType type) { final RRError error = General.getGeneralErrorForFailure(context, type); new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { General.showResultDialog(CommentEditActivity.this, error); if (progressDialog.isShowing()) progressDialog.dismiss(); } }); } }; final CacheManager cm = CacheManager.getInstance(this); final RedditAccount selectedAccount = RedditAccountManager.getInstance(this).getDefaultAccount(); RedditAPI.editComment(cm, handler, selectedAccount, commentIdAndType, textEdit.getText().toString(), this); progressDialog.show(); } else if (item.getTitle().equals(getString(R.string.comment_reply_preview))) { MarkdownPreviewDialog.newInstance(textEdit.getText().toString()).show(getSupportFragmentManager()); } return true; }
From source file:org.lol.reddit.activities.CommentReplyActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getTitle().equals(getString(R.string.comment_reply_send))) { final ProgressDialog progressDialog = new ProgressDialog(this); progressDialog.setTitle(getString(R.string.comment_reply_submitting_title)); progressDialog.setMessage(getString(R.string.comment_reply_submitting_message)); progressDialog.setIndeterminate(true); progressDialog.setCancelable(true); progressDialog.setCanceledOnTouchOutside(false); progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(final DialogInterface dialogInterface) { General.quickToast(CommentReplyActivity.this, getString(R.string.comment_reply_oncancel)); progressDialog.dismiss(); }//from www .j av a2 s .co m }); progressDialog.setOnKeyListener(new DialogInterface.OnKeyListener() { public boolean onKey(final DialogInterface dialogInterface, final int keyCode, final KeyEvent keyEvent) { if (keyCode == KeyEvent.KEYCODE_BACK) { General.quickToast(CommentReplyActivity.this, getString(R.string.comment_reply_oncancel)); progressDialog.dismiss(); } return true; } }); final APIResponseHandler.ActionResponseHandler handler = new APIResponseHandler.ActionResponseHandler( this) { @Override protected void onSuccess() { General.UI_THREAD_HANDLER.post(new Runnable() { public void run() { if (progressDialog.isShowing()) progressDialog.dismiss(); General.quickToast(CommentReplyActivity.this, getString(R.string.comment_reply_done)); finish(); } }); } @Override protected void onCallbackException(Throwable t) { BugReportActivity.handleGlobalError(CommentReplyActivity.this, t); } @Override protected void onFailure(RequestFailureType type, Throwable t, StatusLine status, String readableMessage) { final RRError error = General.getGeneralErrorForFailure(context, type, t, status, null); General.UI_THREAD_HANDLER.post(new Runnable() { public void run() { General.showResultDialog(CommentReplyActivity.this, error); if (progressDialog.isShowing()) progressDialog.dismiss(); } }); } @Override protected void onFailure(final APIFailureType type) { final RRError error = General.getGeneralErrorForFailure(context, type); General.UI_THREAD_HANDLER.post(new Runnable() { public void run() { General.showResultDialog(CommentReplyActivity.this, error); if (progressDialog.isShowing()) progressDialog.dismiss(); } }); } }; final CacheManager cm = CacheManager.getInstance(this); final ArrayList<RedditAccount> accounts = RedditAccountManager.getInstance(this).getAccounts(); RedditAccount selectedAccount = null; for (RedditAccount account : accounts) { if (!account.isAnonymous() && account.username.equalsIgnoreCase((String) usernameSpinner.getSelectedItem())) { selectedAccount = account; break; } } RedditAPI.comment(cm, handler, selectedAccount, parentIdAndType, textEdit.getText().toString(), this); progressDialog.show(); } else if (item.getTitle().equals(getString(R.string.comment_reply_preview))) { MarkdownPreviewDialog.newInstance(textEdit.getText().toString()).show(getSupportFragmentManager()); } return true; }
From source file:com.github.kanata3249.ffxieq.android.AugmentEditActivity.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) { if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { EditText et;/*from ww w.j a va2 s . co m*/ Equipment eq; eq = getDAO().instantiateEquipment(mBaseID, mAugID); et = (EditText) findViewById(R.id.AugmentDescription); if (eq != null && et != null) { String augment; augment = et.getText().toString(); if (!eq.getAugment().equals(augment)) { showDialog(R.string.QueryDiscardChanges); return true; } } } } return super.dispatchKeyEvent(event); }
From source file:org.quantumbadger.redreader.activities.CommentEditActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getTitle().equals(getString(R.string.comment_edit_save))) { final ProgressDialog progressDialog = new ProgressDialog(this); progressDialog.setTitle(getString(R.string.comment_reply_submitting_title)); progressDialog.setMessage(getString(R.string.comment_reply_submitting_message)); progressDialog.setIndeterminate(true); progressDialog.setCancelable(true); progressDialog.setCanceledOnTouchOutside(false); progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(final DialogInterface dialogInterface) { General.quickToast(CommentEditActivity.this, R.string.comment_reply_oncancel); progressDialog.dismiss(); }// w w w. j ava 2 s .c om }); progressDialog.setOnKeyListener(new DialogInterface.OnKeyListener() { public boolean onKey(final DialogInterface dialogInterface, final int keyCode, final KeyEvent keyEvent) { if (keyCode == KeyEvent.KEYCODE_BACK) { General.quickToast(CommentEditActivity.this, R.string.comment_reply_oncancel); progressDialog.dismiss(); } return true; } }); final APIResponseHandler.ActionResponseHandler handler = new APIResponseHandler.ActionResponseHandler( this) { @Override protected void onSuccess() { new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { if (progressDialog.isShowing()) progressDialog.dismiss(); General.quickToast(CommentEditActivity.this, R.string.comment_edit_done); finish(); } }); } @Override protected void onCallbackException(Throwable t) { BugReportActivity.handleGlobalError(CommentEditActivity.this, t); } @Override protected void onFailure(RequestFailureType type, Throwable t, StatusLine status, String readableMessage) { final RRError error = General.getGeneralErrorForFailure(context, type, t, status, null); new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { General.showResultDialog(CommentEditActivity.this, error); if (progressDialog.isShowing()) progressDialog.dismiss(); } }); } @Override protected void onFailure(final APIFailureType type) { final RRError error = General.getGeneralErrorForFailure(context, type); new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { General.showResultDialog(CommentEditActivity.this, error); if (progressDialog.isShowing()) progressDialog.dismiss(); } }); } }; final CacheManager cm = CacheManager.getInstance(this); final RedditAccount selectedAccount = RedditAccountManager.getInstance(this).getDefaultAccount(); RedditAPI.editComment(cm, handler, selectedAccount, commentIdAndType, textEdit.getText().toString(), this); progressDialog.show(); } else if (item.getTitle().equals(getString(R.string.comment_reply_preview))) { MarkdownPreviewDialog.newInstance(textEdit.getText().toString()).show(getSupportFragmentManager()); } return true; }
From source file:com.example.activity.ShotListActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { // TODO Auto-generated method stub if (keyCode == KeyEvent.KEYCODE_BACK) { if (isExit == false) { isExit = true;// w w w.ja v a 2 s .c om ToastView toast = new ToastView(getApplicationContext(), "?BeeExample"); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); isExit = false; } }; mHandler.sendEmptyMessageDelayed(0, 3000); return true; } else { finish(); return false; } } return true; }
From source file:com.kpfunusa.RestaurantMap.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { RestaurantMap.this.finish(); return true; }//from w w w. j a v a2s . co m return super.onKeyDown(keyCode, event); }
From source file:com.ryan.ryanreader.activities.CommentReplyActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getTitle().equals(getString(R.string.comment_reply_send))) { final ProgressDialog progressDialog = new ProgressDialog(this); progressDialog.setTitle(getString(R.string.comment_reply_submitting_title)); progressDialog.setMessage(getString(R.string.comment_reply_submitting_message)); progressDialog.setIndeterminate(true); progressDialog.setCancelable(true); progressDialog.setCanceledOnTouchOutside(false); progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(final DialogInterface dialogInterface) { General.quickToast(CommentReplyActivity.this, getString(R.string.comment_reply_oncancel)); progressDialog.dismiss(); }//from w ww.j a v a2 s . c o m }); progressDialog.setOnKeyListener(new DialogInterface.OnKeyListener() { public boolean onKey(final DialogInterface dialogInterface, final int keyCode, final KeyEvent keyEvent) { if (keyCode == KeyEvent.KEYCODE_BACK) { General.quickToast(CommentReplyActivity.this, getString(R.string.comment_reply_oncancel)); progressDialog.dismiss(); } return true; } }); final APIResponseHandler.ActionResponseHandler handler = new APIResponseHandler.ActionResponseHandler( this) { @Override protected void onSuccess() { new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { if (progressDialog.isShowing()) progressDialog.dismiss(); General.quickToast(CommentReplyActivity.this, getString(R.string.comment_reply_done)); finish(); } }); } @Override protected void onCallbackException(Throwable t) { BugReportActivity.handleGlobalError(CommentReplyActivity.this, t); } @Override protected void onFailure(RequestFailureType type, Throwable t, StatusLine status, String readableMessage) { final RRError error = General.getGeneralErrorForFailure(context, type, t, status); new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { General.showResultDialog(CommentReplyActivity.this, error); if (progressDialog.isShowing()) progressDialog.dismiss(); } }); } @Override protected void onFailure(final APIFailureType type) { final RRError error = General.getGeneralErrorForFailure(context, type); new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { General.showResultDialog(CommentReplyActivity.this, error); if (progressDialog.isShowing()) progressDialog.dismiss(); } }); } }; final CacheManager cm = CacheManager.getInstance(this); final ArrayList<RedditAccount> accounts = RedditAccountManager.getInstance(this).getAccounts(); RedditAccount selectedAccount = null; for (RedditAccount account : accounts) { if (!account.isAnonymous() && account.username.equalsIgnoreCase((String) usernameSpinner.getSelectedItem())) { selectedAccount = account; break; } } RedditAPI.comment(cm, handler, selectedAccount, parentIdAndType, textEdit.getText().toString(), this); progressDialog.show(); } else if (item.getTitle().equals(getString(R.string.comment_reply_preview))) { MarkdownPreviewDialog.newInstance(textEdit.getText().toString()).show(getSupportFragmentManager()); } return true; }
From source file:com.appsimobile.appsii.Sidebar.java
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { closeSidebar();/* www. j a va2 s . com*/ return true; } return super.onKeyUp(keyCode, event); }
From source file:babybear.akbquiz.ConfigActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: if (cfgflipper.getDisplayedChild() == 0) { cfgEditor.commit();/*from ww w . j a v a 2 s. c o m*/ finish(); } else { cfgflipper.showPrevious(); return false; } break; } return super.onKeyDown(keyCode, event); }
From source file:com.iStudy.Study.Renren.View.RenrenDialog.java
/** * Reponse on the Back key click to close the authrization dialog and send * back the Cancel message Added by Shaofeng Wang * (shaofeng.wang@renren-inc.com)//w ww .java2 s . c om */ @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { if (webView != null) { webView.stopLoading(); } if (progress != null) { progress.dismiss(); } RenrenDialog.this.dismiss(); mListener.onPageBegin(Renren.DEFAULT_REDIRECT_URI + "?error=" + CODE_AUTH_CANCEL); this.cancel(); } return super.onKeyDown(keyCode, event); }