Package org.robolectric.shadows
Class ShadowVibrator
- java.lang.Object
-
- org.robolectric.shadows.ShadowVibrator
-
- Direct Known Subclasses:
ShadowSystemVibrator
@Implements(android.os.Vibrator.class) public class ShadowVibrator extends Object
-
-
Field Summary
Fields Modifier and Type Field Description protected long[]
pattern
protected List<Integer>
supportedPrimitives
protected VibrationAttributes
vibrationAttributesFromLastVibration
protected List<VibrationEffectSegment>
vibrationEffectSegments
-
Constructor Summary
Constructors Constructor Description ShadowVibrator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
areAllPrimitivesSupported(int... primitiveIds)
int
getEffectId()
Returns the last vibration effect ID of aVibrationEffect#Prebaked
(e.g.long
getMilliseconds()
Returns the last vibration duration in MS.long[]
getPattern()
Returns the last vibration pattern.int
getRepeat()
Returns the last vibration repeat times.VibrationAttributes
getVibrationAttributesFromLastVibration()
Returns theVibrationAttributes
from the last vibration.List<VibrationEffectSegment>
getVibrationEffectSegments()
Returns the last list ofVibrationEffectSegment
.boolean
isCancelled()
Returns true if the Vibrator has been cancelled.boolean
isVibrating()
Returns true if the Vibrator is currently vibrating as controlled byVibrator.vibrate(long)
void
setHasAmplitudeControl(boolean hasAmplitudeControl)
Controls the return value ofVibrator.hasAmplitudeControl()
the default is false.void
setHasVibrator(boolean hasVibrator)
Controls the return value ofVibrator.hasVibrator()
the default is true.void
setSupportedPrimitives(Collection<Integer> primitives)
Adds supported vibration primitives.
-
-
-
Field Detail
-
pattern
protected long[] pattern
-
vibrationEffectSegments
protected final List<VibrationEffectSegment> vibrationEffectSegments
-
vibrationAttributesFromLastVibration
@Nullable protected VibrationAttributes vibrationAttributesFromLastVibration
-
-
Method Detail
-
setHasVibrator
public void setHasVibrator(boolean hasVibrator)
Controls the return value ofVibrator.hasVibrator()
the default is true.
-
setHasAmplitudeControl
public void setHasAmplitudeControl(boolean hasAmplitudeControl)
Controls the return value ofVibrator.hasAmplitudeControl()
the default is false.
-
isVibrating
@Implementation(minSdk=30) public boolean isVibrating()
Returns true if the Vibrator is currently vibrating as controlled byVibrator.vibrate(long)
-
isCancelled
public boolean isCancelled()
Returns true if the Vibrator has been cancelled.
-
getMilliseconds
public long getMilliseconds()
Returns the last vibration duration in MS.
-
getPattern
public long[] getPattern()
Returns the last vibration pattern.
-
getEffectId
public int getEffectId()
Returns the last vibration effect ID of aVibrationEffect#Prebaked
(e.g.VibrationEffect.EFFECT_CLICK
).This field is non-zero only if a
VibrationEffect#Prebaked
was ever requested.
-
getRepeat
public int getRepeat()
Returns the last vibration repeat times.
-
getVibrationEffectSegments
public List<VibrationEffectSegment> getVibrationEffectSegments()
Returns the last list ofVibrationEffectSegment
.
-
areAllPrimitivesSupported
@Implementation(minSdk=30) protected boolean areAllPrimitivesSupported(int... primitiveIds)
-
setSupportedPrimitives
public void setSupportedPrimitives(Collection<Integer> primitives)
Adds supported vibration primitives.
-
getVibrationAttributesFromLastVibration
@Nullable public VibrationAttributes getVibrationAttributesFromLastVibration()
Returns theVibrationAttributes
from the last vibration.
-
-