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
3b624527
Commit
3b624527
authored
Mar 16, 2014
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add method implementation for `deviceready` for Android
parent
7e47b387
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
22 deletions
+30
-22
LocalNotification.java
src/android/LocalNotification.java
+30
-22
No files found.
src/android/LocalNotification.java
View file @
3b624527
...
...
@@ -51,12 +51,13 @@ import android.content.SharedPreferences.Editor;
*/
public
class
LocalNotification
extends
CordovaPlugin
{
protected
final
static
String
PLUGIN_NAME
=
"LocalNotification"
;
protected
final
static
String
PLUGIN_NAME
=
"LocalNotification"
;
private
static
CordovaWebView
webView
=
null
;
protected
static
Context
context
=
null
;
private
static
CordovaWebView
webView
=
null
;
private
static
Boolean
deviceready
=
false
;
protected
static
Context
context
=
null
;
private
static
ArrayList
<
String
>
callback
Queue
=
new
ArrayList
<
String
>();
private
static
ArrayList
<
String
>
event
Queue
=
new
ArrayList
<
String
>();
@Override
public
void
initialize
(
CordovaInterface
cordova
,
CordovaWebView
webView
)
{
...
...
@@ -64,8 +65,6 @@ public class LocalNotification extends CordovaPlugin {
LocalNotification
.
webView
=
super
.
webView
;
LocalNotification
.
context
=
super
.
cordova
.
getActivity
().
getApplicationContext
();
execPendingCallbacks
();
}
@Override
...
...
@@ -122,11 +121,34 @@ public class LocalNotification extends CordovaPlugin {
return
true
;
}
if
(
action
.
equalsIgnoreCase
(
"deviceready"
))
{
cordova
.
getThreadPool
().
execute
(
new
Runnable
()
{
public
void
run
()
{
deviceready
();
}
});
return
true
;
}
// Returning false results in a "MethodNotFound" error.
return
false
;
}
/**
* Calls all pending callbacks after the deviceready event has been fired.
*/
private
static
void
deviceready
()
{
deviceready
=
true
;
for
(
String
js
:
eventQueue
)
{
webView
.
sendJavascript
(
js
);
}
eventQueue
.
clear
();
}
/**
* Set an alarm.
*
* @param options
...
...
@@ -288,10 +310,8 @@ public class LocalNotification extends CordovaPlugin {
String
params
=
"\""
+
id
+
"\",\""
+
state
+
"\",\\'"
+
JSONObject
.
quote
(
json
)
+
"\\'.replace(/(^\"|\"$)/g, \\'\\')"
;
String
js
=
"setTimeout('plugin.notification.local.on"
+
event
+
"("
+
params
+
")',0)"
;
// after reboot, LocalNotification.webView is always be null
// call background callback later
if
(
webView
==
null
)
{
callbackQueue
.
add
(
js
);
if
(
deviceready
==
false
)
{
eventQueue
.
add
(
js
);
}
else
{
webView
.
sendJavascript
(
js
);
}
...
...
@@ -337,15 +357,4 @@ public class LocalNotification extends CordovaPlugin {
return
true
;
}
}
/**
* Calls all pending callbacks after the webview was created.
*/
private
void
execPendingCallbacks
()
{
for
(
String
js
:
callbackQueue
)
{
webView
.
sendJavascript
(
js
);
}
callbackQueue
.
clear
();
}
}
\ No newline at end of file
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