List of usage examples for android.view HapticFeedbackConstants VIRTUAL_KEY
int VIRTUAL_KEY
To view the source code for android.view HapticFeedbackConstants VIRTUAL_KEY.
Click Source Link
From source file:za.co.neilson.alarm.alert.AlarmAlertActivity.java
@Override public void onClick(View v) { if (!alarmActive) return;/*from www . j a v a 2 s . c o m*/ String button = (String) v.getTag(); v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); if (button.equalsIgnoreCase("clear")) { if (answerBuilder.length() > 0) { answerBuilder.setLength(answerBuilder.length() - 1); answerView.setText(answerBuilder.toString()); } } else if (button.equalsIgnoreCase(".")) { if (!answerBuilder.toString().contains(button)) { if (answerBuilder.length() == 0) answerBuilder.append(0); answerBuilder.append(button); answerView.setText(answerBuilder.toString()); } } else if (button.equalsIgnoreCase("-")) { if (answerBuilder.length() == 0) { answerBuilder.append(button); answerView.setText(answerBuilder.toString()); } } else { answerBuilder.append(button); answerView.setText(answerBuilder.toString()); if (isAnswerCorrect()) { alarmActive = false; if (vibrator != null) vibrator.cancel(); try { mediaPlayer.stop(); } catch (IllegalStateException ise) { } try { mediaPlayer.release(); } catch (Exception e) { } this.finish(); } } if (answerView.getText().length() >= answerString.length() && !isAnswerCorrect()) { answerView.setTextColor(Color.RED); } else { answerView.setTextColor(Color.BLACK); } }
From source file:za.co.neilson.alarm.AlarmActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.alarm_activity); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setTitle("E-care"); setSupportActionBar(toolbar);/*w w w. ja va 2 s. co m*/ db = new SQLiteHandler(getApplicationContext()); session = new SessionManager(getApplicationContext()); drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); NavigationView view = (NavigationView) findViewById(R.id.navigation_view); view.getMenu().getItem(3).setChecked(true); view.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem menuItem) { Toast.makeText(AlarmActivity.this, menuItem.getItemId() + " pressed", Toast.LENGTH_LONG).show(); Log.d(R.id.nav_1 + "", menuItem.getItemId() + " "); Intent intent = new Intent(); switch (menuItem.getItemId()) { case R.id.nav_1: intent.setClass(AlarmActivity.this, Case_history_review.class); startActivity(intent); break; case R.id.nav_2: intent.setClass(AlarmActivity.this, ShowAppointmentList.class); //intent .putExtra("name", "Hello B Activity"); startActivity(intent); break; case R.id.nav_3: intent.setClass(AlarmActivity.this, Appointmentcreate.class); //intent .putExtra("name", "Hello B Activity"); startActivity(intent); break; case R.id.nav_4: intent.setClass(AlarmActivity.this, AlarmActivity.class); //intent .putExtra("name", "Hello B Activity"); startActivity(intent); break; case R.id.nav_5: intent.setClass(AlarmActivity.this, PatientReport.class); //intent .putExtra("name", "Hello B Activity"); startActivity(intent); break; case R.id.nav_6: //logout AlertDialog.Builder builder = new AlertDialog.Builder(AlarmActivity.this); //Uncomment the below code to Set the message and title from the strings.xml file //builder.setMessage(R.string.dialog_message) .setTitle(R.string.dialog_title); //Setting message manually and performing action on button click builder.setMessage("Do you want to close this application ?").setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { session.setLogin(false); db.deleteUsers(); final Intent intent_logout = new Intent(AlarmActivity.this, LoginActivity.class); startActivity(intent_logout); finish(); } }).setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // Action for 'NO' Button dialog.cancel(); } }); //Creating dialog box AlertDialog alert = builder.create(); //Setting the title manually alert.setTitle("AlertDialogExample"); alert.show(); break; } menuItem.setChecked(true); drawerLayout.closeDrawers(); return true; } }); ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.drawer_open, R.string.drawer_close) { @Override public void onDrawerClosed(View drawerView) { super.onDrawerClosed(drawerView); } @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); } }; HashMap<String, String> dbuser = db.getUserDetails(); View header = view.getHeaderView(0); TextView headerName = (TextView) header.findViewById(R.id.drawer_name); String username = dbuser.get("name"); headerName.setText(username); ImageLoader imageLoader = AppController.getInstance().getImageLoader(); CirculaireNetworkImageView headerphoto = (CirculaireNetworkImageView) header .findViewById(R.id.drawer_thumbnail); headerphoto.setImageUrl("http://192.168.43.216/test/" + dbuser.get("image"), imageLoader); drawerLayout.setDrawerListener(actionBarDrawerToggle); actionBarDrawerToggle.syncState(); mathAlarmListView = (ListView) findViewById(android.R.id.list); mathAlarmListView.setLongClickable(true); mathAlarmListView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> adapterView, View view, int position, long id) { view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); final Alarm alarm = (Alarm) alarmListAdapter.getItem(position); Builder dialog = new AlertDialog.Builder(AlarmActivity.this); dialog.setTitle("Delete"); dialog.setMessage("Delete this alarm?"); dialog.setPositiveButton("Ok", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Database.init(AlarmActivity.this); Database.deleteEntry(alarm); AlarmActivity.this.callMathAlarmScheduleService(); updateAlarmList(); } }); dialog.setNegativeButton("Cancel", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.show(); return true; } }); callMathAlarmScheduleService(); alarmListAdapter = new AlarmListAdapter(this); this.mathAlarmListView.setAdapter(alarmListAdapter); mathAlarmListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View v, int position, long id) { v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); Alarm alarm = (Alarm) alarmListAdapter.getItem(position); Intent intent = new Intent(AlarmActivity.this, AlarmPreferencesActivity.class); intent.putExtra("alarm", alarm); startActivity(intent); } }); }
From source file:com.ritesh.sevilla.EditDeliverAddressPhoneFields.VerifyPhoneFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.activity_edit_delivery_address, container, false); ButterKnife.bind(this, rootView); Appconstant.sh = getActivity().getSharedPreferences(Appconstant.MyPREFERENCES, Context.MODE_PRIVATE); User_ID = Appconstant.sh.getString("id", null); Log.e("User_ID from SharedPref :", "" + User_ID); /*textDotLoaderCountry = (DotLoader) rootView.findViewById(R.id.text_dot_loader_country); for (int i = 1; i < 4; i++) {/*from w ww . ja v a 2s . co m*/ textDotLoaderCountry.postDelayed(new DotIncrementRunnable(3 + i, textDotLoaderCountry), i * 3000); } textDotLoaderState = (DotLoader) rootView.findViewById(R.id.text_dot_loader_state); for (int i = 1; i < 4; i++) { textDotLoaderState.postDelayed(new DotIncrementRunnable(3 + i, textDotLoaderState), i * 3000); } textDotLoaderCity = (DotLoader) rootView.findViewById(R.id.text_dot_loader_city); for (int i = 1; i < 4; i++) { textDotLoaderCity.postDelayed(new DotIncrementRunnable(3 + i, textDotLoaderCity), i * 3000); }*/ if (Utils.isConnected(getActivity())) { UserGetAddressJsontask task = new UserGetAddressJsontask(); task.execute(); } else { SnackbarManager.show(Snackbar.with(getActivity()).position(Snackbar.SnackbarPosition.TOP).margin(15, 15) .backgroundDrawable(R.drawable.snackbar_custom_layout) .text("Please Your Internet Connectivity..!!")); } CPB_address_progressbar_circular = (CircularProgressBar) rootView .findViewById(R.id.cpb_address_progressbar_circular); // signupProgress.setVisibility(View.GONE); ((CircularProgressDrawable) CPB_address_progressbar_circular.getIndeterminateDrawable()).start(); updateValues(); /*%%%%%%%%%%%%%% Spinner Country (Start) %%%%%%%%%%%%%%*/ /*spinner click method and not clicked method for country (Start)*/ SP_user_country.setOnItemSelectedListener(new MaterialSpinner.OnItemSelectedListener<String>() { @Override public void onItemSelected(MaterialSpinner view, int position, long id, String item) { SP_user_country.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); /*Toast.makeText(getActivity(), "Position :" + " " + position + " Clicked " + "" + item, Toast.LENGTH_SHORT).show();*/ Log.e("Country Detail :", "Position :" + "" + position + "\t" + "ID :" + "" + id + "\t" + "Name :" + "" + item); /*android.support.design.widget.Snackbar.make(view, "Clicked " + item, android.support.design.widget.Snackbar.LENGTH_SHORT).show();*/ Get_user_country_SelectedValue = item; Str_get_user_country = item; Str_set_user_country = Str_get_user_country; long pos = id; int posi = position; Log.e("pos :", "" + pos); Log.e("posi ID:", "" + posi); GetSet_user_country_ID = String.valueOf(posi); Log.e("GetSet_user_country_ID :", "" + GetSet_user_country_ID); Log.e("Str_get_user_country :", "" + Str_get_user_country); Log.e("Str_set_user_country :", "" + Str_set_user_country); Log.e("Get_user_country_SelectedValue :", "" + Get_user_country_SelectedValue); if (Utils.isConnected(getActivity())) { UserStateListJsontask task = new UserStateListJsontask(); task.execute(); } else { SnackbarManager.show(Snackbar.with(getActivity()).position(Snackbar.SnackbarPosition.TOP) .margin(15, 15).backgroundDrawable(R.drawable.snackbar_custom_layout) .text("Please Your Internet Connectivity..!!")); } } }); SP_user_country.setOnNothingSelectedListener(new MaterialSpinner.OnNothingSelectedListener() { @Override public void onNothingSelected(MaterialSpinner spinner) { /*Toast.makeText(getActivity(), "Please select Country First..!!", Toast.LENGTH_SHORT).show();*/ android.support.design.widget.Snackbar.make(spinner, "Please select Country First..!!", android.support.design.widget.Snackbar.LENGTH_SHORT).show(); } }); /*%%%%%%%%%%%%%% Spinner Country (End) %%%%%%%%%%%%%%*/ /*%%%%%%%%%%%%%% Spinner State (Start) %%%%%%%%%%%%%%*/ SP_user_state.setOnItemSelectedListener(new MaterialSpinner.OnItemSelectedListener<String>() { @Override public void onItemSelected(MaterialSpinner view, int position, long id, String item) { SP_user_state.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); /*Toast.makeText(getActivity(), "Position :" + " " + position + " Clicked " + "" + item, Toast.LENGTH_SHORT).show();*/ Log.e("State Detail :", "Position :" + "" + position + "\t" + "ID :" + "" + id + "\t" + "Name :" + "" + item); /*android.support.design.widget.Snackbar.make(view, "Clicked " + item, android.support.design.widget.Snackbar.LENGTH_SHORT).show();*/ Get_user_state_SelectedValue = item; Str_get_user_state = item; Str_set_user_state = Str_get_user_state; long pos = id; int posi = position; Log.e("pos :", "" + pos); Log.e("posi ID:", "" + posi); GetSet_user_state_ID = String.valueOf(posi); Log.e("GetSet_user_state_ID :", "" + GetSet_user_state_ID); Log.e("Str_get_user_state :", "" + Str_get_user_state); Log.e("Str_set_user_state :", "" + Str_set_user_state); if (Utils.isConnected(getActivity())) { UserCityListJsontask task = new UserCityListJsontask(); task.execute(); } else { SnackbarManager.show(Snackbar.with(getActivity()).position(Snackbar.SnackbarPosition.TOP) .margin(15, 15).backgroundDrawable(R.drawable.snackbar_custom_layout) .text("Please Your Internet Connectivity..!!")); } } }); SP_user_state.setOnNothingSelectedListener(new MaterialSpinner.OnNothingSelectedListener() { @Override public void onNothingSelected(MaterialSpinner spinner) { /*Toast.makeText(getActivity(), "Please select Country First..!!", Toast.LENGTH_SHORT).show();*/ android.support.design.widget.Snackbar.make(spinner, "Please select State First..!!", android.support.design.widget.Snackbar.LENGTH_SHORT).show(); } }); /*%%%%%%%%%%%%%% Spinner State (End) %%%%%%%%%%%%%%*/ /*%%%%%%%%%%%%%% Spinner City (Start) %%%%%%%%%%%%%%*/ SP_user_city.setOnItemSelectedListener(new MaterialSpinner.OnItemSelectedListener<String>() { @Override public void onItemSelected(MaterialSpinner view, int position, long id, String item) { SP_user_city.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); /*Toast.makeText(getActivity(), "Position :" + " " + position + " Clicked " + "" + item, Toast.LENGTH_SHORT).show();*/ Log.e("City Detail :", "Position :" + "" + position + "\t" + "ID :" + "" + id + "\t" + "Name :" + "" + item); /*android.support.design.widget.Snackbar.make(view, "Clicked " + item, android.support.design.widget.Snackbar.LENGTH_SHORT).show();*/ Get_user_city_SelectedValue = item; Str_get_user_city = item; Str_set_user_city = Str_get_user_city; Log.e("Get_user_city_SelectedValue :", "" + Get_user_city_SelectedValue); Log.e("Str_get_user_city :", "" + Str_get_user_city); Log.e("Str_set_user_city :", "" + Str_set_user_city); } }); SP_user_city.setOnNothingSelectedListener(new MaterialSpinner.OnNothingSelectedListener() { @Override public void onNothingSelected(MaterialSpinner spinner) { /*Toast.makeText(getActivity(), "Please select Country First..!!", Toast.LENGTH_SHORT).show();*/ android.support.design.widget.Snackbar.make(spinner, "Please select City First..!!", android.support.design.widget.Snackbar.LENGTH_SHORT).show(); } }); /*%%%%%%%%%%%%%% Spinner City (End) %%%%%%%%%%%%%%*/ CV_et_address_continue_payment.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { Str_set_user_f_name = ET_address_user_first_name.getText().toString().trim(); Str_set_user_l_name = ET_address_user_last_name.getText().toString().trim(); Str_set_user_street_address = ET_address_user_address.getText().toString().trim(); Str_set_user_phone = ET_address_phone.getText().toString().trim(); Str_set_user_phone_replace = Str_set_user_phone.replace(" ", ""); Str_set_user_zip_code = ET_address_user_zip_code.getText().toString().trim(); Log.e("Address Data :", "\n" + "Str_set_user_f_name :" + "" + Str_set_user_f_name + "\n" + "Str_set_user_l_name :" + "" + Str_set_user_l_name + "\n" + "Str_set_user_street_address :" + "" + Str_set_user_street_address + "\n" + "Str_set_user_phone :" + "" + Str_set_user_phone + "\n" + "Str_set_user_phone_replace :" + "" + Str_set_user_phone_replace + "\n" + "Str_set_user_zip_code :" + "" + Str_set_user_zip_code + "\n" + "Str_set_user_country :" + "" + Str_set_user_country + "\n" + "Str_set_user_state :" + "" + Str_set_user_state + "\n" + "Str_set_user_city :" + "" + Str_set_user_city + "\n"); if (event.getAction() == MotionEvent.ACTION_DOWN) { Log.e("Action ", "Down"); CV_et_address_continue_payment_click.setVisibility(View.VISIBLE); CV_et_address_continue_payment.setVisibility(View.GONE); v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); // Toast.makeText(getApplicationContext(), "Add to cart Clicked", Toast.LENGTH_SHORT).show(); return true; } if (event.getAction() == MotionEvent.ACTION_MOVE) { Log.e("Action ", "Move"); CV_et_address_continue_payment_click.setVisibility(View.VISIBLE); CV_et_address_continue_payment.setVisibility(View.GONE); return true; } if (event.getAction() == MotionEvent.ACTION_UP) { Log.e("Action ", "Up"); CV_et_address_continue_payment_click.setVisibility(View.GONE); CV_et_address_continue_payment.setVisibility(View.VISIBLE); /*Intent MyCartPage = new Intent(GetDeliveryAddress.this, MyCartActivity.class); startActivity(MyCartPage);*/ if (Str_set_user_f_name.isEmpty()) { ISerror = true; v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); // v.playSoundEffect(SoundEffectConstants.CLICK); /**************** Start Animation ************** **/ YoYo.with(Techniques.Tada).duration(700).playOn(ET_address_user_first_name); /**************** End Animation ****************/ /*Toast.makeText(getApplicationContext(), "Please enter your Email Id", Toast.LENGTH_SHORT).show();*/ SnackbarManager.show(Snackbar.with(getActivity()).position(Snackbar.SnackbarPosition.TOP) .margin(15, 15).backgroundDrawable(R.drawable.snackbar_custom_layout) .text("Please enter your First Name")); } else if (Str_set_user_l_name.isEmpty()) { ISerror = true; v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); // v.playSoundEffect(SoundEffectConstants.CLICK); /**************** Start Animation ************** **/ YoYo.with(Techniques.Tada).duration(700).playOn(ET_address_user_last_name); /**************** End Animation ****************/ /*Toast.makeText(getApplicationContext(), "Please enter your Email Id", Toast.LENGTH_SHORT).show();*/ SnackbarManager.show(Snackbar.with(getActivity()).position(Snackbar.SnackbarPosition.TOP) .margin(15, 15).backgroundDrawable(R.drawable.snackbar_custom_layout) .text("Please enter your Last Name")); } else if (Str_set_user_street_address.isEmpty()) { ISerror = true; v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); // v.playSoundEffect(SoundEffectConstants.CLICK); /**************** Start Animation ************** **/ YoYo.with(Techniques.Tada).duration(700).playOn(ET_address_user_address); /**************** End Animation ****************/ /*Toast.makeText(getApplicationContext(), "Please enter your Email Id", Toast.LENGTH_SHORT).show();*/ SnackbarManager.show(Snackbar.with(getActivity()).position(Snackbar.SnackbarPosition.TOP) .margin(15, 15).backgroundDrawable(R.drawable.snackbar_custom_layout) .text("Please enter your Street Address")); } else if (Str_set_user_phone_replace.isEmpty()) { ISerror = true; v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); // v.playSoundEffect(SoundEffectConstants.CLICK); /**************** Start Animation ************** **/ YoYo.with(Techniques.Tada).duration(700).playOn(ET_address_phone); /**************** End Animation ****************/ /*Toast.makeText(getApplicationContext(), "Please enter your Email Id", Toast.LENGTH_SHORT).show();*/ SnackbarManager.show(Snackbar.with(getActivity()).position(Snackbar.SnackbarPosition.TOP) .margin(15, 15).backgroundDrawable(R.drawable.snackbar_custom_layout) .text("Please enter your Phone Number")); } else if (Str_set_user_country.isEmpty()) { ISerror = true; v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); // v.playSoundEffect(SoundEffectConstants.CLICK); /**************** Start Animation ************** **/ YoYo.with(Techniques.Tada).duration(700).playOn(SP_user_country); /**************** End Animation ****************/ /*Toast.makeText(getApplicationContext(), "Please enter your Email Id", Toast.LENGTH_SHORT).show();*/ SnackbarManager.show(Snackbar.with(getActivity()).position(Snackbar.SnackbarPosition.TOP) .margin(15, 15).backgroundDrawable(R.drawable.snackbar_custom_layout) .text("Please select your Country")); } else if (Str_set_user_state.isEmpty()) { ISerror = true; v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); // v.playSoundEffect(SoundEffectConstants.CLICK); /**************** Start Animation ************** **/ YoYo.with(Techniques.Tada).duration(700).playOn(SP_user_state); /**************** End Animation ****************/ /*Toast.makeText(getApplicationContext(), "Please enter your Email Id", Toast.LENGTH_SHORT).show();*/ SnackbarManager.show(Snackbar.with(getActivity()).position(Snackbar.SnackbarPosition.TOP) .margin(15, 15).backgroundDrawable(R.drawable.snackbar_custom_layout) .text("Please select your State")); } else if (Str_set_user_city.isEmpty()) { ISerror = true; v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); // v.playSoundEffect(SoundEffectConstants.CLICK); /**************** Start Animation ***************/ YoYo.with(Techniques.Tada).duration(700).playOn(SP_user_city); /**************** End Animation ****************/ /*Toast.makeText(getApplicationContext(), "Please enter your Email Id", Toast.LENGTH_SHORT).show();*/ SnackbarManager.show(Snackbar.with(getActivity()).position(Snackbar.SnackbarPosition.TOP) .margin(15, 15).backgroundDrawable(R.drawable.snackbar_custom_layout) .text("Please select your City")); } else if (Str_set_user_zip_code.isEmpty()) { ISerror = true; v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); // v.playSoundEffect(SoundEffectConstants.CLICK); /**************** Start Animation ************** **/ YoYo.with(Techniques.Tada).duration(700).playOn(ET_address_user_zip_code); /**************** End Animation ****************/ /*Toast.makeText(getApplicationContext(), "Please enter your Email Id", Toast.LENGTH_SHORT).show();*/ SnackbarManager.show(Snackbar.with(getActivity()).position(Snackbar.SnackbarPosition.TOP) .margin(15, 15).backgroundDrawable(R.drawable.snackbar_custom_layout) .text("Please enter your area code")); } else if (!ISerror) { // v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); /*Toast.makeText(getApplicationContext(), "Good", Toast.LENGTH_SHORT).show();*/ if (Utils.isConnected(getActivity())) { UserUpdateAddressJsontask task = new UserUpdateAddressJsontask(); task.execute(); } else { SnackbarManager .show(Snackbar.with(getActivity()).position(Snackbar.SnackbarPosition.TOP) .margin(15, 15).backgroundDrawable(R.drawable.snackbar_custom_layout) .text("Please Your Internet Connectivity..!!")); } /* SnackbarManager.show( Snackbar.with(getActivity()) .position(Snackbar.SnackbarPosition.TOP) .margin(15, 15) .backgroundDrawable(R.drawable.snackbar_custom_layout) .text("Good All Value Correct"));*/ // v.playSoundEffect(android.view.SoundEffectConstants.CLICK); } /*SnackbarManager.show( Snackbar.with(getActivity()) .position(Snackbar.SnackbarPosition.TOP) .margin(15, 15) .backgroundDrawable(R.drawable.snackbar_custom_layout) .text("Confirm Clicked")); */ return true; } return false; } }); initUI(rootView); return rootView; }
From source file:org.catrobat.catroid.cast.CastManager.java
private synchronized void handleGamepadTouch(ImageButton button, MotionEvent event) { if (event.getAction() != MotionEvent.ACTION_DOWN && event.getAction() != MotionEvent.ACTION_UP) { // We only care about the event when a gamepad button is pressed and when a gamepad button is unpressed return;/* w w w. ja v a 2 s .co m*/ } if (gamepadActivity == null) { return; } boolean isActionDown = (event.getAction() == MotionEvent.ACTION_DOWN); String buttonPressedName; switch (button.getId()) { case R.id.gamepadButtonA: buttonPressedName = gamepadActivity.getString(R.string.cast_gamepad_A); button.setImageResource( isActionDown ? R.drawable.gamepad_button_a_pressed : R.drawable.gamepad_button_a); setButtonPress(Sensors.GAMEPAD_A_PRESSED, isActionDown); break; case R.id.gamepadButtonB: buttonPressedName = gamepadActivity.getString(R.string.cast_gamepad_B); button.setImageResource( isActionDown ? R.drawable.gamepad_button_b_pressed : R.drawable.gamepad_button_b); setButtonPress(Sensors.GAMEPAD_B_PRESSED, isActionDown); break; case R.id.gamepadButtonUp: buttonPressedName = gamepadActivity.getString(R.string.cast_gamepad_up); setButtonPress(Sensors.GAMEPAD_UP_PRESSED, isActionDown); break; case R.id.gamepadButtonDown: buttonPressedName = gamepadActivity.getString(R.string.cast_gamepad_down); setButtonPress(Sensors.GAMEPAD_DOWN_PRESSED, isActionDown); break; case R.id.gamepadButtonLeft: buttonPressedName = gamepadActivity.getString(R.string.cast_gamepad_left); setButtonPress(Sensors.GAMEPAD_LEFT_PRESSED, isActionDown); break; case R.id.gamepadButtonRight: buttonPressedName = gamepadActivity.getString(R.string.cast_gamepad_right); setButtonPress(Sensors.GAMEPAD_RIGHT_PRESSED, isActionDown); break; default: throw new IllegalArgumentException("Unknown button pressed"); } if (isActionDown) { ((StageListener) gamepadActivity.getApplicationListener()).gamepadPressed(buttonPressedName); button.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); } }
From source file:com.appeaser.sublimepickerlibrary.utilities.SUtils.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public static void vibrateForDatePicker(View view) { // Using a different haptic feedback constant view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY /*(5) - HapticFeedbackConstants.CALENDAR_DATE*/); }
From source file:com.appeaser.sublimepickerlibrary.utilities.SUtils.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public static void vibrateForTimePicker(View view) { view.performHapticFeedback(/* ww w.j a v a 2 s . co m*/ isApi_21_OrHigher() ? HapticFeedbackConstants.CLOCK_TICK : HapticFeedbackConstants.VIRTUAL_KEY); }
From source file:com.achep.acdisplay.ui.widgets.CircleView.java
/** * Sets the radius of fake circle.// w w w . ja v a2 s . c o m * * @param radius radius to set */ private void setRadius(float radius) { mRadius = radius; if (!mCanceled) { // Save maximum radius for detecting // decreasing of the circle's size. if (mRadius > mRadiusMaxPeak) { mRadiusMaxPeak = mRadius; } else if (mRadiusMaxPeak - mRadius > mRadiusDecreaseThreshold) { cancelCircle(); return; // Cancelling circle will recall #setRadius } boolean aimed = mRadius >= mRadiusTarget; if (mRadiusTargetAimed != aimed) { mRadiusTargetAimed = aimed; // Vibrate if the user is interacting with the device. if (isInTouchMode()) performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); } } final float ratio = calculateRatio(); int alpha; // Update unlock icon's transparency. if (mDrawable != null) { alpha = (int) (255 * Math.pow(ratio, 3)); mDrawable.setAlpha(alpha); } // Update corners' icons transparency. alpha = (int) (50f * Math.pow(1f - ratio, 0.3f)); mDrawableLeftTopCorner.setAlpha(alpha); mDrawableRightTopCorner.setAlpha(alpha); mDrawableLeftBottomCorner.setAlpha(alpha); mDrawableRightBottomCorner.setAlpha(alpha); // Update the size of the unlock circle. radius = (float) Math.sqrt(mRadius / 50f) * 50f; setRadiusDrawn(radius); }
From source file:de.dmarcini.bt.homelight.HomeLightMainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (BuildConfig.DEBUG) { Log.v(TAG, "erzeuge Application..."); }/*from ww w.ja va2 s .c o m*/ setContentView(R.layout.activity_home_light_main); if (BuildConfig.DEBUG) { Log.e(TAG, "D E B U G Version"); } //############################################################################################## // // Ist Bluethooth LE (4.0) untersttzt? // if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) { Toast.makeText(this, R.string.main_ble_not_supported, Toast.LENGTH_SHORT).show(); finish(); } // // initialisiere den Adapter // final BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); btConfig.setBluetoothAdapter(bluetoothManager.getAdapter()); // // Ist ein BT Adapter vorhanden? // if (btConfig.getBluethoothAdapter() == null) { Toast.makeText(this, R.string.main_ble_not_supported, Toast.LENGTH_SHORT).show(); finish(); return; } // // Systemeinstellungen einlesen // HomeLightSysConfig.readSysPrefs(getResources(), PreferenceManager.getDefaultSharedPreferences(this)); // // Kommando-Queue Tread aktivieren // cmdTread = new CmdQueueThread(recCmdQueue, CReciver); Thread tr = new Thread(cmdTread, "cmd_queue_thread"); tr.start(); // // Vorerst nur der Platzhalter fr ein Spielerchen spter // FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fabOnOff); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); setModulOnOff(); //Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG).setAction("Action", null).show(); } }); if (BuildConfig.DEBUG) { Log.v(TAG, "erzeuge Application...OK"); } }
From source file:com.hippo.widget.lockpattern.LockPatternView.java
/** * Determines whether the point x, y will add a new point to the current * pattern (in addition to finding the cell, also makes heuristic choices * such as filling in gaps based on current pattern). * @param x The x coordinate.//from w ww.j ava2 s.com * @param y The y coordinate. */ private Cell detectAndAddHit(float x, float y) { final Cell cell = checkForNewHit(x, y); if (cell != null) { // check for gaps in existing pattern Cell fillInGapCell = null; final ArrayList<Cell> pattern = mPattern; if (!pattern.isEmpty()) { final Cell lastCell = pattern.get(pattern.size() - 1); int dRow = cell.row - lastCell.row; int dColumn = cell.column - lastCell.column; int fillInRow = lastCell.row; int fillInColumn = lastCell.column; if (Math.abs(dRow) == 2 && Math.abs(dColumn) != 1) { fillInRow = lastCell.row + ((dRow > 0) ? 1 : -1); } if (Math.abs(dColumn) == 2 && Math.abs(dRow) != 1) { fillInColumn = lastCell.column + ((dColumn > 0) ? 1 : -1); } fillInGapCell = Cell.of(fillInRow, fillInColumn); } if (fillInGapCell != null && !mPatternDrawLookup[fillInGapCell.row][fillInGapCell.column]) { addCellToPattern(fillInGapCell); } addCellToPattern(cell); if (mEnableHapticFeedback) { performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING | HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } return cell; } return null; }
From source file:org.docrj.smartcard.reader.AppSelectActivity.java
@Override public void setUserSelectListener(final ReaderXcvr.UiListener callback) { mSelectButton.setOnClickListener(new View.OnClickListener() { @Override//from w w w. j a va 2s. c om public void onClick(View v) { // haptic feedback if (mSelectHaptic) { v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } // update console and do select transaction if (mAutoClear) { clearMessages(false); // short delay to show cleared messages mHandler.postDelayed(new Runnable() { public void run() { callback.onUserSelect(mApps.get(mSelectedAppPos).getAid()); } }, 50L); } else { clearImage(); addMessageSeparator(); callback.onUserSelect(mApps.get(mSelectedAppPos).getAid()); } } }); }