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.cybrosys.basic.EventListener.java
@Override public boolean onKey(View vwView, int keyCode, KeyEvent keyEvent) { int action = keyEvent.getAction(); if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) { boolean eat = mHandler.eatHorizontalMove(keyCode == KeyEvent.KEYCODE_DPAD_LEFT); return eat; }/*from w ww.j a v a 2 s. co m*/ if (action == KeyEvent.ACTION_MULTIPLE && keyCode == KeyEvent.KEYCODE_UNKNOWN) { return true; } if (keyEvent.getUnicodeChar() == '=') { if (action == KeyEvent.ACTION_UP) { mHandler.onEnter(); } return true; } if (keyCode != KeyEvent.KEYCODE_DPAD_CENTER && keyCode != KeyEvent.KEYCODE_DPAD_UP && keyCode != KeyEvent.KEYCODE_DPAD_DOWN && keyCode != KeyEvent.KEYCODE_ENTER) { return false; } if (action == KeyEvent.ACTION_UP) { switch (keyCode) { case KeyEvent.KEYCODE_ENTER: case KeyEvent.KEYCODE_DPAD_CENTER: mHandler.onEnter(); break; case KeyEvent.KEYCODE_DPAD_UP: mHandler.onUp(); break; case KeyEvent.KEYCODE_DPAD_DOWN: mHandler.onDown(); break; } } return true; }
From source file:com.Bhailal_Chauhan.retailapp.view.fragment.ContactUsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.frag_about, container, false); getActivity().setTitle("Contact Us"); mToolbar = (Toolbar) rootView.findViewById(R.id.htab_toolbar); if (mToolbar != null) { ((ECartHomeActivity) getActivity()).setSupportActionBar(mToolbar); }// www . j a va 2 s .co 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); rootView.findViewById(R.id.locations).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { } }); rootView.findViewById(R.id.contact_num).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent callIntent = new Intent(Intent.ACTION_DIAL); callIntent.setData(Uri.parse("tel:" + "8347337366")); startActivity(callIntent); } }); 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.site_dev).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://bhailalchauhan.com/")); startActivity(browserIntent); } }); rootView.findViewById(R.id.email).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[] { "hibhailal458@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.trupti_prajapati.retailapp.view.fragment.ContactUsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.frag_contactus, container, false); getActivity().setTitle("Contact Us"); mToolbar = (Toolbar) rootView.findViewById(R.id.htab_toolbar); if (mToolbar != null) { ((ECartHomeActivity) getActivity()).setSupportActionBar(mToolbar); }//from w w w. ja v a 2 s . co 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); rootView.findViewById(R.id.locations).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { } }); rootView.findViewById(R.id.contact_num).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent callIntent = new Intent(Intent.ACTION_DIAL); callIntent.setData(Uri.parse("tel:" + "8866685640")); startActivity(callIntent); } }); 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.site_dev).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/truptinprajapati")); startActivity(browserIntent); } }); rootView.findViewById(R.id.email).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[] { "truptiprajapati19@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.androzic.MapList.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.list_with_empty_view_and_progressbar, container, false); progressBar = (ProgressBar) view.findViewById(R.id.progressbar); view.setFocusableInTouchMode(true);/* www. j ava 2s .com*/ 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) { if (currentTree != mapsTree) { currentTree = currentTree.parent; adapter.notifyDataSetChanged(); return true; } } return false; } }); return view; }
From source file:au.com.wallaceit.reddinator.ViewAllSubredditsActivity.java
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); global = ((GlobalObjects) getApplicationContext()); ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); }/*w w w . j a v a 2 s .c o m*/ setContentView(R.layout.viewallsubreddit); // setup list view listview = getListView(); listview.setTextFilterEnabled(true); listview.setEmptyView(findViewById(R.id.subredditload)); listview.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent intent = new Intent(); // update subreddit without adding to list intent.putExtra("subreddit", sreddits.get(position)); setResult(RESULT_SET_SUBREDDIT, intent); finish(); } }); // get empty view text for easy access later emptyview = (TextView) findViewById(R.id.poploadtxt); // setup search buttons searchbox = (EditText) this.findViewById(R.id.searchbox); searchbox.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_UP) { search(v.getText().toString()); } return true; } }); ImageView searchbtn = (ImageView) this.findViewById(R.id.searchbutton); searchbtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String query = searchbox.getText().toString(); if (!query.equals("")) { search(query); } else { new AlertDialog.Builder(ViewAllSubredditsActivity.this).setTitle("No Query") .setMessage("Please enter something to search for").show(); } } }); }
From source file:org.deviceconnect.android.localoauth.fragment.ConfirmAuthFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { Intent intent = getActivity().getIntent(); if (intent == null) { getActivity().finish();// ww w . j ava2s. c o m return null; } mThreadId = intent.getLongExtra(ConfirmAuthActivity.EXTRA_THREAD_ID, -1); if (mThreadId == -1) { getActivity().finish(); return null; } String applicationName = intent.getStringExtra(ConfirmAuthActivity.EXTRA_APPLICATION_NAME); String packageName = intent.getStringExtra(ConfirmAuthActivity.EXTRA_PACKAGE_NAME); String keyword = intent.getStringExtra(ConfirmAuthActivity.EXTRA_KEYWORD); String[] displayScopes = intent.getStringArrayExtra(ConfirmAuthActivity.EXTRA_DISPLAY_SCOPES); String expirePeriod = toStringExpiredPeriod(); boolean isForPlugin = intent.getBooleanExtra(ConfirmAuthActivity.EXTRA_IS_FOR_DEVICEPLUGIN, true); boolean isAutoFlag = intent.getBooleanExtra(ConfirmAuthActivity.EXTRA_AUTO_FLAG, false); long requestTime = intent.getLongExtra(ConfirmAuthActivity.EXTRA_REQUEST_TIME, System.currentTimeMillis()); long timeout = DEFAULT_TIMEOUT - (System.currentTimeMillis() - requestTime); int layoutId; if (isForPlugin) { layoutId = R.layout.confirm_auth_activity_plugin; } else { layoutId = R.layout.confirm_auth_activity_manager; } View view = inflater.inflate(layoutId, container, false); view.setFocusableInTouchMode(true); view.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(final View v, final int keyCode, final KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) { notApprovalProc(); return true; } return false; } }); // ? TextView textViewExpirePeriod = (TextView) view.findViewById(R.id.textViewExpirePeriod); textViewExpirePeriod.setText(expirePeriod); // ?? TextView textViewApplicationName = (TextView) view.findViewById(R.id.textViewAccessToken); textViewApplicationName.setText(applicationName); // ListView listViewScopes = (ListView) view.findViewById(R.id.listViewScopes); listViewScopes.setAdapter(new ArrayAdapter<>(getActivity(), R.layout.confirm_auth_scopes_list_item, R.id.textViewScope, displayScopes)); // ? Button buttonApproval = (Button) view.findViewById(R.id.buttonApproval); buttonApproval.setOnClickListener(mOnButtonApprovalClickListener); // ? Button buttonReject = (Button) view.findViewById(R.id.buttonReject); buttonReject.setOnClickListener(mOnButtonApprovalClickListener); if (!isForPlugin) { // ?(=?)??? TextView textViewPackageName = (TextView) view.findViewById(R.id.textPackageName); textViewPackageName.setText(packageName); // TextView textViewKeyword = (TextView) view.findViewById(R.id.textKeyword); textViewKeyword.setText(keyword); } if (timeout > 0) { startTimeoutTimer(timeout); } else { // ????????Activity? getActivity().finish(); } if (isAutoFlag) { new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { approvalProc(); } }); } return view; }
From source file:com.gigaset.home.Home.java
/** * Catch keys to avoid back through HOME in Back Stack *///from ww w. j ava2 s.c o m @Override public boolean dispatchKeyEvent(KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_BACK: return true; case KeyEvent.KEYCODE_HOME: return true; } } else if (event.getAction() == KeyEvent.ACTION_UP) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_BACK: if (!event.isCanceled()) { // Do BACK behavior. } return true; case KeyEvent.KEYCODE_HOME: if (!event.isCanceled()) { // Do HOME behavior. myPager.setCurrentItem(HomePagerAdapter.SCREEN_CENTER); } return true; } } return super.dispatchKeyEvent(event); }
From source file:com.nadmm.airports.afd.BrowseAirportsFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (savedInstanceState != null && savedInstanceState.containsKey(BROWSE_MODE)) { mMode = savedInstanceState.getInt(BROWSE_MODE); if (mMode == BROWSE_AIRPORTS_MODE) { mStateCode = savedInstanceState.getString(DatabaseManager.Airports.ASSOC_STATE); mStateName = savedInstanceState.getString(DatabaseManager.States.STATE_NAME); }// www. j a v a 2 s.c o m } else { mMode = BROWSE_STATE_MODE; } if (mMode == BROWSE_STATE_MODE) { setBackgroundTask(new BrowseStateTask()).execute(); } else { setBackgroundTask(new BrowseAirportsTask()).execute(mStateCode, mStateName); } View view = getView(); if (view != null) { view.setFocusableInTouchMode(true); view.requestFocus(); view.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (mMode == BROWSE_AIRPORTS_MODE && keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) { // Intercept back key to go back to state mode mMode = BROWSE_STATE_MODE; setListShown(false); getListView().setAdapter(null); setBackgroundTask(new BrowseStateTask()).execute(); return true; } return false; } }); } }
From source file:com.stu.zdy.weather.ui.fragment.InfoFragment.java
public void onResume() { super.onResume(); MobclickAgent.onPageStart(InfoFragment.TAG); getView().setFocusableInTouchMode(true); getView().requestFocus();//from ww w . j a va 2 s . c om getView().setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) { fragmentCallBack.callbackInfoFragment(null); return true; } return false; } }); }
From source file:com.dwdesign.tweetings.activity.SearchActivity.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { SharedPreferences mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE); if (mPreferences.getBoolean(PREFERENCE_KEY_VOLUME_NAVIGATION, false)) { if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_VOLUME_UP: { Intent broadcast = new Intent(); broadcast.setAction(BROADCAST_VOLUME_UP); sendBroadcast(broadcast); //scrollToPrevious(); return true; }/* ww w . j av a 2s .com*/ case KeyEvent.KEYCODE_VOLUME_DOWN: { Intent broadcast = new Intent(); broadcast.setAction(BROADCAST_VOLUME_DOWN); sendBroadcast(broadcast); //scrollToNext(); return true; } } } if (event.getAction() == KeyEvent.ACTION_UP && (event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_UP || event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_DOWN)) { return true; } } return super.dispatchKeyEvent(event); }