Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cordova-plugin-local-notifications
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nabil Sadki
cordova-plugin-local-notifications
Commits
eb41d94f
Commit
eb41d94f
authored
Jan 31, 2018
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent endless trigger loop [fixes #1463]
parent
45b5d887
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
5 deletions
+27
-5
TriggerReceiver.java
src/android/TriggerReceiver.java
+12
-4
Request.java
src/android/notification/Request.java
+15
-1
No files found.
src/android/TriggerReceiver.java
View file @
eb41d94f
...
...
@@ -25,6 +25,8 @@ import android.content.Context;
import
android.os.Bundle
;
import
android.os.PowerManager
;
import
java.util.Calendar
;
import
de.appplant.cordova.plugin.notification.Builder
;
import
de.appplant.cordova.plugin.notification.Manager
;
import
de.appplant.cordova.plugin.notification.Notification
;
...
...
@@ -35,6 +37,7 @@ import de.appplant.cordova.plugin.notification.receiver.AbstractTriggerReceiver;
import
static
android
.
content
.
Context
.
POWER_SERVICE
;
import
static
android
.
os
.
Build
.
VERSION
.
SDK_INT
;
import
static
android
.
os
.
Build
.
VERSION_CODES
.
LOLLIPOP
;
import
static
java
.
util
.
Calendar
.
MINUTE
;
/**
* The alarm receiver is triggered when a scheduled alarm is fired. This class
...
...
@@ -69,13 +72,18 @@ public class TriggerReceiver extends AbstractTriggerReceiver {
notification
.
show
();
if
(
options
.
isInfiniteTrigger
())
{
manager
.
schedule
(
new
Request
(
options
),
this
.
getClass
());
}
if
(!
isUpdate
)
{
LocalNotification
.
fireEvent
(
"trigger"
,
notification
);
}
if
(!
options
.
isInfiniteTrigger
())
return
;
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
add
(
MINUTE
,
1
);
Request
req
=
new
Request
(
options
,
cal
.
getTime
());
manager
.
schedule
(
req
,
this
.
getClass
());
}
/**
...
...
src/android/notification/Request.java
View file @
eb41d94f
...
...
@@ -64,7 +64,7 @@ public final class Request {
private
Date
triggerDate
;
/**
* C
onstructor
* C
reate a request with a base date specified through the passed options.
*
* @param options The options spec.
*/
...
...
@@ -77,6 +77,20 @@ public final class Request {
}
/**
* Create a request with a base date specified via base argument.
*
* @param options The options spec.
* @param base The base date from where to calculate the next trigger.
*/
public
Request
(
Options
options
,
Date
base
)
{
this
.
options
=
options
;
this
.
spec
=
options
.
getTrigger
();
this
.
count
=
Math
.
max
(
spec
.
optInt
(
"count"
),
1
);
this
.
trigger
=
buildTrigger
();
this
.
triggerDate
=
trigger
.
getNextTriggerDate
(
base
);
}
/**
* Gets the options spec.
*/
public
Options
getOptions
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment