List of usage examples for android.view HapticFeedbackConstants CONTEXT_CLICK
int CONTEXT_CLICK
To view the source code for android.view HapticFeedbackConstants CONTEXT_CLICK.
Click Source Link
From source file:hack.ddakev.roadrant.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); sendButton = (Button) findViewById(R.id.sendButton); plateBox = (TextView) findViewById(R.id.plateNumber); thumbsUp = (ImageView) findViewById(R.id.thumbsup); thumbsDown = (ImageView) findViewById(R.id.thumbsdown); cameraIcon = (ImageView) findViewById(R.id.cameraButton); commentBox = (TextView) findViewById(R.id.comment); ratingN = -1;//from ww w. j a v a 2 s . c o m mGoogleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).addApi(LocationServices.API).build(); reviews = new ArrayList<Review>(); lr = new LocationRequest(); lr.setInterval(1000); lr.setFastestInterval(1000); lr.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY); loadPermissions(android.Manifest.permission.ACCESS_FINE_LOCATION, REQUEST_FINE_LOCATION); cameraIcon.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dispatchTakePictureIntent(); v.performHapticFeedback(HapticFeedbackConstants.CONTEXT_CLICK); } }); thumbsUp.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (ratingN == -1) { ((ImageView) v).setImageResource(R.drawable.thumbs_up_highlight); } else if (ratingN == 0) { thumbsDown.setImageResource(R.drawable.thumbs_down); ((ImageView) v).setImageResource(R.drawable.thumbs_up_highlight); } ratingN = 1; v.performHapticFeedback(HapticFeedbackConstants.CONTEXT_CLICK); } }); thumbsDown.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (ratingN == -1) { ((ImageView) v).setImageResource(R.drawable.thumbs_down_highlight); } else if (ratingN == 1) { thumbsUp.setImageResource(R.drawable.thumbs_up); ((ImageView) v).setImageResource(R.drawable.thumbs_down_highlight); } ratingN = 0; v.performHapticFeedback(HapticFeedbackConstants.CONTEXT_CLICK); } }); sendButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (!isConnected()) { Toast.makeText(getBaseContext(), "You're not connected to the internet", Toast.LENGTH_LONG) .show(); return; } license = plateBox.getText().toString(); commentS = commentBox.getText().toString(); if (license.equals("")) { Toast.makeText(getBaseContext(), "Enter license plate number!", Toast.LENGTH_LONG).show(); return; } if (ratingN == -1) { Toast.makeText(getBaseContext(), "Choose rating!", Toast.LENGTH_LONG).show(); return; } Review data = new Review(license, ratingN == 1, commentS, lat, lon); reviews.add(data); Toast.makeText(getBaseContext(), "Please wait", Toast.LENGTH_SHORT).show(); v.performHapticFeedback(HapticFeedbackConstants.CONTEXT_CLICK); } }); }