diff --git a/packages/react-native-hms/android/src/main/java/com/reactnativehmssdk/HMSHLSPlayerManager.kt b/packages/react-native-hms/android/src/main/java/com/reactnativehmssdk/HMSHLSPlayerManager.kt index 6248c4e4f..59efa505b 100644 --- a/packages/react-native-hms/android/src/main/java/com/reactnativehmssdk/HMSHLSPlayerManager.kt +++ b/packages/react-native-hms/android/src/main/java/com/reactnativehmssdk/HMSHLSPlayerManager.kt @@ -24,15 +24,18 @@ class HMSHLSPlayerManager : SimpleViewManager() { override fun getExportedCustomDirectEventTypeConstants(): MutableMap? { super.getExportedCustomDirectEventTypeConstants() - return MapBuilder.of( - HMSHLSPlayerConstants.HMS_HLS_PLAYBACK_EVENT, - MapBuilder.of("registrationName", "onHmsHlsPlaybackEvent"), - HMSHLSPlayerConstants.HMS_HLS_STATS_EVENT, - MapBuilder.of("registrationName", "onHmsHlsStatsEvent"), - HMSHLSPlayerConstants.HLS_DATA_REQUEST_EVENT, - MapBuilder.of("registrationName", "onDataReturned"), - HMSHLSPlayerConstants.HLS_PLAYER_CUES_EVENT, - MapBuilder.of("registrationName", "onHlsPlayerCuesEvent"), + // MapBuilder returns a Java Map; wrap it into a MutableMap to satisfy RN 0.81 signature + return HashMap( + MapBuilder.of( + HMSHLSPlayerConstants.HMS_HLS_PLAYBACK_EVENT, + MapBuilder.of("registrationName", "onHmsHlsPlaybackEvent"), + HMSHLSPlayerConstants.HMS_HLS_STATS_EVENT, + MapBuilder.of("registrationName", "onHmsHlsStatsEvent"), + HMSHLSPlayerConstants.HLS_DATA_REQUEST_EVENT, + MapBuilder.of("registrationName", "onDataReturned"), + HMSHLSPlayerConstants.HLS_PLAYER_CUES_EVENT, + MapBuilder.of("registrationName", "onHlsPlayerCuesEvent"), + ), ) } @@ -97,22 +100,24 @@ class HMSHLSPlayerManager : SimpleViewManager() { } override fun getCommandsMap(): MutableMap? = - MapBuilder - .builder() - .put("play", 10) - .put("stop", 20) - .put("pause", 30) - .put("resume", 40) - .put("seekToLivePosition", 50) - .put("seekForward", 60) - .put("seekBackward", 70) - .put("setVolume", 80) - .put("areClosedCaptionSupported", 90) - .put("isClosedCaptionEnabled", 100) - .put("enableClosedCaption", 110) - .put("disableClosedCaption", 120) - .put("getPlayerDurationDetails", 130) - .build() + HashMap( + MapBuilder + .builder() + .put("play", 10) + .put("stop", 20) + .put("pause", 30) + .put("resume", 40) + .put("seekToLivePosition", 50) + .put("seekForward", 60) + .put("seekBackward", 70) + .put("setVolume", 80) + .put("areClosedCaptionSupported", 90) + .put("isClosedCaptionEnabled", 100) + .put("enableClosedCaption", 110) + .put("disableClosedCaption", 120) + .put("getPlayerDurationDetails", 130) + .build(), + ) @ReactProp(name = "url") fun setStreamURL( diff --git a/packages/react-native-hms/android/src/main/java/com/reactnativehmssdk/HMSManager.kt b/packages/react-native-hms/android/src/main/java/com/reactnativehmssdk/HMSManager.kt index be72cbf1a..b4caf59da 100644 --- a/packages/react-native-hms/android/src/main/java/com/reactnativehmssdk/HMSManager.kt +++ b/packages/react-native-hms/android/src/main/java/com/reactnativehmssdk/HMSManager.kt @@ -96,7 +96,7 @@ class HMSManager( reactAppContext = reactApplicationContext if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - currentActivity?.let { + reactApplicationContext.currentActivity?.let { pipReceiver?.register(it) } } @@ -438,7 +438,7 @@ class HMSManager( data: ReadableMap, callback: Promise?, ) { - currentActivity?.application?.registerActivityLifecycleCallbacks(this) + reactApplicationContext.currentActivity?.application?.registerActivityLifecycleCallbacks(this) val hms = HMSHelper.getHms(data, hmsCollection) hms?.startScreenshare(callback) @@ -461,7 +461,7 @@ class HMSManager( ) { val hms = HMSHelper.getHms(data, hmsCollection) - currentActivity?.application?.unregisterActivityLifecycleCallbacks(this) + reactApplicationContext.currentActivity?.application?.unregisterActivityLifecycleCallbacks(this) hms?.stopScreenshare(callback) } @@ -470,7 +470,7 @@ class HMSManager( data: ReadableMap, callback: Promise?, ) { - currentActivity?.application?.registerActivityLifecycleCallbacks(this) + reactApplicationContext.currentActivity?.application?.registerActivityLifecycleCallbacks(this) val hms = HMSHelper.getHms(data, hmsCollection) hms?.startAudioshare(data, callback) @@ -493,7 +493,7 @@ class HMSManager( ) { val hms = HMSHelper.getHms(data, hmsCollection) - currentActivity?.application?.unregisterActivityLifecycleCallbacks(this) + reactApplicationContext.currentActivity?.application?.unregisterActivityLifecycleCallbacks(this) hms?.stopAudioshare(callback) } @@ -784,7 +784,7 @@ class HMSManager( return } - val activity = currentActivity + val activity = reactApplicationContext.currentActivity if (activity !== null) { val hmssdk = getHmsInstance()[PipActionReceiver.sdkIdForPIP!!]?.hmsSDK @@ -1085,7 +1085,7 @@ class HMSManager( throw Throwable(message = "PIP Mode is not supported!") } - val activity = currentActivity ?: return false + val activity = reactApplicationContext.currentActivity ?: return false val pipParamConfig = readableMapToPipParamConfig(data) ?: return false val pipParams = buildPipParams(pipParamConfig) ?: return false @@ -1122,7 +1122,7 @@ class HMSManager( throw Throwable(message = "PIP Mode is not supported!") } - val activity = currentActivity ?: return false + val activity = reactApplicationContext.currentActivity ?: return false val pipParamConfig = readableMapToPipParamConfig(data) ?: return false val pipParams = buildPipParams(pipParamConfig) ?: return false @@ -1713,7 +1713,7 @@ class HMSManager( hmsCollection[key]?.leave(null) } } - currentActivity?.application?.unregisterActivityLifecycleCallbacks(this) + reactApplicationContext.currentActivity?.application?.unregisterActivityLifecycleCallbacks(this) hmsCollection = mutableMapOf() // unregistering pip actions on activity destroy. if (pipReceiver !== null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { diff --git a/packages/react-native-hms/android/src/main/java/com/reactnativehmssdk/HMSSDKViewManager.kt b/packages/react-native-hms/android/src/main/java/com/reactnativehmssdk/HMSSDKViewManager.kt index 5c1ac2f35..55e865921 100644 --- a/packages/react-native-hms/android/src/main/java/com/reactnativehmssdk/HMSSDKViewManager.kt +++ b/packages/react-native-hms/android/src/main/java/com/reactnativehmssdk/HMSSDKViewManager.kt @@ -22,17 +22,21 @@ class HMSSDKViewManager : SimpleViewManager() { } override fun getExportedCustomBubblingEventTypeConstants(): MutableMap? = - MapBuilder - .builder() - .put( - "topChange", - MapBuilder.of("phasedRegistrationNames", MapBuilder.of("bubbled", "onChange")), - ).build() + HashMap( + MapBuilder + .builder() + .put( + "topChange", + MapBuilder.of("phasedRegistrationNames", MapBuilder.of("bubbled", "onChange")), + ).build(), + ) override fun getExportedCustomDirectEventTypeConstants(): MutableMap? = - MapBuilder.of( - "captureFrame", - MapBuilder.of("registrationName", "onDataReturned"), + HashMap( + MapBuilder.of( + "captureFrame", + MapBuilder.of("registrationName", "onDataReturned"), + ), ) @RequiresApi(Build.VERSION_CODES.N)