cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [5/8] cordova-plugin-vibration git commit: CB-7216 changed cancelWasCalled boolean
Date Mon, 18 May 2015 22:33:29 GMT
CB-7216 changed cancelWasCalled boolean

- changed variable name
- clear at the beginning of call to vibrateWithPattern


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/6612805e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/tree/6612805e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/diff/6612805e

Branch: refs/heads/master
Commit: 6612805e61dba39ea638c6801ff4e11163fa0d70
Parents: 463dbfa
Author: Staci Cooper <smcooper@us.ibm.com>
Authored: Thu Aug 28 13:42:06 2014 -0400
Committer: Staci Cooper <smcooper@us.ibm.com>
Committed: Thu Aug 28 13:42:06 2014 -0400

----------------------------------------------------------------------
 src/wp/Vibration.cs | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration/blob/6612805e/src/wp/Vibration.cs
----------------------------------------------------------------------
diff --git a/src/wp/Vibration.cs b/src/wp/Vibration.cs
index 52f996a..14b53b7 100644
--- a/src/wp/Vibration.cs
+++ b/src/wp/Vibration.cs
@@ -28,8 +28,8 @@ namespace WPCordovaClassLib.Cordova.Commands
 {
     public class Vibration : BaseCommand
     {
-        // bool used by vibrateWithPattern to stop when Cancel is pressed
-        private bool cancelPattern = false;
+        // bool used to determine if cancel was called during vibrateWithPattern
+        private bool cancelWasCalled = false;
 
         public void vibrate(string vibrateDuration)
         {
@@ -63,13 +63,19 @@ namespace WPCordovaClassLib.Cordova.Commands
 
         public async Task vibrateWithPattern(string options)
         {
+            // clear the cancelWasCalled flag
+            cancelWasCalled = false;
             // get options
             string[] args = JSON.JsonHelper.Deserialize<string[]>(options);
-            long[] pattern = JSON.JsonHelper.Deserialize<long[]>(args[0]);
+            int[] pattern = JSON.JsonHelper.Deserialize<int[]>(args[0]);
 
-            for (int i = 0; i < pattern.Length && !cancelPattern; i++)
+            for (int i = 0; i < pattern.Length && !cancelWasCalled; i++)
             {
-                long msecs = pattern[i];
+                int msecs = pattern[i];
+                if (msecs < 1)
+                {
+                    msecs = 1;
+                }
                 if (i % 2 == 0)
                 {
                     msecs = (msecs > 5000) ? 5000 : msecs;
@@ -77,14 +83,13 @@ namespace WPCordovaClassLib.Cordova.Commands
                 }
                 await Task.Delay(TimeSpan.FromMilliseconds(msecs));
             }
-            cancelPattern = false;
             DispatchCommandResult();
         }
 
         public void cancelVibration(string options)
         {
             VibrateController.Default.Stop();
-            cancelPattern = true;
+            cancelWasCalled = true;
             DispatchCommandResult();
         }
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message