List of usage examples for android.os Vibrator vibrate
@RequiresPermission(android.Manifest.permission.VIBRATE) public void vibrate(VibrationEffect vibe)
From source file:org.mitre.svmp.activities.AppRTCVideoActivity.java
private void createTopPanel() { // TODO Auto-generated method stub ll.setOnClickListener(new View.OnClickListener() { @Override/*from www .j av a2 s.com*/ public void onClick(View v) { // TODO Auto-generated method stub } }); ImageView homeStreamingBtn = (ImageView) findViewById(R.id.homeStreamingBtn); homeStreamingBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent intent = new Intent(AppRTCVideoActivity.this, OvalDrawerActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | IntentCompat.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); disconnectAndExit(); } }); ImageView stopStreamingBtn = (ImageView) findViewById(R.id.stopStreamingBtn); stopStreamingBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub disconnectAndExit(); } }); scrollUpImgVw.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub // TODO Auto-generated method stub if (scrollClicked == false) { scrollClicked = true; Vibrator vb = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); vb.vibrate(50); // vsv.onPause(); vsvProgrssBar.setVisibility(View.VISIBLE); Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { vsvProgrssBar.setVisibility(View.INVISIBLE); // vsv.onResume(); scrollClicked = false; } }, 2000); SVMPProtocol.Request.Builder msg = SVMPProtocol.Request.newBuilder(); SVMPProtocol.TouchEvent.Builder eventmsg = SVMPProtocol.TouchEvent.newBuilder(); eventmsg.setAction(51); msg.setType(RequestType.TOUCHEVENT); msg.addTouch(eventmsg); // TODO: batch touch events // Send touch event to VM sendMessage(msg.build()); } } }); scrolldownImgVw.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub // TODO Auto-generated method stub if (scrollClicked == false) { scrollClicked = true; Vibrator vb = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); vb.vibrate(50); // vsv.onPause(); vsvProgrssBar.setVisibility(View.VISIBLE); Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { vsvProgrssBar.setVisibility(View.INVISIBLE); //vsv.onResume(); scrollClicked = false; } }, 2000); SVMPProtocol.Request.Builder msg = SVMPProtocol.Request.newBuilder(); SVMPProtocol.TouchEvent.Builder eventmsg = SVMPProtocol.TouchEvent.newBuilder(); eventmsg.setAction(50); msg.setType(RequestType.TOUCHEVENT); msg.addTouch(eventmsg); // TODO: batch touch events // Send touch event to VM sendMessage(msg.build()); } } }); ((ViewGroup) scrollBtnsRLayout.getParent()).removeView(scrollBtnsRLayout); ((ViewGroup) ll.getParent()).removeView(ll); }
From source file:org.chromium.chrome.browser.widget.findinpage.FindToolbar.java
@Override public void onFindResult(FindNotificationDetails result) { if (mResultBar != null) mResultBar.mWaitingForActivateAck = false; assert mFindInPageBridge != null; if ((result.activeMatchOrdinal == -1 || result.numberOfMatches == 1) && !result.finalUpdate) { // Wait until activeMatchOrdinal has been determined (is no longer // -1) before showing counts. Additionally, to reduce flicker, // ignore short-lived interim notifications with numberOfMatches set // to 1, which are sent as soon as something has been found (see bug // 894389 and FindBarController::UpdateFindBarForCurrentResult). // Instead wait until the scoping effort starts returning real // match counts (or the search actually finishes with 1 result). // This also protects against receiving bogus rendererSelectionRects // at the start (see below for why we can't filter them out). return;/*from ww w. j ava 2 s . c o m*/ } if (result.finalUpdate) { if (result.numberOfMatches > 0) { // TODO(johnme): Don't wait till end of find, stream rects live! mFindInPageBridge.requestFindMatchRects(mResultBar != null ? mResultBar.mRectsVersion : -1); } else { clearResults(); } findResultSelected(result.rendererSelectionRect); } // Even though we wait above until activeMatchOrdinal is no longer -1, // it's possible for it to still be -1 (unknown) in the final find // notification. This happens very rarely, e.g. if the m_activeMatch // found by WebFrameImpl::find has been removed from the DOM by the time // WebFrameImpl::scopeStringMatches tries to find the ordinal of the // active match (while counting the matches), as in b/4147049. In such // cases it looks less broken to show 0 instead of -1 (as desktop does). Context context = getContext(); String text = context.getResources().getString(R.string.find_in_page_count, Math.max(result.activeMatchOrdinal, 0), result.numberOfMatches); setStatus(text, result.numberOfMatches == 0); // The accessible version will be something like "Result 1 of 9". String accessibleText = getAccessibleStatusText(Math.max(result.activeMatchOrdinal, 0), result.numberOfMatches); mFindStatus.setContentDescription(accessibleText); announceStatusForAccessibility(accessibleText); // Vibrate when no results are found, unless you're just deleting chars. if (result.numberOfMatches == 0 && result.finalUpdate && !mFindInPageBridge.getPreviousFindText().startsWith(mFindQuery.getText().toString())) { final boolean hapticFeedbackEnabled = Settings.System.getInt(context.getContentResolver(), Settings.System.HAPTIC_FEEDBACK_ENABLED, 1) == 1; if (hapticFeedbackEnabled) { Vibrator v = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); final long noResultsVibrateDurationMs = 50; v.vibrate(noResultsVibrateDurationMs); } } }
From source file:liqui.droid.activity.Base.java
@Override public void onReceiveResult(int resultCode, Bundle resultData) { // Toast.makeText(this, "resultCode: " + resultCode, Toast.LENGTH_SHORT).show(); switch (resultCode) { case SyncService.STATUS_RUNNING: { mSyncing = true;/*ww w . jav a 2 s. c o m*/ // setProgressVisible(true); // Toast.makeText(this, "syncing..", Toast.LENGTH_SHORT).show(); // Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); // v.vibrate(300); break; } case SyncService.STATUS_FINISHED: { mSyncing = false; // setProgressVisible(false); // Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); // v.vibrate(300); // Toast.makeText(this, "finished syncing.", Toast.LENGTH_SHORT).show(); break; } case SyncService.STATUS_ERROR: { // Error happened down in SyncService, show as toast. mSyncing = false; // setProgressVisible(false); final String errorText = "sync error: " + resultData.getString(Intent.EXTRA_TEXT); Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); v.vibrate(300); Toast.makeText(this, errorText, Toast.LENGTH_LONG).show(); break; } } }
From source file:dk.dr.radio.afspilning.Afspiller.java
private void vibru(int ms) { Log.d("vibru " + ms); try {//from w ww . ja va 2s .c o m Vibrator vibrator = (Vibrator) App.instans.getSystemService(Activity.VIBRATOR_SERVICE); vibrator.vibrate(ms); // Tenu telefonon veka por 1/2a sekundo AlarmAlertWakeLock.createPartialWakeLock(App.instans).acquire(500); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.b44t.ui.Components.PasscodeView.java
private void onPasscodeError() { Vibrator v = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE); if (v != null) { v.vibrate(200); }//from w w w.ja v a 2 s . co m shakeTextView(2, 0); }
From source file:com.b44t.ui.Components.PasscodeView.java
private void showFingerprintError(CharSequence error) { fingerprintStatusTextView.setText(error); fingerprintStatusTextView.setTextColor(0xfff4511e); Vibrator v = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE); if (v != null) { v.vibrate(200); }/*w w w . j av a 2 s . c o m*/ AndroidUtilities.shakeView(fingerprintStatusTextView, 2, 0); }
From source file:jp.gr.java_conf.piropiroping.bluetoothcommander.MainActivity.java
private void setCommandButtonListener(String commandName, int commandVal) { Button commandButton = new Button(this); // ? commandButton.setText(commandName);// w w w .ja va 2s. c om commandButton.setTextSize(20); commandButton.setBackgroundResource(R.drawable.command_button_background); savedCommand.add(commandVal, commandButton); // ??? commandLayout.removeAllViews(); // ??? for (int i = 0; i < commandVal + 1; i++) { // ?(?Button + PlusButton) commandLayout.addView(savedCommand.get(i)); } commandLayout.addView(plusButton); /* ??? */ commandButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { Button button = (Button) view; String name = button.getText().toString(); try { InputStream in = openFileInput(name); BufferedReader reader = new BufferedReader(new InputStreamReader(in, "UTF-8")); String s; mOutEditText.getText().clear(); while ((s = reader.readLine()) != null) { mOutEditText.append(s); } reader.close(); } catch (IOException e) { e.printStackTrace(); } setCommandData(); // ASCIIBitmap? } }); /* ?? */ commandButton.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(final View view) { Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE); vibrator.vibrate(20); delState = true; // ?ON final Button button = (Button) view; final String name = button.getText().toString(); AlertDialog.Builder deleteCommandDialog = new AlertDialog.Builder(MainActivity.this); deleteCommandDialog.setTitle("??????"); deleteCommandDialog.setMessage(name); deleteCommandDialog.setPositiveButton("??", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // OK button pressed deleteFile(name); commandLayout.removeView(button); savedCommand.remove(button); } }); deleteCommandDialog.setNegativeButton("???", null); deleteCommandDialog.show(); return false; } }); /* Command delete design (TBD) */ // commandButton.setOnTouchListener(new View.OnTouchListener() { // @Override // public boolean onTouch(View view, MotionEvent motionEvent) { // int x = (int) motionEvent.getRawX(); // int y = (int) motionEvent.getRawY(); // // switch (motionEvent.getAction()) { // case MotionEvent.ACTION_DOWN: // viewX = view.getLeft(); // viewY = view.getTop(); // currentX = x; // currentY = y; // break; // case MotionEvent.ACTION_MOVE: // LinearLayout topLayout = (LinearLayout) findViewById(R.id.top_layout); //// topLayout.addView(view); // if (delState == true) { // int ajustX = currentX - x; // int ajustY = currentY - y; // viewX = viewX - ajustX; // viewY = viewY - ajustY; // view.layout(viewX, viewY, viewX + view.getWidth(), viewY + view.getHeight()); // currentX = x; // currentY = y; // } // break; // case MotionEvent.ACTION_UP: // delState = false; // // if(??) // // // // else // // ?xy??? // // break; // // } // return false; // } // }); }
From source file:com.example.administrator.myapplication2._2_exercise._2_Status_heart.fragments.LeftFragment.java
public void warning() { alertCount++;/*from www.jav a 2 s .c o m*/ if (playBool == true && (alertCount % 5 == 0)) { MediaPlayer ss1; ss1 = MediaPlayer.create(getActivity(), R.raw.alertsound2); // ss1.setLooping(true); ss1.start(); Vibrator vibrator = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE); vibrator.vibrate(2000); android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder( getActivity(), R.style.AppCompatAlertDialogStyle); builder.setTitle("?? "); builder.setMessage( " ? \nMAXIMUM ?\n" + "5 ?? ??.\n" + "? \n?? ."); builder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { playBool = true; } }); builder.show(); playBool = false; } }
From source file:com.skyousuke.ivtool.windows.MainWindow.java
private void showAppraisal() { appraisalButton.setOnClickListener(new OnClickListener() { @Override/*from www. ja va2s . com*/ public void onClick(View v) { Toast.makeText(context, "Long Press to Disable Appraisal", Toast.LENGTH_SHORT).show(); Vibrator vb = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); vb.vibrate(100); } }); appraisalButton.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { lostFocus(500); if (hasAppraisalShow()) hideAppraisal(); return true; } }); showTeamSelect(); appraisalButton.setText(R.string.no_appraisal); }
From source file:com.skyousuke.ivtool.windows.MainWindow.java
private void hideAppraisal() { hideTeamSelect();// w w w .ja v a 2s .c o m hideRangePhraseSelect(); hideBestStatSelect(); hideMatchedStatSelect(); hideStatSelect(); appraisalButton.setText(R.string.appraisal); appraisalButton.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { lostFocus(500); if (!hasAppraisalShow()) showAppraisal(); return true; } }); appraisalButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { lostFocus(500); Vibrator vb = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); vb.vibrate(25); if (!hasAppraisalShow()) showAppraisal(); } }); }