react-native-navigation的迁移库

NavigationApplication.java 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package com.reactnativenavigation;
  2. import android.app.Application;
  3. import com.facebook.react.ReactApplication;
  4. import com.facebook.react.ReactNativeHost;
  5. import com.reactnativenavigation.controllers.ActivityLifecycleDelegate;
  6. import com.reactnativenavigation.react.DevPermissionRequestImpl;
  7. import com.reactnativenavigation.react.NavigationReactNativeHost;
  8. public abstract class NavigationApplication extends Application implements ReactApplication {
  9. public static NavigationApplication instance;
  10. public static class Config {
  11. public ReactNativeHost reactNativeHost;
  12. public ActivityLifecycleDelegate activityLifecycleDelegate;
  13. }
  14. private Config config;
  15. @Override
  16. public void onCreate() {
  17. super.onCreate();
  18. instance = this;
  19. config = createConfig();
  20. }
  21. public final Config getConfig() {
  22. return config;
  23. }
  24. @Override
  25. public ReactNativeHost getReactNativeHost() {
  26. return getConfig().reactNativeHost;
  27. }
  28. public abstract boolean isDebug();
  29. /**
  30. * override this to inject your own configuration
  31. *
  32. * @return the Config
  33. */
  34. protected Config createConfig() {
  35. Config config = new Config();
  36. config.reactNativeHost = new NavigationReactNativeHost(this, isDebug());
  37. config.activityLifecycleDelegate = new ActivityLifecycleDelegate(config.reactNativeHost.getReactInstanceManager(), new DevPermissionRequestImpl());
  38. return config;
  39. }
  40. }