List of usage examples for android.view KeyEvent ACTION_UP
int ACTION_UP
To view the source code for android.view KeyEvent ACTION_UP.
Click Source Link
From source file:com.alivenet.dmvtaxi.fragment.Fragment_ride_list.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_ride_list, container, false); mPref = getActivity().getSharedPreferences(MYPREF, Context.MODE_PRIVATE); mUserId = mPref.getString("userId", null); progressDialog = new ProgressDialog(getActivity()); progressDialog.setMessage("Please wait..."); progressDialog.setCancelable(false); recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view); recyclerView.setHasFixedSize(true);/*from ww w . jav a 2 s . c o m*/ LinearLayoutManager llm = new LinearLayoutManager(getActivity()); llm.setOrientation(LinearLayoutManager.VERTICAL); recyclerView.addItemDecoration(new SpacesItemDecoration(VERTICAL_ITEM_SPACE)); recyclerView.setLayoutManager(llm); recyclerView.setItemAnimator(new DefaultItemAnimator()); mnorides = (TextView) view.findViewById(R.id.tv_norides); RequestParams params = new RequestParams(); params.put("userId", mUserId); rideListWs(params); view.setFocusableInTouchMode(true); view.requestFocus(); view.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) { // handle back button's click listener if (keyCode == KeyEvent.KEYCODE_BACK) { Fragment homeFragment = new FragmentMainScreen(); FragmentManager frgManager; frgManager = getFragmentManager(); frgManager.beginTransaction().replace(R.id.fragment_switch, homeFragment).commit(); return true; } return true; } return false; } }); return view; }
From source file:com.vikingbrain.dmt.view.RemoteControlActivity.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { int keyaction = event.getAction(); int keyCode = event.getKeyCode(); //Manage key up keys if (keyaction == KeyEvent.ACTION_UP) { if (keyCode == KeyEvent.KEYCODE_BACK) { //Back button, exit the activity onBackPressed();// ww w . ja va 2s . co m return true; } else if (keyCode == KeyEvent.KEYCODE_DEL) { //this is for backspace addCharacterToSendQueue(Keyboard2RemoteKey.BACKSPACE.getKeyboardSymbol()); return true; } else { //Any other keyboard key up DmtLogger.d("key pressed", String.valueOf(event.getKeyCode())); char unicodeChar = (char) event.getUnicodeChar(); String keyboardSymbol = String.valueOf(unicodeChar); addCharacterToSendQueue(keyboardSymbol); return true; } } return super.dispatchKeyEvent(event); }
From source file:me.pexcn.bandwagonhost.main.HostDialogFragment.java
@NonNull @Override// www . j av a 2s .c om public Dialog onCreateDialog(Bundle savedInstanceState) { final View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_host, (ViewGroup) getActivity().getWindow().getDecorView(), false); mTitle = (TextInputEditText) view.findViewById(R.id.et_title); mVeid = (TextInputEditText) view.findViewById(R.id.et_veid); mKey = (TextInputEditText) view.findViewById(R.id.et_key); mLayoutTitle = (TextInputLayout) view.findViewById(R.id.til_title); mLayoutVeid = (TextInputLayout) view.findViewById(R.id.til_veid); mLayoutKey = (TextInputLayout) view.findViewById(R.id.til_key); final Bundle args = getArguments(); if (args != null) { mHost = args.getParcelable(ARGS_HOST); if (mHost != null) { mTitle.setText(mHost.title); mVeid.setText(mHost.veid); mKey.setText(mHost.key); mTitle.setSelection(mHost.title.length()); } } else { mHost = new Host(); } mDialog = new AlertDialog.Builder(getActivity()).setView(view) .setTitle(args == null ? getResources().getString(R.string.dialog_title_add_host) : getResources().getString(R.string.dialog_title_update_host)) .setPositiveButton(args == null ? getResources().getString(R.string.dialog_button_ok) : getResources().getString(R.string.dialog_button_update), null) .setNegativeButton(getResources().getString(R.string.dialog_button_cancel), null) .setOnKeyListener((dialog, keyCode, event) -> { if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP && !event.isCanceled()) { dialog.dismiss(); return true; } return false; }).create(); mDialog.setOnShowListener(dialog -> { mDialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(v -> { if (mTitle.length() == 0 || mVeid.length() == 0 || mKey.length() == 0) { fixEditTextInput(); } else { mHost.title = mTitle.getText().toString(); mHost.veid = mVeid.getText().toString(); mHost.key = mKey.getText().toString(); dispatchProcess(mHost); dialog.dismiss(); } }); mMainView.hideFab(); }); return mDialog; }
From source file:ayushi.view.fragment.SettingsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.frag_settings, container, false); getActivity().setTitle("About App"); mToolbar = (Toolbar) rootView.findViewById(R.id.htab_toolbar); if (mToolbar != null) { ((ECartHomeActivity) getActivity()).setSupportActionBar(mToolbar); }// ww w. ja va 2 s . com if (mToolbar != null) { ((ECartHomeActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); mToolbar.setNavigationIcon(R.drawable.ic_drawer); } mToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((ECartHomeActivity) getActivity()).getmDrawerLayout().openDrawer(GravityCompat.START); } }); mToolbar.setTitleTextColor(Color.WHITE); submitLog = (TextView) rootView.findViewById(R.id.submit_log_txt); if (PreferenceHelper.getPrefernceHelperInstace().getBoolean(getActivity(), PreferenceHelper.SUBMIT_LOGS, true)) { submitLog.setText("Disable"); } else { submitLog.setText("Enable"); } rootView.findViewById(R.id.submit_log).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (PreferenceHelper.getPrefernceHelperInstace().getBoolean(getActivity(), PreferenceHelper.SUBMIT_LOGS, true)) { PreferenceHelper.getPrefernceHelperInstace().setBoolean(getActivity(), PreferenceHelper.SUBMIT_LOGS, false); submitLog.setText("Disable"); } else { PreferenceHelper.getPrefernceHelperInstace().setBoolean(getActivity(), PreferenceHelper.SUBMIT_LOGS, true); submitLog.setText("Enable"); } } }); 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) { Utils.switchContent(R.id.frag_container, Utils.HOME_FRAGMENT, ((ECartHomeActivity) (getContext())), AnimationType.SLIDE_UP); } return true; } }); rootView.findViewById(R.id.picasso).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/square/picasso")); startActivity(browserIntent); } }); rootView.findViewById(R.id.acra).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/ACRA/acra")); startActivity(browserIntent); } }); rootView.findViewById(R.id.pull_zoom_view).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/Frank-Zhu/PullZoomView")); startActivity(browserIntent); } }); rootView.findViewById(R.id.list_buddies).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/jpardogo/ListBuddies")); startActivity(browserIntent); } }); rootView.findViewById(R.id.list_jazzy).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/twotoasters/JazzyListView")); startActivity(browserIntent); } }); rootView.findViewById(R.id.email_dev).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("text/plain"); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "serveroverloadofficial@gmail.com" }); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Hello There"); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Add Message here"); emailIntent.setType("message/rfc822"); try { startActivity(Intent.createChooser(emailIntent, "Send email using...")); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(getActivity(), "No email clients installed.", Toast.LENGTH_SHORT).show(); } } }); return rootView; }
From source file:com.google.android.marvin.mytalkback.ProcessorVolumeStream.java
@Override public boolean onKeyEvent(KeyEvent event) { boolean handled = false; switch (event.getAction()) { case KeyEvent.ACTION_DOWN: handled = handleKeyDown(event.getKeyCode()); break;//from www . j a v a2 s . c o m case KeyEvent.ACTION_UP: handled = handleKeyUp(event.getKeyCode()); break; } if (handled) { // Quickly acquire and release the wake lock so that // PowerManager.ON_AFTER_RELEASE takes effect. mWakeLock.acquire(); mWakeLock.release(); } return handled; }
From source file:com.stfalcon.frescoimageviewer.ImageViewer.java
/** * Resets image on {@literal KeyEvent.KEYCODE_BACK} to normal scale if needed, otherwise - hide the viewer. *///from w w w . j av a 2 s . com @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP && !event.isCanceled()) { if (viewer.isScaled()) { viewer.resetScale(); } else { dialog.cancel(); } } return true; }
From source file:cx.ring.fragments.AccountCreationFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) { final View inflatedView = inflater.inflate(R.layout.frag_account_creation, parent, false); mAliasView = (EditText) inflatedView.findViewById(R.id.alias); mHostnameView = (EditText) inflatedView.findViewById(R.id.hostname); mUsernameView = (EditText) inflatedView.findViewById(R.id.username); mPasswordView = (EditText) inflatedView.findViewById(R.id.password); mPasswordView.setOnEditorActionListener(new OnEditorActionListener() { @Override/*from w ww .ja v a 2 s. c om*/ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == getResources().getInteger(R.integer.register_sip_account_actionid) || event == null || (event.getAction() == KeyEvent.ACTION_UP)) { inflatedView.findViewById(R.id.create_sip_button).callOnClick(); } return true; } }); inflatedView.findViewById(R.id.ring_card_view).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mAccountType = AccountDetailBasic.ACCOUNT_TYPE_RING; initAccountCreation(); } }); inflatedView.findViewById(R.id.create_sip_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mAccountType = AccountDetailBasic.ACCOUNT_TYPE_SIP; mAlias = mAliasView.getText().toString(); mHostname = mHostnameView.getText().toString(); mUsername = mUsernameView.getText().toString(); mPassword = mPasswordView.getText().toString(); attemptCreation(); } }); inflatedView.findViewById(R.id.import_card_view).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { startImport(); } }); mSipFormLinearLayout = (LinearLayout) inflatedView.findViewById(R.id.sipFormLinearLayout); mSipFormLinearLayout.setVisibility(View.GONE); inflatedView.findViewById(R.id.sipHeaderLinearLayout).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (null != mSipFormLinearLayout) { if (mSipFormLinearLayout.getVisibility() != View.VISIBLE) { mSipFormLinearLayout.setVisibility(View.VISIBLE); //~ Let the time to perform setVisibility before scrolling. final ScrollView loginForm = (ScrollView) inflatedView.findViewById(R.id.login_form); loginForm.postDelayed(new Runnable() { @Override public void run() { loginForm.fullScroll(ScrollView.FOCUS_DOWN); mAliasView.requestFocus(); } }, 100); } } } }); return inflatedView; }
From source file:com.trupti_prajapati.retailapp.view.fragment.SettingsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.frag_aboutus, container, false); getActivity().setTitle("About App"); mToolbar = (Toolbar) rootView.findViewById(R.id.htab_toolbar); if (mToolbar != null) { ((ECartHomeActivity) getActivity()).setSupportActionBar(mToolbar); }//from w ww .jav a2 s .c o m if (mToolbar != null) { ((ECartHomeActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); mToolbar.setNavigationIcon(R.drawable.ic_drawer); } mToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((ECartHomeActivity) getActivity()).getmDrawerLayout().openDrawer(GravityCompat.START); } }); mToolbar.setTitleTextColor(Color.WHITE); submitLog = (TextView) rootView.findViewById(R.id.submit_log_txt); if (PreferenceHelper.getPrefernceHelperInstace().getBoolean(getActivity(), PreferenceHelper.SUBMIT_LOGS, true)) { submitLog.setText("Disable"); } else { submitLog.setText("Enable"); } rootView.findViewById(R.id.submit_log).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (PreferenceHelper.getPrefernceHelperInstace().getBoolean(getActivity(), PreferenceHelper.SUBMIT_LOGS, true)) { PreferenceHelper.getPrefernceHelperInstace().setBoolean(getActivity(), PreferenceHelper.SUBMIT_LOGS, false); submitLog.setText("Disable"); } else { PreferenceHelper.getPrefernceHelperInstace().setBoolean(getActivity(), PreferenceHelper.SUBMIT_LOGS, true); submitLog.setText("Enable"); } } }); 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) { Utils.switchContent(R.id.frag_container, Utils.HOME_FRAGMENT, ((ECartHomeActivity) (getContext())), AnimationType.SLIDE_UP); } return true; } }); rootView.findViewById(R.id.picasso).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/square/picasso")); startActivity(browserIntent); } }); rootView.findViewById(R.id.acra).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/ACRA/acra")); startActivity(browserIntent); } }); rootView.findViewById(R.id.pull_zoom_view).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/Frank-Zhu/PullZoomView")); startActivity(browserIntent); } }); rootView.findViewById(R.id.list_buddies).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/jpardogo/ListBuddies")); startActivity(browserIntent); } }); rootView.findViewById(R.id.list_jazzy).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/twotoasters/JazzyListView")); startActivity(browserIntent); } }); rootView.findViewById(R.id.email_dev).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("text/plain"); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "serveroverloadofficial@gmail.com" }); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Hello There"); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Add Message here"); emailIntent.setType("message/rfc822"); try { startActivity(Intent.createChooser(emailIntent, "Send email using...")); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(getActivity(), "No email clients installed.", Toast.LENGTH_SHORT).show(); } } }); return rootView; }
From source file:ch.gianulli.trelloapi.ui.AuthenticationDialogFragment.java
@Nullable @Override/* w ww . j av a 2 s.co m*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (getDialog() != null) { getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE); } View v = inflater.inflate(R.layout.dialog_authentication, container, false); mProgressIndicator = (ProgressBar) v.findViewById(R.id.progress_indicator); mWebView = (WebView) v.findViewById(R.id.webview); // Catch token mWebView.setWebViewClient(new WebViewClient() { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { setProgressIndicatorVisibility(true); } @Override public void onPageFinished(WebView view, String url) { setProgressIndicatorVisibility(false); if (url.equals(URL_TOKEN)) { // Get token and close dialog mWebView.loadUrl("javascript:window.HTMLOUT.parseHTML('<html>'+document" + ".getElementsByTagName('html')[0].innerHTML+'</html>');"); } else { super.onPageFinished(view, url); } } }); WebSettings webSettings = mWebView.getSettings(); webSettings.setJavaScriptEnabled(true); mWebView.addJavascriptInterface(new MyJavaScriptInterface(), "HTMLOUT"); mWebView.setVisibility(View.GONE); mWebView.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_UP) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: if (mWebView.canGoBack()) { mWebView.goBack(); return true; } } } return false; } }); // Load first page setProgressIndicatorVisibility(true); try { mWebView.loadUrl(URL_AUTHORIZATION + "key=" + mApi.getAppKey() + "&name=" + URLEncoder.encode(getString(R.string.app_name), "UTF-8") + "&expiration=never&response_type=token&scope=read,write"); } catch (UnsupportedEncodingException e) { // never happens } return v; }
From source file:bbct.android.common.activity.BaseballCardDetails.java
@Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.card_details, container, false); ButterKnife.bind(this, view); final Activity activity = Objects.requireNonNull(getActivity()); String cardDetailsTitle = this.getString(R.string.card_details_title); String title = this.getString(R.string.bbct_title, cardDetailsTitle); activity.setTitle(title);/*from w w w. ja v a 2 s . c om*/ brandText.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { Log.d(TAG, "onKey() in Brand TextView"); Log.d(TAG, "keyCode = " + keyCode); if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_ENTER) { Log.d(TAG, "focus on Year"); yearText.requestFocus(); return true; } return false; } }); playerNameText.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { Log.d(TAG, "onKey() in Player Name TextView"); Log.d(TAG, "keyCode = " + keyCode); if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_ENTER) { Log.d(TAG, "focus on Team"); teamText.requestFocus(); return true; } return false; } }); teamText.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { Log.d(TAG, "onKey() in Team TextView"); Log.d(TAG, "keyCode = " + keyCode); if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_ENTER) { Log.d(TAG, "hide keyboard"); InputMethodManager imm = Objects.requireNonNull( (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE)); imm.hideSoftInputFromWindow(teamText.getWindowToken(), 0); playerPositionSpinner.requestFocus(); return true; } return false; } }); createAdapters(activity); populateTextEdits(); return view; }