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 authored and jcesarmobile committed Mar 5, 2020
1 parent cf2f746 commit 7decd0b
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
Original file line number Diff line number Diff line change
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 7decd0b

Please sign in to comment.