Browse Source

[RN] Add JitsiMeetViewAbstractListener to Android SDK

j8
Saúl Ibarra Corretgé 8 years ago
parent
commit
a266a71999

+ 7
- 0
android/README.md View File

180
 Called before a conference is left.
180
 Called before a conference is left.
181
 
181
 
182
 The `data` HashMap contains a "url" key with the conference URL.
182
 The `data` HashMap contains a "url" key with the conference URL.
183
+
184
+### JitsiMeetViewAbstractListener
185
+
186
+Utility (abstract) class with stub methods for the `JitsiMeetView.Listener`
187
+interface. Applications can innherit from this class instead of implementing
188
+the interface in order to avoid adding stubs for methods they don't care about.
189
+

+ 66
- 0
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetViewAbstractListener.java View File

1
+/*
2
+ * Copyright @ 2017-present Atlassian Pty Ltd
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ *     http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+package org.jitsi.meet.sdk;
18
+
19
+import java.util.HashMap;
20
+
21
+/**
22
+ * This class provides a reference implementation for {@JitsiMeetView.Listener} so applications
23
+ * don't need to add stubs for all methods in the interface if they are only interested in some.
24
+ */
25
+public abstract class JitsiMeetViewAbstractListener implements JitsiMeetView.Listener {
26
+
27
+    /**
28
+     * {@inheritDoc}
29
+     */
30
+    @Override
31
+    public void onConferenceFailed(HashMap<String, Object> data) {
32
+
33
+    }
34
+
35
+    /**
36
+     * {@inheritDoc}
37
+     */
38
+    @Override
39
+    public void onConferenceJoined(HashMap<String, Object> data) {
40
+
41
+    }
42
+
43
+    /**
44
+     * {@inheritDoc}
45
+     */
46
+    @Override
47
+    public void onConferenceLeft(HashMap<String, Object> data) {
48
+
49
+    }
50
+
51
+    /**
52
+     * {@inheritDoc}
53
+     */
54
+    @Override
55
+    public void onConferenceWillJoin(HashMap<String, Object> data) {
56
+
57
+    }
58
+
59
+    /**
60
+     * {@inheritDoc}
61
+     */
62
+    @Override
63
+    public void onConferenceWillLeave(HashMap<String, Object> data) {
64
+
65
+    }
66
+}

+ 22
- 26
android/sdk/src/main/java/org/jitsi/meet/sdk/externalapi/ExternalAPIModule.java View File

78
         // until React Native 0.46.
78
         // until React Native 0.46.
79
         final HashMap<String, Object> dataMap = new HashMap<>();
79
         final HashMap<String, Object> dataMap = new HashMap<>();
80
 
80
 
81
-        try {
82
-            switch (name) {
83
-            case "CONFERENCE_FAILED":
84
-                dataMap.put("error", data.getString("error"));
85
-                dataMap.put("url", data.getString("url"));
86
-                listener.onConferenceFailed(dataMap);
87
-                break;
88
-            case "CONFERENCE_JOINED":
89
-                dataMap.put("url", data.getString("url"));
90
-                listener.onConferenceJoined(dataMap);
91
-                break;
92
-            case "CONFERENCE_LEFT":
93
-                dataMap.put("url", data.getString("url"));
94
-                listener.onConferenceLeft(dataMap);
95
-                break;
96
-            case "CONFERENCE_WILL_JOIN":
97
-                dataMap.put("url", data.getString("url"));
98
-                listener.onConferenceWillJoin(dataMap);
99
-                break;
100
-            case "CONFERENCE_WILL_LEAVE":
101
-                dataMap.put("url", data.getString("url"));
102
-                listener.onConferenceWillLeave(dataMap);
103
-                break;
104
-            }
105
-        } catch (UnsupportedOperationException e) {
106
-            // Allow partial interface implementations.
81
+        switch (name) {
82
+        case "CONFERENCE_FAILED":
83
+            dataMap.put("error", data.getString("error"));
84
+            dataMap.put("url", data.getString("url"));
85
+            listener.onConferenceFailed(dataMap);
86
+            break;
87
+        case "CONFERENCE_JOINED":
88
+            dataMap.put("url", data.getString("url"));
89
+            listener.onConferenceJoined(dataMap);
90
+            break;
91
+        case "CONFERENCE_LEFT":
92
+            dataMap.put("url", data.getString("url"));
93
+            listener.onConferenceLeft(dataMap);
94
+            break;
95
+        case "CONFERENCE_WILL_JOIN":
96
+            dataMap.put("url", data.getString("url"));
97
+            listener.onConferenceWillJoin(dataMap);
98
+            break;
99
+        case "CONFERENCE_WILL_LEAVE":
100
+            dataMap.put("url", data.getString("url"));
101
+            listener.onConferenceWillLeave(dataMap);
102
+            break;
107
         }
103
         }
108
     }
104
     }
109
 }
105
 }

Loading…
Cancel
Save