Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(android): add bridgeless support #4985

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions android/build.gradle
Expand Up @@ -19,6 +19,10 @@ buildscript {

apply plugin: 'com.android.library'

def isNewArchitectureEnabled() {
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
}

android {
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
Expand All @@ -30,6 +34,8 @@ android {
defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', 21)
targetSdkVersion safeExtGet('targetSdkVersion', 34)

buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
}
}

Expand Down
6 changes: 4 additions & 2 deletions android/src/main/java/com/rnmaps/maps/MapManager.java
Expand Up @@ -450,8 +450,10 @@ public void updateExtraData(MapView view, Object extraData) {
}

void pushEvent(ThemedReactContext context, View view, String name, WritableMap data) {
context.getJSModule(RCTEventEmitter.class)
.receiveEvent(view.getId(), name, data);
context
.getReactApplicationContext()
.getJSModule(RCTEventEmitter.class)
.receiveEvent(view.getId(), name, data);
}

@Override
Expand Down
11 changes: 10 additions & 1 deletion android/src/main/java/com/rnmaps/maps/MapView.java
Expand Up @@ -30,7 +30,9 @@
import com.facebook.react.bridge.WritableNativeMap;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.UIManagerHelper;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.common.UIManagerType;
import com.facebook.react.uimanager.events.EventDispatcher;
import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory;
Expand Down Expand Up @@ -208,7 +210,14 @@ public boolean onDoubleTap(MotionEvent ev) {
}
});

eventDispatcher = reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
int uiManagerType = UIManagerType.DEFAULT;
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
uiManagerType = UIManagerType.FABRIC;
}

eventDispatcher = UIManagerHelper
.getUIManager(reactContext, uiManagerType)
.getEventDispatcher();

// Set up a parent view for triggering visibility in subviews that depend on it.
// Mainly ReactImageView depends on Fresco which depends on onVisibilityChanged() event
Expand Down