// Older apps may need this compatibility hack for measurement. sUseBrokenMakeMeasureSpec = targetSdkVersion <= JELLY_BEAN_MR1;
// Older apps expect onMeasure() to always be called on a layout pass, regardless // of whether a layout was requested on that View. sIgnoreMeasureCache = targetSdkVersion < KITKAT;
sCompatibilityDone = true; } /** add for view 触摸时震动 start **/ mVibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE); // end add }
/** * Play a sound effect for this view. * * <p>The framework will play sound effects for some built in actions, such as * clicking, but you may wish to play these effects in your widget, * for instance, for internal navigation. * * <p>The sound effect will only be played if sound effects are enabled by the user, and * {@link #isSoundEffectsEnabled()} is true. * * @param soundConstant One of the constants defined in {@link SoundEffectConstants} */ publicvoidplaySoundEffect(int soundConstant) { if (mAttachInfo == null || mAttachInfo.mRootCallbacks == null || !isSoundEffectsEnabled()) { return; } /** add for view 触摸时震动 start **/ boolean vibratorEnabled = Settings.System.getInt(mContext.getContentResolver(),Settings.System.HAPTIC_FEEDBACK_ENABLED,1)==1; if(mVibrator !=null && vibratorEnabled ){ try { mVibrator.vibrate(50); } catch (Exception e) { android.util.Log.v("View","Exception"+e.toString()); } } // end add