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
7c5eefd0
Commit
7c5eefd0
authored
Jan 12, 2015
by
PKnittel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restructured LocalNotification.java
parent
1694a815
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
112 additions
and
57 deletions
+112
-57
LocalNotification.java
src/android/LocalNotification.java
+112
-57
No files found.
src/android/LocalNotification.java
View file @
7c5eefd0
...
...
@@ -81,18 +81,7 @@ public class LocalNotification extends CordovaPlugin {
if
(
action
.
equalsIgnoreCase
(
"add"
))
{
cordova
.
getThreadPool
().
execute
(
new
Runnable
()
{
public
void
run
()
{
JSONArray
notifications
=
args
.
optJSONArray
(
0
);
JSONObject
arguments
;
for
(
int
i
=
0
;
i
<
notifications
.
length
();
i
++){
arguments
=
notifications
.
optJSONObject
(
i
);
LOG
.
d
(
"LocalNotification"
,
arguments
.
toString
());
arguments
=
asset
.
parseURIs
(
arguments
);
Options
options
=
new
Options
(
context
).
parse
(
arguments
);
options
.
setInitDate
();
nWrapper
.
schedule
(
options
);
JSONArray
data
=
new
JSONArray
().
put
(
options
.
getJSONObject
());
fireEvent
(
"add"
,
options
.
getId
(),
options
.
getJSON
(),
data
);
}
add
(
args
);
command
.
success
();
}
});
...
...
@@ -101,13 +90,7 @@ public class LocalNotification extends CordovaPlugin {
if
(
action
.
equalsIgnoreCase
(
"update"
))
{
cordova
.
getThreadPool
().
execute
(
new
Runnable
()
{
public
void
run
()
{
JSONArray
updates
=
args
.
optJSONArray
(
0
);
JSONObject
updateContent
;
for
(
int
i
=
0
;
i
<
updates
.
length
();
i
++){
updateContent
=
args
.
optJSONObject
(
i
);
nWrapper
.
update
(
updateContent
);
}
update
(
args
);
command
.
success
();
}
});
...
...
@@ -116,15 +99,7 @@ public class LocalNotification extends CordovaPlugin {
if
(
action
.
equalsIgnoreCase
(
"cancel"
))
{
cordova
.
getThreadPool
().
execute
(
new
Runnable
()
{
public
void
run
()
{
JSONArray
ids
=
args
.
optJSONArray
(
0
);
String
id
;
for
(
int
i
=
0
;
i
<
ids
.
length
();
i
++){
id
=
args
.
optString
(
i
);
nWrapper
.
cancel
(
id
);
JSONArray
managerId
=
new
JSONArray
().
put
(
id
);
JSONArray
data
=
new
JSONArray
().
put
(
manager
.
getAll
(
managerId
));
fireEvent
(
"cancel"
,
id
,
""
,
data
);
}
cancel
(
args
);
command
.
success
();
}
...
...
@@ -134,16 +109,7 @@ public class LocalNotification extends CordovaPlugin {
if
(
action
.
equalsIgnoreCase
(
"cancelAll"
))
{
cordova
.
getThreadPool
().
execute
(
new
Runnable
()
{
public
void
run
()
{
JSONArray
options
=
manager
.
getAll
();
nWrapper
.
cancelAll
();
String
id
;
JSONObject
arguments
;
for
(
int
i
=
0
;
i
<
options
.
length
();
i
++){
arguments
=
(
JSONObject
)
options
.
opt
(
i
);
JSONArray
data
=
new
JSONArray
().
put
(
arguments
);
id
=
arguments
.
optString
(
"id"
);
fireEvent
(
"cancel"
,
id
,
""
,
data
);
}
cancelAll
(
args
);
command
.
success
();
}
});
...
...
@@ -152,15 +118,7 @@ public class LocalNotification extends CordovaPlugin {
if
(
action
.
equalsIgnoreCase
(
"clear"
))
{
cordova
.
getThreadPool
().
execute
(
new
Runnable
()
{
public
void
run
()
{
JSONArray
ids
=
args
.
optJSONArray
(
0
);
String
id
;
for
(
int
i
=
0
;
i
<
ids
.
length
();
i
++){
id
=
args
.
optString
(
i
);
nWrapper
.
clear
(
id
);
JSONArray
managerId
=
new
JSONArray
().
put
(
id
);
JSONArray
data
=
new
JSONArray
().
put
(
manager
.
getAll
(
managerId
));
fireEvent
(
"clear"
,
id
,
""
,
data
);
}
clear
(
args
);
command
.
success
();
}
});
...
...
@@ -169,16 +127,7 @@ public class LocalNotification extends CordovaPlugin {
if
(
action
.
equalsIgnoreCase
(
"clearAll"
))
{
cordova
.
getThreadPool
().
execute
(
new
Runnable
()
{
public
void
run
()
{
JSONArray
options
=
manager
.
getAll
();
nWrapper
.
clearAll
();
String
id
;
JSONObject
arguments
;
for
(
int
i
=
0
;
i
<
options
.
length
();
i
++){
arguments
=
(
JSONObject
)
options
.
opt
(
i
);
JSONArray
data
=
new
JSONArray
().
put
(
arguments
);
id
=
arguments
.
optString
(
"id"
);
fireEvent
(
"clear"
,
id
,
""
,
data
);
}
clearAll
(
args
);
command
.
success
();
}
});
...
...
@@ -275,6 +224,112 @@ public class LocalNotification extends CordovaPlugin {
return
true
;
}
//------------------------------------------------exec-Functions-----------------------------------------------
/**
* Schedule notifications contained in the args-Array
* @param args
*/
private
void
add
(
JSONArray
args
){
JSONArray
notifications
=
args
.
optJSONArray
(
0
);
JSONObject
arguments
;
for
(
int
i
=
0
;
i
<
notifications
.
length
();
i
++){
arguments
=
notifications
.
optJSONObject
(
i
);
LOG
.
d
(
"LocalNotification"
,
arguments
.
toString
());
arguments
=
asset
.
parseURIs
(
arguments
);
Options
options
=
new
Options
(
context
).
parse
(
arguments
);
options
.
setInitDate
();
nWrapper
.
schedule
(
options
);
JSONArray
data
=
new
JSONArray
().
put
(
options
.
getJSONObject
());
fireEvent
(
"add"
,
options
.
getId
(),
options
.
getJSON
(),
data
);
}
}
/**
* Update existing notifications
* @param args
*/
private
void
update
(
JSONArray
args
){
JSONArray
updates
=
args
.
optJSONArray
(
0
);
JSONObject
updateContent
;
for
(
int
i
=
0
;
i
<
updates
.
length
();
i
++){
updateContent
=
args
.
optJSONObject
(
i
);
nWrapper
.
update
(
updateContent
);
}
}
/**
* Cancel scheduled Notifications
* @param args
*/
private
void
cancel
(
JSONArray
args
){
JSONArray
ids
=
args
.
optJSONArray
(
0
);
String
id
;
for
(
int
i
=
0
;
i
<
ids
.
length
();
i
++){
id
=
args
.
optString
(
i
);
nWrapper
.
cancel
(
id
);
JSONArray
managerId
=
new
JSONArray
().
put
(
id
);
JSONArray
data
=
new
JSONArray
().
put
(
manager
.
getAll
(
managerId
));
fireEvent
(
"cancel"
,
id
,
""
,
data
);
}
}
/**
* Cancel all scheduled notifications
* @param args
*/
public
void
cancelAll
(
JSONArray
args
){
JSONArray
options
=
manager
.
getAll
();
nWrapper
.
cancelAll
();
String
id
;
JSONObject
arguments
;
for
(
int
i
=
0
;
i
<
options
.
length
();
i
++){
arguments
=
(
JSONObject
)
options
.
opt
(
i
);
JSONArray
data
=
new
JSONArray
().
put
(
arguments
);
id
=
arguments
.
optString
(
"id"
);
fireEvent
(
"cancel"
,
id
,
""
,
data
);
}
}
/**
* Clear triggered notifications without cancel repeating.
* @param args
*/
public
void
clear
(
JSONArray
args
){
JSONArray
ids
=
args
.
optJSONArray
(
0
);
String
id
;
for
(
int
i
=
0
;
i
<
ids
.
length
();
i
++){
id
=
args
.
optString
(
i
);
nWrapper
.
clear
(
id
);
JSONArray
managerId
=
new
JSONArray
().
put
(
id
);
JSONArray
data
=
new
JSONArray
().
put
(
manager
.
getAll
(
managerId
));
fireEvent
(
"clear"
,
id
,
""
,
data
);
}
}
/**
* Clear all triggered notifications without cancel repeating.
* @param args
*/
public
void
clearAll
(
JSONArray
args
){
JSONArray
options
=
manager
.
getAll
();
nWrapper
.
clearAll
();
String
id
;
JSONObject
arguments
;
for
(
int
i
=
0
;
i
<
options
.
length
();
i
++){
arguments
=
(
JSONObject
)
options
.
opt
(
i
);
JSONArray
data
=
new
JSONArray
().
put
(
arguments
);
id
=
arguments
.
optString
(
"id"
);
fireEvent
(
"clear"
,
id
,
""
,
data
);
}
}
//-------------------------------------------------------------------------------------------------------------
/**
* Calls all pending callbacks after the deviceready event has been fired.
*/
...
...
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