暫無描述

MainApplicationTurboModuleManagerDelegate.java 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package com.censusproject.newarchitecture.modules;
  2. import com.facebook.jni.HybridData;
  3. import com.facebook.react.ReactPackage;
  4. import com.facebook.react.ReactPackageTurboModuleManagerDelegate;
  5. import com.facebook.react.bridge.ReactApplicationContext;
  6. import com.facebook.soloader.SoLoader;
  7. import java.util.List;
  8. /**
  9. * Class responsible to load the TurboModules. This class has native methods and needs a
  10. * corresponding C++ implementation/header file to work correctly (already placed inside the jni/
  11. * folder for you).
  12. *
  13. * <p>Please note that this class is used ONLY if you opt-in for the New Architecture (see the
  14. * `newArchEnabled` property). Is ignored otherwise.
  15. */
  16. public class MainApplicationTurboModuleManagerDelegate
  17. extends ReactPackageTurboModuleManagerDelegate {
  18. private static volatile boolean sIsSoLibraryLoaded;
  19. protected MainApplicationTurboModuleManagerDelegate(
  20. ReactApplicationContext reactApplicationContext, List<ReactPackage> packages) {
  21. super(reactApplicationContext, packages);
  22. }
  23. protected native HybridData initHybrid();
  24. native boolean canCreateTurboModule(String moduleName);
  25. public static class Builder extends ReactPackageTurboModuleManagerDelegate.Builder {
  26. protected MainApplicationTurboModuleManagerDelegate build(
  27. ReactApplicationContext context, List<ReactPackage> packages) {
  28. return new MainApplicationTurboModuleManagerDelegate(context, packages);
  29. }
  30. }
  31. @Override
  32. protected synchronized void maybeLoadOtherSoLibraries() {
  33. if (!sIsSoLibraryLoaded) {
  34. // If you change the name of your application .so file in the Android.mk file,
  35. // make sure you update the name here as well.
  36. SoLoader.loadLibrary("censusproject_appmodules");
  37. sIsSoLibraryLoaded = true;
  38. }
  39. }
  40. }