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
ced7c19a
Commit
ced7c19a
authored
Nov 07, 2017
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reference webView as weak
parent
6c919c8d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
8 deletions
+12
-8
LocalNotification.java
src/android/LocalNotification.java
+12
-8
No files found.
src/android/LocalNotification.java
View file @
ced7c19a
...
@@ -59,7 +59,7 @@ import static de.appplant.cordova.plugin.notification.Notification.Type.TRIGGERE
...
@@ -59,7 +59,7 @@ import static de.appplant.cordova.plugin.notification.Notification.Type.TRIGGERE
public
class
LocalNotification
extends
CordovaPlugin
{
public
class
LocalNotification
extends
CordovaPlugin
{
// Reference to the web view for static access
// Reference to the web view for static access
private
static
CordovaWebView
webView
=
null
;
private
static
WeakReference
<
CordovaWebView
>
webView
=
null
;
// Indicates if the device is ready (to receive events)
// Indicates if the device is ready (to receive events)
private
static
Boolean
deviceready
=
false
;
private
static
Boolean
deviceready
=
false
;
...
@@ -77,7 +77,7 @@ public class LocalNotification extends CordovaPlugin {
...
@@ -77,7 +77,7 @@ public class LocalNotification extends CordovaPlugin {
*/
*/
@Override
@Override
public
void
initialize
(
CordovaInterface
cordova
,
CordovaWebView
webView
)
{
public
void
initialize
(
CordovaInterface
cordova
,
CordovaWebView
webView
)
{
LocalNotification
.
webView
=
super
.
webView
;
LocalNotification
.
webView
=
new
WeakReference
<
CordovaWebView
>(
webView
)
;
}
}
/**
/**
...
@@ -547,14 +547,16 @@ public class LocalNotification extends CordovaPlugin {
...
@@ -547,14 +547,16 @@ public class LocalNotification extends CordovaPlugin {
*/
*/
private
static
synchronized
void
sendJavascript
(
final
String
js
)
{
private
static
synchronized
void
sendJavascript
(
final
String
js
)
{
if
(!
deviceready
)
{
if
(!
deviceready
||
webView
==
null
)
{
eventQueue
.
add
(
js
);
eventQueue
.
add
(
js
);
return
;
return
;
}
}
((
Activity
)(
webView
.
getContext
())).
runOnUiThread
(
new
Runnable
()
{
final
CordovaWebView
view
=
webView
.
get
();
((
Activity
)(
view
.
getContext
())).
runOnUiThread
(
new
Runnable
()
{
public
void
run
()
{
public
void
run
()
{
webV
iew
.
loadUrl
(
"javascript:"
+
js
);
v
iew
.
loadUrl
(
"javascript:"
+
js
);
}
}
});
});
}
}
...
@@ -564,17 +566,19 @@ public class LocalNotification extends CordovaPlugin {
...
@@ -564,17 +566,19 @@ public class LocalNotification extends CordovaPlugin {
*/
*/
private
static
boolean
isInForeground
()
{
private
static
boolean
isInForeground
()
{
if
(!
deviceready
)
if
(!
deviceready
||
webView
==
null
)
return
false
;
return
false
;
KeyguardManager
km
=
(
KeyguardManager
)
webView
.
getContext
()
CordovaWebView
view
=
webView
.
get
();
KeyguardManager
km
=
(
KeyguardManager
)
view
.
getContext
()
.
getSystemService
(
Context
.
KEYGUARD_SERVICE
);
.
getSystemService
(
Context
.
KEYGUARD_SERVICE
);
//noinspection SimplifiableIfStatement
//noinspection SimplifiableIfStatement
if
(
km
.
isKeyguardLocked
())
if
(
km
.
isKeyguardLocked
())
return
false
;
return
false
;
return
webV
iew
.
getView
().
getWindowVisibility
()
==
View
.
VISIBLE
;
return
v
iew
.
getView
().
getWindowVisibility
()
==
View
.
VISIBLE
;
}
}
/**
/**
...
...
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