Skip to content

Commit

Permalink
fix(android): plugin retained events not being retained if listeners …
Browse files Browse the repository at this point in the history
…were empty (#2408)
  • Loading branch information
kofoeddk committed Feb 6, 2020
1 parent 8c9fe93 commit b817e83
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions android/capacitor/src/main/java/com/getcapacitor/Plugin.java
Expand Up @@ -300,7 +300,7 @@ public void pluginRequestPermission(String permission, int requestCode) {
*/
private void addEventListener(String eventName, PluginCall call) {
List<PluginCall> listeners = eventListeners.get(eventName);
if (listeners == null) {
if (listeners == null || listeners.isEmpty()) {
listeners = new ArrayList<PluginCall>();
eventListeners.put(eventName, listeners);

Expand Down Expand Up @@ -335,7 +335,7 @@ private void removeEventListener(String eventName, PluginCall call) {
protected void notifyListeners(String eventName, JSObject data, boolean retainUntilConsumed) {
Log.v(getLogTag(), "Notifying listeners for event " + eventName);
List<PluginCall> listeners = eventListeners.get(eventName);
if (listeners == null) {
if (listeners == null || listeners.isEmpty()) {
Log.d(getLogTag(), "No listeners found for event " + eventName);
if (retainUntilConsumed) {
retainedEventArguments.put(eventName, data);
Expand Down

0 comments on commit b817e83

Please sign in to comment.