You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ld...@apache.org on 2014/08/07 18:58:43 UTC

[03/12] git commit: changes to how 0 is getting added to array in order to align with w3c spec

changes to how 0 is getting added to array in order to align with w3c spec


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/commit/07f5c903
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/tree/07f5c903
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/diff/07f5c903

Branch: refs/heads/master
Commit: 07f5c9037104b13a4f2aab14588fb123e27f9e9a
Parents: 1d0afd7
Author: Edna Morales <ed...@Ednas-MacBook-Pro-2.local>
Authored: Tue Jul 22 12:37:34 2014 -0400
Committer: Edna Morales <ed...@Ednas-MacBook-Pro-2.local>
Committed: Tue Jul 22 12:37:34 2014 -0400

----------------------------------------------------------------------
 src/android/Vibration.java | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/07f5c903/src/android/Vibration.java
----------------------------------------------------------------------
diff --git a/src/android/Vibration.java b/src/android/Vibration.java
index b412f9a..d557976 100755
--- a/src/android/Vibration.java
+++ b/src/android/Vibration.java
@@ -51,9 +51,11 @@ public class Vibration extends CordovaPlugin {
         else if (action.equals("vibrateWithPattern")) {
             JSONArray pattern = args.getJSONArray(0);
             int repeat = args.getInt(1);
-            long[] patternArray = new long[pattern.length()];
+            //add a 0 at the beginning of pattern to align with w3c
+            long[] patternArray = new long[pattern.length()+1];
+            patternArray[0] = 0;
             for (int i = 0; i < pattern.length(); i++) {
-                patternArray[i] = pattern.getLong(i);
+                patternArray[i+1] = pattern.getLong(i);
             }
             this.vibrateWithPattern(patternArray, repeat);
         }
@@ -111,13 +113,7 @@ public class Vibration extends CordovaPlugin {
      */
     public void vibrateWithPattern(long[] pattern, int repeat) {
         Vibrator vibrator = (Vibrator) this.cordova.getActivity().getSystemService(Context.VIBRATOR_SERVICE);
-        
-        //add 0 at beginning of pattern to align with w3c spec
-        long[] newPattern = new long[pattern.length+1];
-        newPattern[0] = 0;
-        System.arraycopy(pattern, 0, newPattern, 1, pattern.length);
-        
-        vibrator.vibrate(newPattern, repeat);
+        vibrator.vibrate(pattern, repeat);
     }
 
     /**