Skip to content

Commit

Permalink
fix(android): fix crash with interop layer (#3509)
Browse files Browse the repository at this point in the history
  • Loading branch information
KrzysztofMoch committed Jan 31, 2024
1 parent 53068dd commit 41e9bcb
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
import com.brentvatne.common.api.VideoTrack;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.UIManager;
import com.facebook.react.bridge.WritableArray;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.uimanager.UIManagerHelper;
import com.facebook.react.uimanager.common.ViewUtil;
import com.facebook.react.uimanager.events.RCTEventEmitter;
import com.google.ads.interactivemedia.v3.api.AdError;

Expand All @@ -23,12 +26,12 @@

public class VideoEventEmitter {

private final RCTEventEmitter eventEmitter;
private final ReactContext mReactContext;

private int viewId = View.NO_ID;

public VideoEventEmitter(ReactContext reactContext) {
this.eventEmitter = reactContext.getJSModule(RCTEventEmitter.class);
this.mReactContext = reactContext;
}

private static final String EVENT_LOAD_START = "onVideoLoadStart";
Expand Down Expand Up @@ -449,6 +452,10 @@ public void receiveAdErrorEvent(AdError error) {
}

private void receiveEvent(@VideoEvents String type, WritableMap event) {
eventEmitter.receiveEvent(viewId, type, event);
UIManager uiManager = UIManagerHelper.getUIManager(mReactContext, ViewUtil.getUIManagerType(viewId));

if(uiManager != null) {
uiManager.receiveEvent(UIManagerHelper.getSurfaceId(mReactContext), viewId, type, event);
}
}
}

0 comments on commit 41e9bcb

Please sign in to comment.