1 package com.xtremelabs.robolectric.shadows;
2 
3 import android.os.Vibrator;
4 
5 import com.xtremelabs.robolectric.internal.Implementation;
6 import com.xtremelabs.robolectric.internal.Implements;
7 
8 @Implements(Vibrator.class)
9 public class ShadowVibrator {
10     private boolean vibrating;
11     private boolean cancelled;
12     private long milliseconds;
13     private long[] pattern;
14     private int repeat;
15 
16     @Implementation
vibrate(long milliseconds)17     public void vibrate(long milliseconds) {
18         vibrating = true;
19         this.milliseconds = milliseconds;
20     }
21 
22     @Implementation
vibrate(long[] pattern, int repeat)23     public void vibrate(long[] pattern, int repeat) {
24         vibrating = true;
25         this.pattern = pattern;
26         this.repeat = repeat;
27     }
28 
29     @Implementation
cancel()30     public void cancel() {
31         cancelled = true;
32         vibrating = false;
33     }
34 
isVibrating()35     public boolean isVibrating() {
36         return vibrating;
37     }
38 
isCancelled()39     public boolean isCancelled() {
40         return cancelled;
41     }
42 
getMilliseconds()43     public long getMilliseconds() {
44         return milliseconds;
45     }
46 
getPattern()47     public long[] getPattern() {
48         return pattern;
49     }
50 
getRepeat()51     public int getRepeat() {
52         return repeat;
53     }
54 }