List of usage examples for android.view View performHapticFeedback
public boolean performHapticFeedback(int feedbackConstant, int flags)
From source file:com.andrewsummers.otashu.DepthPageTransformer.java
/** * transformPage used to apply a custom transformation (animation) to page view scrolling. * /* ww w . j av a2 s. co m*/ * @param view Incoming view. * @param position Current position of page relative to current "front and center" page. As per * the official ViewPager documentation, possible values are: -1 is one page position * to the left 0 is front and center. 1 is one page position to the right */ public void transformPage(View view, float position) { int pageWidth = view.getWidth(); // if application touch feedback setting is set, enable touch feedback if (pref_touch_feedback_enabled) { view.setHapticFeedbackEnabled(true); view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } // current page setting: [-Infinity, -1) if (position < -1) { // this page is way off-screen to the left view.setAlpha(0); } // current page setting: [-1, 0] else if (position <= 0) { // use the default slide transition when moving to the left page view.setAlpha(1); // view.setHapticFeedbackEnabled(hapticFeedbackEnabled); view.setTranslationY(pageWidth * position); view.setScaleX(1); view.setScaleY(1); } // current page setting: (0, 1) else if (position <= 1) { // fade page out view.setAlpha(1 - position); // counteract the default slide transition view.setTranslationY(pageWidth * -position); // scale the page down (between MIN_SCALE and 1) float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position)); view.setScaleX(scaleFactor); view.setScaleY(scaleFactor); } // current page setting: (1, +Infinity] else { // this page is way off-screen to the right view.setAlpha(0); } }
From source file:org.docrj.smartcard.reader.AppSelectActivity.java
private void prepareViewForMode() { mIntro.setText(mManual ? R.string.intro_app_select_manual : R.string.intro_app_select); if (mManual) { mSelectButton.setOnClickListener(new View.OnClickListener() { @Override/* www . j a va 2 s .c om*/ public void onClick(View v) { if (mSelectHaptic) { v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } clearMessages(false); // short delay to show cleared messages mHandler.postDelayed(new Runnable() { public void run() { onError(getString(R.string.manual_disconnected)); } }, 50L); } }); if (mSelectBar.getVisibility() == View.INVISIBLE) { // slide select bar up and shake the button! mSelectBar.setVisibility(View.VISIBLE); Animation slideUp = AnimationUtils.loadAnimation(this, R.anim.slide_up); mSelectBar.startAnimation(slideUp); Animation shake = AnimationUtils.loadAnimation(this, R.anim.shake); mSelectButton.startAnimation(shake); } } else { if (mSelectBar.getVisibility() == View.VISIBLE) { Animation slideDown = AnimationUtils.loadAnimation(this, R.anim.slide_down); mSelectBar.startAnimation(slideDown); mSelectBar.setVisibility(View.INVISIBLE); } } }
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 ww . j a v a2s. 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()); } } }); }