diff --git a/android/src/main/java/io/ably/flutter/plugin/AblyEventStreamHandler.java b/android/src/main/java/io/ably/flutter/plugin/AblyEventStreamHandler.java index 3cda15a63..87c57f1c4 100644 --- a/android/src/main/java/io/ably/flutter/plugin/AblyEventStreamHandler.java +++ b/android/src/main/java/io/ably/flutter/plugin/AblyEventStreamHandler.java @@ -97,9 +97,9 @@ private AblyFlutterMessage> getMessage(Object message){ @Override public void onListen(Object object, EventChannel.EventSink uiThreadEventSink) { MainThreadEventSink eventSink = new MainThreadEventSink(uiThreadEventSink); - AblyFlutterMessage> ablyMessage = getMessage(object); - AblyEventMessage eventMessage = ablyMessage.message; - String eventName = eventMessage.eventName; + final AblyFlutterMessage> ablyMessage = getMessage(object); + final AblyEventMessage eventMessage = ablyMessage.message; + final String eventName = eventMessage.eventName; try { switch (eventName) { case PlatformConstants.PlatformMethod.onRealtimeConnectionStateChanged: @@ -108,11 +108,11 @@ public void onListen(Object object, EventChannel.EventSink uiThreadEventSink) { break; case PlatformConstants.PlatformMethod.onRealtimeChannelStateChanged: assert eventMessage.message!=null : "event message is missing"; - Map eventPayload = (Map) eventMessage.message; - String channelName = (String) eventPayload.get("channel"); - ChannelOptions channelOptions = (ChannelOptions) eventPayload.get("options"); + final Map eventPayload = (Map) eventMessage.message; + final String channelName = (String) eventPayload.get("channel"); + final ChannelOptions channelOptions = (ChannelOptions) eventPayload.get("options"); try { - Channel channel = ablyLibrary.getRealtime(ablyMessage.handle).channels.get(channelName, channelOptions); + final Channel channel = ablyLibrary.getRealtime(ablyMessage.handle).channels.get(channelName, channelOptions); channelStateListener = new PluginChannelStateListener(eventSink); channel.on(channelStateListener); } catch (AblyException ablyException) { @@ -133,9 +133,9 @@ public void onCancel(Object object) { System.out.println("Cannot process null input on cancel"); return; } - AblyFlutterMessage> ablyMessage = getMessage(object); - AblyEventMessage eventMessage = ablyMessage.message; - String eventName = eventMessage.eventName; + final AblyFlutterMessage> ablyMessage = getMessage(object); + final AblyEventMessage eventMessage = ablyMessage.message; + final String eventName = eventMessage.eventName; switch (eventName) { case PlatformConstants.PlatformMethod.onRealtimeConnectionStateChanged: ablyLibrary.getRealtime(ablyMessage.handle).connection.off(connectionStateListener); @@ -144,8 +144,8 @@ public void onCancel(Object object) { // Note: this and all other assert statements in this onCancel method are // left as is as there is no way of propagating this error to flutter side assert eventMessage.message!=null : "event message is missing"; - Map eventPayload = (Map) eventMessage.message; - String channelName = (String) eventPayload.get("channel"); + final Map eventPayload = (Map) eventMessage.message; + final String channelName = (String) eventPayload.get("channel"); ablyLibrary.getRealtime(ablyMessage.handle).channels.get(channelName).off(channelStateListener); break; }