108 lines
3.3 KiB
Java
108 lines
3.3 KiB
Java
package com.fieldnotes;
|
|
|
|
import android.app.Application;
|
|
|
|
import com.facebook.react.ReactApplication;
|
|
import io.sentry.react.RNSentryPackage;
|
|
import com.reactnativecommunity.netinfo.NetInfoPackage;
|
|
import com.reactnativecommunity.asyncstorage.AsyncStoragePackage;
|
|
import com.oblador.vectoricons.VectorIconsPackage;
|
|
import com.devstepbcn.wifi.AndroidWifiPackage;
|
|
import com.facebook.react.ReactNativeHost;
|
|
import com.facebook.react.ReactPackage;
|
|
import com.facebook.react.shell.MainReactPackage;
|
|
import com.facebook.soloader.SoLoader;
|
|
import cl.json.RNSharePackage;
|
|
import io.github.elyx0.reactnativedocumentpicker.DocumentPickerPackage;
|
|
import cl.json.ShareApplication;
|
|
import com.rnfs.RNFSPackage;
|
|
import com.mapbox.rctmgl.RCTMGLPackage;
|
|
import android.content.Context;
|
|
import com.facebook.react.PackageList;
|
|
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
import java.lang.reflect.InvocationTargetException;
|
|
|
|
import com.facebook.react.ReactInstanceManager;
|
|
|
|
public class MainApplication extends Application implements ReactApplication, ShareApplication {
|
|
|
|
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
|
|
@Override
|
|
public boolean getUseDeveloperSupport() {
|
|
return BuildConfig.DEBUG;
|
|
}
|
|
|
|
@Override
|
|
protected List<ReactPackage> getPackages() {
|
|
return Arrays.<ReactPackage>asList(
|
|
new MainReactPackage(),
|
|
new RNSentryPackage(),
|
|
new NetInfoPackage(),
|
|
new AsyncStoragePackage(),
|
|
new VectorIconsPackage(),
|
|
new AndroidWifiPackage(),
|
|
new ReachviewReactPackage(),
|
|
new RNSharePackage(),
|
|
new RNFSPackage(),
|
|
new DocumentPickerPackage(),
|
|
new RCTMGLPackage()
|
|
);
|
|
}
|
|
|
|
@Override
|
|
protected String getJSMainModuleName() {
|
|
return "index";
|
|
}
|
|
};
|
|
|
|
@Override
|
|
public ReactNativeHost getReactNativeHost() {
|
|
return mReactNativeHost;
|
|
}
|
|
|
|
@Override
|
|
public void onCreate() {
|
|
super.onCreate();
|
|
SoLoader.init(this, /* native exopackage */ false);
|
|
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
|
|
}
|
|
|
|
@Override
|
|
public String getFileProviderAuthority() {
|
|
return BuildConfig.APPLICATION_ID + ".provider";
|
|
}
|
|
|
|
/**
|
|
* Loads Flipper in React Native templates. Call this in the onCreate method with something like
|
|
* initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
|
|
*
|
|
* @param context
|
|
* @param reactInstanceManager
|
|
*/
|
|
private static void initializeFlipper(
|
|
Context context, ReactInstanceManager reactInstanceManager) {
|
|
if (BuildConfig.DEBUG) {
|
|
try {
|
|
/*
|
|
We use reflection here to pick up the class that initializes Flipper,
|
|
since Flipper library is not available in release mode
|
|
*/
|
|
Class<?> aClass = Class.forName("com.rndiffapp.ReactNativeFlipper");
|
|
aClass
|
|
.getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
|
|
.invoke(null, context, reactInstanceManager);
|
|
} catch (ClassNotFoundException e) {
|
|
e.printStackTrace();
|
|
} catch (NoSuchMethodException e) {
|
|
e.printStackTrace();
|
|
} catch (IllegalAccessException e) {
|
|
e.printStackTrace();
|
|
} catch (InvocationTargetException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
}
|