@iternio/react-native-auto-play 0.3.5 → 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,6 +9,7 @@ import androidx.lifecycle.Lifecycle
9
9
  import androidx.lifecycle.LifecycleEventObserver
10
10
  import androidx.lifecycle.LifecycleOwner
11
11
  import com.facebook.react.bridge.UiThreadUtil
12
+ import java.util.concurrent.ConcurrentHashMap
12
13
  import com.margelo.nitro.swe.iternio.reactnativeautoplay.template.AndroidAutoTemplate
13
14
  import com.margelo.nitro.swe.iternio.reactnativeautoplay.template.GridTemplate
14
15
  import com.margelo.nitro.swe.iternio.reactnativeautoplay.template.InformationTemplate
@@ -117,15 +118,18 @@ class AndroidAutoScreen(
117
118
  companion object {
118
119
  const val TAG = "AndroidAutoScreen"
119
120
 
120
- private val screens = mutableMapOf<String, AndroidAutoScreen>()
121
+ private val screens = ConcurrentHashMap<String, AndroidAutoScreen>()
121
122
 
122
123
  fun getScreen(marker: String): AndroidAutoScreen? {
123
124
  return screens[marker]
124
125
  }
125
126
 
126
127
  fun getScreenManager(): ScreenManager? {
127
- return screens[AndroidAutoSession.ROOT_SESSION]?.screenManager
128
- }
128
+ val clusterSessions = AndroidAutoSession.getClusterSessions().toSet()
129
+ return screens.entries
130
+ .firstOrNull { !clusterSessions.contains(it.key) }
131
+ ?.value?.screenManager
132
+ }
129
133
 
130
134
  fun invalidateScreens() {
131
135
  for (screen in screens) {
@@ -143,4 +147,4 @@ class AndroidAutoScreen(
143
147
  }
144
148
  }
145
149
  }
146
- }
150
+ }
@@ -23,6 +23,8 @@ import kotlinx.coroutines.CoroutineScope
23
23
  import kotlinx.coroutines.Dispatchers
24
24
  import kotlinx.coroutines.launch
25
25
  import java.util.UUID
26
+ import java.util.concurrent.ConcurrentHashMap
27
+ import java.util.concurrent.CopyOnWriteArrayList
26
28
 
27
29
  class AndroidAutoSession(sessionInfo: SessionInfo, private val reactApplication: ReactApplication) :
28
30
  Session() {
@@ -246,9 +248,9 @@ class AndroidAutoSession(sessionInfo: SessionInfo, private val reactApplication:
246
248
  const val ROOT_SESSION = "AutoPlayRoot"
247
249
 
248
250
  private lateinit var reactContext: ReactContext
249
- private val sessions = mutableMapOf<String, ScreenContext>()
251
+ private val sessions = ConcurrentHashMap<String, ScreenContext>()
250
252
 
251
- private val clusterSessions = mutableListOf<String>()
253
+ private val clusterSessions = CopyOnWriteArrayList<String>()
252
254
 
253
255
  fun getIsConnected(): Boolean {
254
256
  return sessions.containsKey(ROOT_SESSION)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iternio/react-native-auto-play",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "description": "Android Auto and Apple CarPlay for react-native",
5
5
  "main": "lib/index",
6
6
  "module": "lib/index",