123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- package com.reactnativenavigation;
-
- import android.app.Application;
- import android.os.Handler;
- import android.support.annotation.Nullable;
-
- import com.facebook.react.ReactApplication;
- import com.facebook.react.ReactNativeHost;
- import com.facebook.react.ReactPackage;
- import com.facebook.react.bridge.ReactContext;
- import com.reactnativenavigation.bridge.EventEmitter;
- import com.reactnativenavigation.controllers.ActivityCallbacks;
- import com.reactnativenavigation.react.NavigationReactGateway;
- import com.reactnativenavigation.react.ReactGateway;
-
- import java.util.List;
-
- public abstract class NavigationApplication extends Application implements ReactApplication {
-
- public static NavigationApplication instance;
-
- private NavigationReactGateway reactGateway;
- private EventEmitter eventEmitter;
- private Handler handler;
- private ActivityCallbacks activityCallbacks;
-
- @Override
- public void onCreate() {
- super.onCreate();
- instance = this;
- handler = new Handler(getMainLooper());
- reactGateway = new NavigationReactGateway();
- eventEmitter = new EventEmitter(reactGateway);
- activityCallbacks = new ActivityCallbacks();
- }
-
- public void startReactContextOnceInBackgroundAndExecuteJS() {
- reactGateway.startReactContextOnceInBackgroundAndExecuteJS();
- }
-
- public void runOnMainThread(Runnable runnable) {
- handler.post(runnable);
- }
-
- public void runOnMainThread(Runnable runnable, long delay) {
- handler.postDelayed(runnable, delay);
- }
-
- public ReactGateway getReactGateway() {
- return reactGateway;
- }
-
- public ActivityCallbacks getActivityCallbacks() {
- return activityCallbacks;
- }
-
- protected void setActivityCallbacks(ActivityCallbacks activityLifecycleCallbacks) {
- this.activityCallbacks = activityLifecycleCallbacks;
- }
-
- public boolean isReactContextInitialized() {
- return reactGateway.isInitialized();
- }
-
- public void onReactInitialized(ReactContext reactContext) {
- // nothing
- }
-
- @Override
- public ReactNativeHost getReactNativeHost() {
- return reactGateway.getReactNativeHost();
- }
-
- public EventEmitter getEventEmitter() {
- return eventEmitter;
- }
-
- /**
- * @see ReactNativeHost#getJSMainModuleName()
- */
- @Nullable
- public String getJSMainModuleName() {
- return null;
- }
-
- /**
- * @see ReactNativeHost#getJSBundleFile()
- */
- @Nullable
- public String getJSBundleFile() {
- return null;
- }
-
- /**
- * @see ReactNativeHost#getBundleAssetName()
- */
- @Nullable
- public String getBundleAssetName() {
- return null;
- }
-
- public abstract boolean isDebug();
-
- @Nullable
- public abstract List<ReactPackage> createAdditionalReactPackages();
- }
|