You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bo...@apache.org on 2014/09/16 17:46:41 UTC
git commit: CB-7538 Android beep thread fix Beep now executes in it's
own thread. It was previously executing in the main UI thread which was
causing the application to lock up will the beep was occurring. Closing pull
request
Repository: cordova-plugin-dialogs
Updated Branches:
refs/heads/master c88acd6ae -> cc73124af
CB-7538 Android beep thread fix Beep now executes in it's own thread. It
was previously executing in the main UI thread which was causing the
application to lock up will the beep was occurring. Closing pull
request
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/commit/cc73124a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/tree/cc73124a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/diff/cc73124a
Branch: refs/heads/master
Commit: cc73124af6ab694e5b9f3ac3401664d287ae08a6
Parents: c88acd6
Author: David Peacock <da...@gmail.com>
Authored: Fri Sep 12 14:52:01 2014 -0400
Committer: Joe Bowser <bo...@apache.org>
Committed: Tue Sep 16 08:46:34 2014 -0700
----------------------------------------------------------------------
src/android/Notification.java | 32 ++++++++++++++++++--------------
1 file changed, 18 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/cc73124a/src/android/Notification.java
----------------------------------------------------------------------
diff --git a/src/android/Notification.java b/src/android/Notification.java
index 2ca5156..1b05dba 100755
--- a/src/android/Notification.java
+++ b/src/android/Notification.java
@@ -120,24 +120,28 @@ public class Notification extends CordovaPlugin {
*
* @param count Number of times to play notification
*/
- public void beep(long count) {
- Uri ringtone = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
- Ringtone notification = RingtoneManager.getRingtone(this.cordova.getActivity().getBaseContext(), ringtone);
+ public void beep(final long count) {
+ cordova.getThreadPool().execute(new Runnable() {
+ public void run() {
+ Uri ringtone = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
+ Ringtone notification = RingtoneManager.getRingtone(cordova.getActivity().getBaseContext(), ringtone);
- // If phone is not set to silent mode
- if (notification != null) {
- for (long i = 0; i < count; ++i) {
- notification.play();
- long timeout = 5000;
- while (notification.isPlaying() && (timeout > 0)) {
- timeout = timeout - 100;
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
+ // If phone is not set to silent mode
+ if (notification != null) {
+ for (long i = 0; i < count; ++i) {
+ notification.play();
+ long timeout = 5000;
+ while (notification.isPlaying() && (timeout > 0)) {
+ timeout = timeout - 100;
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ }
+ }
}
}
}
- }
+ });
}
/**