Created
January 2, 2023 23:03
-
-
Save MaxPleaner/e02cc868ea021dae08ba20ada0a6277f to your computer and use it in GitHub Desktop.
CameraViewWrapper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Just an excerpt of the relevant part here | |
<Button | |
title="Click to invoke your native module!" | |
color="#841584" | |
onPress={() => {CameraViewWrapper.testEvent()}} | |
/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.shadercam; | |
import com.facebook.react.bridge.NativeModule; | |
import com.facebook.react.bridge.ReactApplicationContext; | |
import com.facebook.react.bridge.ReactContext; | |
import com.facebook.react.bridge.ReactContextBaseJavaModule; | |
import com.facebook.react.bridge.ReactMethod; | |
import java.util.Map; | |
import java.util.HashMap; | |
import android.util.Log; | |
public class CameraViewWrapper extends ReactContextBaseJavaModule { | |
CameraViewWrapper(ReactApplicationContext context) { | |
super(context); | |
} | |
@Override | |
public String getName() { | |
return "CameraViewWrapper"; | |
} | |
@ReactMethod | |
public void testEvent() { | |
Log.d("ReactNative","Notify App"); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.shadercam; | |
import com.facebook.react.ReactPackage; | |
import com.facebook.react.bridge.NativeModule; | |
import com.facebook.react.bridge.ReactApplicationContext; | |
import com.facebook.react.uimanager.ViewManager; | |
import java.util.ArrayList; | |
import java.util.Collections; | |
import java.util.List; | |
public class CameraViewWrapperPackage implements ReactPackage { | |
@Override | |
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) { | |
return Collections.emptyList(); | |
} | |
@Override | |
public List<NativeModule> createNativeModules( | |
ReactApplicationContext reactContext) { | |
List<NativeModule> modules = new ArrayList<>(); | |
modules.add(new CameraViewWrapper(reactContext)); | |
return modules; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Just an excerpt of the changed part here | |
@Override | |
protected List<ReactPackage> getPackages() { | |
@SuppressWarnings("UnnecessaryLocalVariable") | |
List<ReactPackage> packages = new PackageList(this).getPackages(); | |
// Packages that cannot be autolinked yet can be added manually here, for example: | |
packages.add(new CameraViewWrapperPackage()); | |
return packages; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment