Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

[RN] Add JitsiMeetViewAbstractListener to Android SDK

Saúl Ibarra Corretgéa266a7199973
diff --git a/android/README.md b/android/README.md
index b66d78804e..bf2c9989a1 100644
--- a/android/README.md
+++ b/android/README.md
@@ -180,3 +180,10 @@ The `data` HashMap contains a "url" key with the conference URL.
Called before a conference is left.
The `data` HashMap contains a "url" key with the conference URL.
+
+### JitsiMeetViewAbstractListener
+
+Utility (abstract) class with stub methods for the `JitsiMeetView.Listener`
+interface. Applications can innherit from this class instead of implementing
+the interface in order to avoid adding stubs for methods they don't care about.
+
diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetViewAbstractListener.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetViewAbstractListener.java
new file mode 100644
index 0000000000..0fdb42c641
--- /dev/null
+++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetViewAbstractListener.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright @ 2017-present Atlassian Pty Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jitsi.meet.sdk;
+
+import java.util.HashMap;
+
+/**
+ * This class provides a reference implementation for {@JitsiMeetView.Listener} so applications
+ * don't need to add stubs for all methods in the interface if they are only interested in some.
+ */
+public abstract class JitsiMeetViewAbstractListener implements JitsiMeetView.Listener {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onConferenceFailed(HashMap<String, Object> data) {
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onConferenceJoined(HashMap<String, Object> data) {
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onConferenceLeft(HashMap<String, Object> data) {
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onConferenceWillJoin(HashMap<String, Object> data) {
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onConferenceWillLeave(HashMap<String, Object> data) {
+
+ }
+}
diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/externalapi/ExternalAPIModule.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/externalapi/ExternalAPIModule.java
index 9e400e8259..6cd727da92 100644
--- a/android/sdk/src/main/java/org/jitsi/meet/sdk/externalapi/ExternalAPIModule.java
+++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/externalapi/ExternalAPIModule.java
@@ -78,32 +78,28 @@ public class ExternalAPIModule extends ReactContextBaseJavaModule {
// until React Native 0.46.
final HashMap<String, Object> dataMap = new HashMap<>();
- try {
- switch (name) {
- case "CONFERENCE_FAILED":
- dataMap.put("error", data.getString("error"));
- dataMap.put("url", data.getString("url"));
- listener.onConferenceFailed(dataMap);
- break;
- case "CONFERENCE_JOINED":
- dataMap.put("url", data.getString("url"));
- listener.onConferenceJoined(dataMap);
- break;
- case "CONFERENCE_LEFT":
- dataMap.put("url", data.getString("url"));
- listener.onConferenceLeft(dataMap);
- break;
- case "CONFERENCE_WILL_JOIN":
- dataMap.put("url", data.getString("url"));
- listener.onConferenceWillJoin(dataMap);
- break;
- case "CONFERENCE_WILL_LEAVE":
- dataMap.put("url", data.getString("url"));
- listener.onConferenceWillLeave(dataMap);
- break;
- }
- } catch (UnsupportedOperationException e) {
- // Allow partial interface implementations.
+ switch (name) {
+ case "CONFERENCE_FAILED":
+ dataMap.put("error", data.getString("error"));
+ dataMap.put("url", data.getString("url"));
+ listener.onConferenceFailed(dataMap);
+ break;
+ case "CONFERENCE_JOINED":
+ dataMap.put("url", data.getString("url"));
+ listener.onConferenceJoined(dataMap);
+ break;
+ case "CONFERENCE_LEFT":
+ dataMap.put("url", data.getString("url"));
+ listener.onConferenceLeft(dataMap);
+ break;
+ case "CONFERENCE_WILL_JOIN":
+ dataMap.put("url", data.getString("url"));
+ listener.onConferenceWillJoin(dataMap);
+ break;
+ case "CONFERENCE_WILL_LEAVE":
+ dataMap.put("url", data.getString("url"));
+ listener.onConferenceWillLeave(dataMap);
+ break;
}
}
}