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:aarddict.android.ArticleViewActivity.java
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { // eat key ups corresponding to key downs so that volume keys don't beep switch (keyCode) { case KeyEvent.KEYCODE_BACK: case KeyEvent.KEYCODE_VOLUME_UP: case KeyEvent.KEYCODE_VOLUME_DOWN: break;//from www.j a va2 s.c o m default: return super.onKeyDown(keyCode, event); } return true; }
From source file:ayushi.view.fragment.ProductDetailsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.frag_product_detail, container, false); mToolbar = (Toolbar) rootView.findViewById(R.id.htab_toolbar); if (mToolbar != null) { ((ECartHomeActivity) getActivity()).setSupportActionBar(mToolbar); }//from w w w .ja v a 2s . c om if (mToolbar != null) { ((ECartHomeActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); mToolbar.setNavigationIcon(R.drawable.ic_drawer); } mToolbar.setTitleTextColor(Color.WHITE); mToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((ECartHomeActivity) getActivity()).getmDrawerLayout().openDrawer(GravityCompat.START); } }); ((ECartHomeActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); similarProductsPager = (ClickableViewPager) rootView.findViewById(R.id.similar_products_pager); topSellingPager = (ClickableViewPager) rootView.findViewById(R.id.top_selleing_pager); itemSellPrice = ((TextView) rootView.findViewById(R.id.category_discount)); quanitity = ((TextView) rootView.findViewById(R.id.iteam_amount)); itemName = ((TextView) rootView.findViewById(R.id.product_name)); itemdescription = ((TextView) rootView.findViewById(R.id.product_description)); itemImage = (ImageView) rootView.findViewById(R.id.product_image); fillProductData(); rootView.findViewById(R.id.add_item).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (isFromCart) { //Update Quantity on shopping List GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(productListNumber) .setQuantity(String.valueOf( Integer.valueOf(GlobaDataHolder.getGlobaDataHolder().getShoppingList() .get(productListNumber).getQuantity()) + 1)); //Update Ui quanitity.setText(GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(productListNumber) .getQuantity()); Utils.vibrate(getActivity()); //Update checkout amount on screen ((ECartHomeActivity) getActivity()).updateCheckOutAmount( BigDecimal.valueOf(Long.valueOf(GlobaDataHolder.getGlobaDataHolder().getShoppingList() .get(productListNumber).getSellMRP())), true); } else { // current object Product tempObj = GlobaDataHolder.getGlobaDataHolder().getProductMap().get(subcategoryKey) .get(productListNumber); // if current object is lready in shopping list if (GlobaDataHolder.getGlobaDataHolder().getShoppingList().contains(tempObj)) { // get position of current item in shopping list int indexOfTempInShopingList = GlobaDataHolder.getGlobaDataHolder().getShoppingList() .indexOf(tempObj); // increase quantity of current item in shopping // list if (Integer.parseInt(tempObj.getQuantity()) == 0) { ((ECartHomeActivity) getContext()).updateItemCount(true); } // update quanity in shopping list GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(indexOfTempInShopingList) .setQuantity(String.valueOf(Integer.valueOf(tempObj.getQuantity()) + 1)); // update checkout amount ((ECartHomeActivity) getContext()) .updateCheckOutAmount( BigDecimal.valueOf( Long.valueOf(GlobaDataHolder.getGlobaDataHolder().getProductMap() .get(subcategoryKey).get(productListNumber).getSellMRP())), true); // update current item quanitity quanitity.setText(tempObj.getQuantity()); } else { ((ECartHomeActivity) getContext()).updateItemCount(true); tempObj.setQuantity(String.valueOf(1)); quanitity.setText(tempObj.getQuantity()); GlobaDataHolder.getGlobaDataHolder().getShoppingList().add(tempObj); ((ECartHomeActivity) getContext()) .updateCheckOutAmount( BigDecimal.valueOf( Long.valueOf(GlobaDataHolder.getGlobaDataHolder().getProductMap() .get(subcategoryKey).get(productListNumber).getSellMRP())), true); } Utils.vibrate(getContext()); } } }); rootView.findViewById(R.id.remove_item).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (isFromCart) { if (Integer.valueOf(GlobaDataHolder.getGlobaDataHolder().getShoppingList() .get(productListNumber).getQuantity()) > 2) { GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(productListNumber) .setQuantity(String.valueOf( Integer.valueOf(GlobaDataHolder.getGlobaDataHolder().getShoppingList() .get(productListNumber).getQuantity()) - 1)); quanitity.setText(GlobaDataHolder.getGlobaDataHolder().getShoppingList() .get(productListNumber).getQuantity()); ((ECartHomeActivity) getActivity()).updateCheckOutAmount( BigDecimal.valueOf(Long.valueOf(GlobaDataHolder.getGlobaDataHolder() .getShoppingList().get(productListNumber).getSellMRP())), false); Utils.vibrate(getActivity()); } else if (Integer.valueOf(GlobaDataHolder.getGlobaDataHolder().getShoppingList() .get(productListNumber).getQuantity()) == 1) { ((ECartHomeActivity) getActivity()).updateItemCount(false); ((ECartHomeActivity) getActivity()).updateCheckOutAmount( BigDecimal.valueOf(Long.valueOf(GlobaDataHolder.getGlobaDataHolder() .getShoppingList().get(productListNumber).getSellMRP())), false); GlobaDataHolder.getGlobaDataHolder().getShoppingList().remove(productListNumber); if (Integer.valueOf(((ECartHomeActivity) getActivity()).getItemCount()) == 0) { MyCartFragment.updateMyCartFragment(false); } Utils.vibrate(getActivity()); } } else { Product tempObj = GlobaDataHolder.getGlobaDataHolder().getProductMap().get(subcategoryKey) .get(productListNumber); if (GlobaDataHolder.getGlobaDataHolder().getShoppingList().contains(tempObj)) { int indexOfTempInShopingList = GlobaDataHolder.getGlobaDataHolder().getShoppingList() .indexOf(tempObj); if (Integer.valueOf(tempObj.getQuantity()) != 0) { GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(indexOfTempInShopingList) .setQuantity(String.valueOf(Integer.valueOf(tempObj.getQuantity()) - 1)); ((ECartHomeActivity) getContext()).updateCheckOutAmount( BigDecimal.valueOf( Long.valueOf(GlobaDataHolder.getGlobaDataHolder().getProductMap() .get(subcategoryKey).get(productListNumber).getSellMRP())), false); quanitity.setText(GlobaDataHolder.getGlobaDataHolder().getShoppingList() .get(indexOfTempInShopingList).getQuantity()); Utils.vibrate(getContext()); if (Integer.valueOf(GlobaDataHolder.getGlobaDataHolder().getShoppingList() .get(indexOfTempInShopingList).getQuantity()) == 0) { GlobaDataHolder.getGlobaDataHolder().getShoppingList() .remove(indexOfTempInShopingList); ((ECartHomeActivity) getContext()).updateItemCount(false); } } } else { } } } }); rootView.setFocusableInTouchMode(true); rootView.requestFocus(); rootView.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) { if (isFromCart) { Utils.switchContent(R.id.frag_container, Utils.SHOPPING_LIST_TAG, ((ECartHomeActivity) (getActivity())), AnimationType.SLIDE_UP); } else { Utils.switchContent(R.id.frag_container, Utils.PRODUCT_OVERVIEW_FRAGMENT_TAG, ((ECartHomeActivity) (getActivity())), AnimationType.SLIDE_RIGHT); } } return true; } }); if (isFromCart) { similarProductsPager.setVisibility(View.GONE); topSellingPager.setVisibility(View.GONE); } else { showRecomondation(); } return rootView; }
From source file:net.oschina.app.ui.MainActivity.java
/** * ?--??/*from ww w . j av a 2s . co m*/ */ @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { // ? if (AppContext.get(AppConfig.KEY_DOUBLE_CLICK_EXIT, true)) { return mDoubleClickExit.onKeyDown(keyCode, event); } } return super.onKeyDown(keyCode, event); }
From source file:at.ac.tuwien.caa.docscan.ui.CameraActivity.java
/** * This function accesses the hardware buttons (like volume buttons). We need this access, * because shutter remotes emulate such a key press over bluetooth. * @param keyCode/*from w ww . j a v a 2 s. c om*/ * @param event * @return */ @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { takePicture(); } else if (keyCode == KeyEvent.KEYCODE_BACK) { super.onBackPressed(); } return true; }
From source file:com.marvin.rocklock.RockLockActivity.java
/** * Pick up back button and volume up and down *///from ww w.j a v a 2 s .c o m @Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: mPlayer.togglePlayPause(); return true; case KeyEvent.KEYCODE_MEDIA_NEXT: mPlayer.nextTrack(false); return true; case KeyEvent.KEYCODE_MEDIA_PREVIOUS: mPlayer.prevTrack(false); return true; case KeyEvent.KEYCODE_VOLUME_UP: mAudioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE, AudioManager.FLAG_PLAY_SOUND); return true; case KeyEvent.KEYCODE_VOLUME_DOWN: mAudioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_LOWER, AudioManager.FLAG_PLAY_SOUND); return true; case KeyEvent.KEYCODE_BACK: onBackPressed(); return true; default: return super.onKeyDown(keyCode, event); } }
From source file:org.cocos2dx.lib.TextInputWraper.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { final int kc = keyCode; if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU) { queueEvent(new Runnable() { @Override// ww w . j av a2s .c o m public void run() { mRenderer.handleKeyDown(kc); } }); return true; } return super.onKeyDown(keyCode, event); }
From source file:am.hour.beebird.Activity.MainActivity.java
public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { recent_fragment_number = -1;//from w ww .j a v a 2 s .com } else if (keyCode == KeyEvent.KEYCODE_MENU) { } else if (keyCode == KeyEvent.KEYCODE_HOME) { // } return super.onKeyDown(keyCode, event); }
From source file:com.jiandanbaoxian.fragment.DialogFragmentCreater.java
/** * Dialog ???// w w w .j a va 2s. c om * @param mContext * @return */ private Dialog showLicenseChoiceDialog(final Context mContext) { View convertView = LayoutInflater.from(mContext).inflate(R.layout.dialog_license_choice, null); final Dialog dialog = new Dialog(mContext, R.style.mystyle); View.OnClickListener listener = new View.OnClickListener() { @Override public void onClick(View v) { switch (v.getId()) { case R.id.layout_rule: if (isAgree) { isAgree = false; ImageView imageView = (ImageView) v.findViewById(R.id.iv_choose); // TextView textView = (TextView)v.findViewById(R.id.tv_rule); imageView.setImageResource(R.drawable.icon_choose); // textView.setBackgroundColor(getResources().getColor(R.color.bg_gray_color_level_0)); // textView.setTextColor(getResources().getColor(R.color.tv_gray_color_level_3)); } else { isAgree = true; ImageView imageView = (ImageView) v.findViewById(R.id.iv_choose); // TextView textView = (TextView)v.findViewById(R.id.tv_rule); imageView.setImageResource(R.drawable.icon_choose_selected); // textView.setBackgroundResource(R.drawable.btn_select_base_shape_0); // textView.setTextColor(getResources().getColor(R.color.white_color)); } break; } if (onLicenseDialogClickListener != null) { onLicenseDialogClickListener.onClick(v, isAgree); } } }; TitleBar titleBar; SwipeRefreshLayout swipeLayout; final WebView webView; ProgressBar progressBar; LinearLayout layoutRule; LinearLayout layoutConfirm; titleBar = (TitleBar) convertView.findViewById(R.id.title_bar); swipeLayout = (SwipeRefreshLayout) convertView.findViewById(R.id.swipe_layout); webView = (WebView) convertView.findViewById(R.id.webView); progressBar = (ProgressBar) convertView.findViewById(R.id.progress_bar); layoutRule = (LinearLayout) convertView.findViewById(R.id.layout_rule); layoutConfirm = (LinearLayout) convertView.findViewById(R.id.layout_confirm); WebChromeClient client = new AppChromeWebClient(titleBar, progressBar, swipeLayout); webView.setWebChromeClient(client); webView.setWebViewClient(new AppWebClient()); webView.getSettings().setJavaScriptEnabled(true); webView.loadUrl(webViewURL); webView.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) { if (keyCode == KeyEvent.KEYCODE_BACK && webView.canGoBack()) { webView.goBack(); //? return true; //? } } return false; } }); titleBar.initTitleBarInfo("", R.drawable.arrow_left, -1, "", ""); titleBar.setOnTitleBarClickListener(new TitleBar.OnTitleBarClickListener() { @Override public void onLeftButtonClick(View v) { if (webView.canGoBack()) { webView.goBack(); //? return; //? } if (onLicenseDialogClickListener != null) { onLicenseDialogClickListener.onClick(v, isAgree); dismiss(); } } @Override public void onRightButtonClick(View v) { } }); UIUtils.initSwipeRefreshLayout(swipeLayout); swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { webView.reload(); } }); layoutConfirm.setOnClickListener(listener); layoutRule.setOnClickListener(listener); dialog.setContentView(convertView); dialog.getWindow().setWindowAnimations(R.style.dialog_right_control_style); return dialog; }
From source file:com.skalski.websocketsclient.ActivityMain.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { onBackPressed();/*from www.ja va 2 s . co m*/ } return true; }
From source file:com.darly.im.ui.LauncherActivity.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { LogUtil.d(LogUtil.getLogUtilsTag(LauncherActivity.class), " onKeyDown"); if ((event.getKeyCode() == KeyEvent.KEYCODE_BACK) && event.getAction() == KeyEvent.ACTION_UP) { // dismiss PlusSubMenuHelper if (mOverflowHelper != null && mOverflowHelper.isOverflowShowing()) { mOverflowHelper.dismiss();//from www.ja va 2 s . c o m return true; } } // ?menu?? if ((event.getKeyCode() == KeyEvent.KEYCODE_BACK) && event.getAction() == KeyEvent.ACTION_DOWN) { doTaskToBackEvent(); } try { return super.dispatchKeyEvent(event); } catch (Exception e) { LogUtil.e(LogUtil.getLogUtilsTag(LauncherActivity.class), "dispatch key event catch exception " + e.getMessage()); } return false; }