Here are the examples of the java api com.facebook.react.ReactInstanceManager taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
102 Examples
19
Source : QtalkServiceRNViewInstanceManager.java
with MIT License
from qunarcorp
with MIT License
from qunarcorp
/**
* Created by hubin on 2018/1/18.
*/
public clreplaced QtalkServiceRNViewInstanceManager {
public static final String JS_BUNDLE_NAME = "index.androidserver.bundle";
public static final String JS_BUNDLE_NAME_ZIP_NAME = JS_BUNDLE_NAME + ".zip";
public static final String CACHE_BUNDLE_NAME = "index.androidserver.bundle_v1";
public static String JS_BUNDLE_LOCAL_BASE_PATH = "";
public static ReactInstanceManager mReactInstanceManager;
public synchronized static ReactInstanceManager getInstanceManager(Activity mActivity) {
if (mReactInstanceManager == null) {
buildBundle(mActivity);
}
// if(mReactInstanceManager == null && !buildBundle(mActivity)){
// // build error
// };
return mReactInstanceManager;
}
public static String getLocalBundleFilePath(Activity mActivity) {
QtalkServiceRNViewInstanceManager.JS_BUNDLE_LOCAL_BASE_PATH = mActivity.getApplicationContext().getFilesDir().getPath() + File.separator + "rnRes" + File.separator + "qtalk_rn_service" + File.separator;
return JS_BUNDLE_LOCAL_BASE_PATH + CACHE_BUNDLE_NAME;
}
public static String getLocalBundlePath(Activity mActivity) {
QtalkServiceRNViewInstanceManager.JS_BUNDLE_LOCAL_BASE_PATH = mActivity.getApplicationContext().getFilesDir().getPath() + File.separator + "rnRes" + File.separator + "qtalk_rn_service" + File.separator;
return JS_BUNDLE_LOCAL_BASE_PATH;
}
public static boolean buildBundle(Activity activity) {
boolean is_ok = false;
try {
ReactInstanceManagerBuilder builder = ReactInstanceManager.builder().setApplication(activity.getApplication()).setJSMainModulePath("index.android").addPackage(new MainReactPackage()).addPackage(new QtalkServiceReactPackage(activity)).addPackage(new CookieManagerPackage()).addPackage(new SvgPackage()).addPackage(new RNI18nPackage()).setUseDeveloperSupport(CommonConfig.isDebug).setInitialLifecycleState(LifecycleState.RESUMED);
String localBundleFile = getLocalBundleFilePath(activity);
File file = new File(localBundleFile);
if (file.exists()) {
// load from cache
builder.setJSBundleFile(localBundleFile);
} else {
// load from replacedet
builder.setBundlereplacedetName(JS_BUNDLE_NAME);
}
mReactInstanceManager = builder.build();
is_ok = true;
} catch (Exception e) {
}
return is_ok;
}
}
19
Source : QtalkServiceExternalRNViewInstanceManager.java
with MIT License
from qunarcorp
with MIT License
from qunarcorp
public clreplaced QtalkServiceExternalRNViewInstanceManager {
public static final String JS_BUNDLE_NAME = "index.androidserver.bundle";
public static final String JS_BUNDLE_NAME_ZIP_NAME = JS_BUNDLE_NAME + ".zip";
public static final String CACHE_BUNDLE_NAME = "index.androidserver.bundle";
public static String JS_BUNDLE_LOCAL_BASE_PATH = "";
public static ReactInstanceManager mReactInstanceManager;
public static String lastBundleName = "";
public static ReactInstanceManager getInstanceManager(Activity mActivity, String bundleName, String Entrance) {
if (lastBundleName.equals(bundleName)) {
if (mReactInstanceManager == null && !buildBundle(mActivity, bundleName, Entrance)) {
// build error
mReactInstanceManager = null;
}
} else {
buildBundle(mActivity, bundleName, Entrance);
lastBundleName = bundleName;
}
// if (mReactInstanceManager == null && !buildBundle(mActivity, bundleName, Entrance)) {
// // build error
// mReactInstanceManager = null;
// }
return mReactInstanceManager;
}
public static String getLocalBundleFilePath(Context application, String bundleName) {
QtalkServiceExternalRNViewInstanceManager.JS_BUNDLE_LOCAL_BASE_PATH = application.getFilesDir().getPath() + File.separator + "External" + File.separator + bundleName;
return JS_BUNDLE_LOCAL_BASE_PATH;
}
public static String getLocalBundlePath(Context activity) {
QtalkServiceExternalRNViewInstanceManager.JS_BUNDLE_LOCAL_BASE_PATH = activity.getFilesDir().getPath() + File.separator + "External" + File.separator;
return JS_BUNDLE_LOCAL_BASE_PATH;
}
public static boolean buildBundle(Activity mActivity, String bundleName, String Entrance) {
boolean is_ok = false;
try {
ReactInstanceManagerBuilder builder = ReactInstanceManager.builder().setApplication(mActivity.getApplication()).setJSMainModulePath(Entrance).addPackage(new MainReactPackage()).addPackage(new QtalkServiceReactPackage(mActivity)).addPackage(new CookieManagerPackage()).addPackage(new SvgPackage()).addPackage(new RNI18nPackage()).setUseDeveloperSupport(CommonConfig.isDebug).setInitialLifecycleState(LifecycleState.RESUMED);
String localBundleFile = getLocalBundleFilePath(mActivity, bundleName);
File file = new File(localBundleFile);
if (file.exists()) {
// load from cache
is_ok = true;
builder.setJSBundleFile(localBundleFile);
} else {
// load from replacedet
is_ok = false;
}
mReactInstanceManager = builder.build();
} catch (Exception e) {
is_ok = false;
}
return is_ok;
}
}
19
Source : QTalkSearchRNViewOldInstanceManager.java
with MIT License
from qunarcorp
with MIT License
from qunarcorp
public clreplaced QTalkSearchRNViewOldInstanceManager {
public static final String MODULE = "qtalkSearch";
public static final String JS_BUNDLE_NAME = "rn-qtalk-search.android.jsbundle";
public static final String JS_BUNDLE_NAME_ZIP_NAME = JS_BUNDLE_NAME + ".zip";
public static final String CACHE_BUNDLE_NAME = "rn-qtalk-search.ios.jsbundle_v3";
public static String JS_BUNDLE_LOCAL_BASE_PATH = "";
public static ReactInstanceManager mReactInstanceManager;
public static ReactInstanceManager getInstanceManager(Application application) {
if (mReactInstanceManager == null && !buildBundle(application)) {
// build error
}
;
return mReactInstanceManager;
}
public static String getLocalBundleFilePath(Application application) {
QTalkSearchRNViewInstanceManager.JS_BUNDLE_LOCAL_BASE_PATH = application.getApplicationContext().getFilesDir().getPath() + File.separator + "rnRes" + File.separator + "qtalk_service" + File.separator;
return JS_BUNDLE_LOCAL_BASE_PATH + CACHE_BUNDLE_NAME;
}
public static String getLocalBundlePath(Activity activity) {
QTalkSearchRNViewInstanceManager.JS_BUNDLE_LOCAL_BASE_PATH = activity.getApplicationContext().getFilesDir().getPath() + File.separator + "rnRes" + File.separator + "qtalk_service" + File.separator;
return JS_BUNDLE_LOCAL_BASE_PATH;
}
public static boolean buildBundle(Application application) {
boolean is_ok = false;
try {
ReactInstanceManagerBuilder builder = ReactInstanceManager.builder().setApplication(application).setJSMainModulePath("index.android").addPackage(new MainReactPackage()).addPackage(new SearchReactPackage()).addPackage(new SvgPackage()).addPackage(new RNI18nPackage()).setUseDeveloperSupport(CommonConfig.isDebug).setInitialLifecycleState(LifecycleState.RESUMED);
String localBundleFile = getLocalBundleFilePath(application);
File file = new File(localBundleFile);
if (file.exists()) {
// load from cache
builder.setJSBundleFile(localBundleFile);
} else {
// load from replacedet
builder.setBundlereplacedetName(JS_BUNDLE_NAME);
}
mReactInstanceManager = builder.build();
is_ok = true;
} catch (Exception e) {
}
return is_ok;
}
}
19
Source : QTalkSearchRNViewInstanceManager.java
with MIT License
from qunarcorp
with MIT License
from qunarcorp
/**
* Created by wangyu.wang on 2016/11/30.
*/
public clreplaced QTalkSearchRNViewInstanceManager {
public static final String MODULE = "new_search";
public static final String JS_BUNDLE_NAME = "index.android_search.bundle_v2";
public static final String JS_BUNDLE_NAME_ZIP_NAME = JS_BUNDLE_NAME + ".zip";
public static final String CACHE_BUNDLE_NAME = "index.android_search.bundle_v2";
public static String JS_BUNDLE_LOCAL_BASE_PATH = "";
public static ReactInstanceManager mReactInstanceManager;
public static ReactInstanceManager getInstanceManager(Application application) {
if (mReactInstanceManager == null && !buildBundle(application)) {
// build error
}
return mReactInstanceManager;
}
public static String getLocalBundleFilePath(Application application) {
QTalkSearchRNViewInstanceManager.JS_BUNDLE_LOCAL_BASE_PATH = application.getApplicationContext().getFilesDir().getPath() + File.separator + "rnRes" + File.separator + "qtalk_service" + File.separator;
return JS_BUNDLE_LOCAL_BASE_PATH + CACHE_BUNDLE_NAME;
}
public static String getLocalBundlePath(Activity activity) {
QTalkSearchRNViewInstanceManager.JS_BUNDLE_LOCAL_BASE_PATH = activity.getApplicationContext().getFilesDir().getPath() + File.separator + "rnRes" + File.separator + "qtalk_service" + File.separator;
return JS_BUNDLE_LOCAL_BASE_PATH;
}
public static boolean buildBundle(Application application) {
boolean is_ok = false;
try {
ReactInstanceManagerBuilder builder = ReactInstanceManager.builder().setApplication(application).setJSMainModulePath("index").addPackage(new MainReactPackage()).addPackage(new SearchReactPackage()).addPackage(new SvgPackage()).addPackage(new RNI18nPackage()).setUseDeveloperSupport(CommonConfig.isDebug).setInitialLifecycleState(LifecycleState.RESUMED);
String localBundleFile = getLocalBundleFilePath(application);
File file = new File(localBundleFile);
if (file.exists()) {
// load from cache
builder.setJSBundleFile(localBundleFile);
} else {
// load from replacedet
builder.setBundlereplacedetName(JS_BUNDLE_NAME);
}
mReactInstanceManager = builder.build();
is_ok = true;
} catch (Exception e) {
}
return is_ok;
}
}
19
Source : ReactNativeDemoLibrary.java
with MIT License
from petterh
with MIT License
from petterh
/**
* Public interface to React Native Demo Library.
*/
public final clreplaced ReactNativeDemoLibrary {
/**
* Make sure we don't change "useDeveloperSupport" during the app's lifetime; the results
* will be unpredictable.
*/
private enum DeveloperSupport {
Uninitialized, UseDeveloperSupport, DontUseDeveloperSupport;
static DeveloperSupport fromBoolean(boolean value) {
return value ? UseDeveloperSupport : DontUseDeveloperSupport;
}
boolean equals(boolean value) {
return value ? this == UseDeveloperSupport : this == DontUseDeveloperSupport;
}
}
/**
* Holds the singleton {@link ReactInstanceManager}.
*
* The "context leak" warning can be ignored; the {@link Context} in question is in fact the
* application context -- the only one guaranteed to live for the lifetime of the application.
* It cannot leak.
*
* https://nfrolov.wordpress.com/2014/07/12/android-using-context-statically-and-in-singletons/
*/
@SuppressLint("StaticFieldLeak")
private static ReactInstanceManager reactInstanceManager;
private static DeveloperSupport developerSupport = DeveloperSupport.Uninitialized;
/**
* Prohibit instantiation of the {@link ReactNativeDemoLibrary} static clreplaced.
*/
private ReactNativeDemoLibrary() {
throw new IllegalStateException("Static clreplaced; do not instantiate.");
}
/**
* Create a react-native "HelloWorld" {@link ReactRootView}.
*
* @param activity The {@link Activity} that will host the {@code View}.
* @param useDeveloperSupport Preplaced {@code true} to load JS from development server. This requires
* overlay permission. Host applications should generally preplaced {@code false}.
* Preplaced the same value every time.
* @return a new react-native "HelloWorld" {@link ReactRootView}.
* @exception IllegalArgumentException if {@code activity == null} or this method has previously
* been called with a different value for {@code useDeveloperSupport}.
*/
public static View createHelloWorldView(@NonNull Activity activity, boolean useDeveloperSupport) {
// noinspection ConstantConditions
if (activity == null) {
throw new IllegalArgumentException("Null activity preplaceded to ReactNativeDemoLibrary.start");
}
if (developerSupport == DeveloperSupport.Uninitialized) {
replacedert reactInstanceManager == null;
developerSupport = DeveloperSupport.fromBoolean(useDeveloperSupport);
} else if (!developerSupport.equals(useDeveloperSupport)) {
replacedert reactInstanceManager != null;
throw new IllegalArgumentException("The value of useDeveloperSupport may not be changed during the app's lifetime.");
}
if (reactInstanceManager == null) {
reactInstanceManager = ReactInstanceManager.builder().setApplication(activity.getApplication()).setBundlereplacedetName("index.android.bundle").setJSMainModulePath("index.android").addPackage(new MainReactPackage()).addPackage(new DemoReactPackage()).setUseDeveloperSupport(useDeveloperSupport).setInitialLifecycleState(LifecycleState.BEFORE_RESUME).build();
}
ActivityLifeCycleHandler lifeCycleHandler = new ActivityLifeCycleHandler(activity, reactInstanceManager);
activity.getApplication().registerActivityLifecycleCallbacks(lifeCycleHandler);
ReactRootView reactRootView = new ReactRootView(activity);
reactRootView.startReactApplication(reactInstanceManager, "HelloWorld");
return reactRootView;
}
}
19
Source : ActivityLifeCycleHandler.java
with MIT License
from petterh
with MIT License
from petterh
/**
* Forwards life-cycle events to {@link ReactInstanceManager}. This saves the host
* {@link Activity} from having to implement a fair bit of boilerplate code.
*
* The life cycle handler is automatically unregistered when the activity is destroyed.
*
* TODO: Back-button handling needs forwarding to JS.
*/
public final clreplaced ActivityLifeCycleHandler implements Application.ActivityLifecycleCallbacks, DefaultHardwareBackBtnHandler {
private final Activity activity;
private final ReactInstanceManager reactInstanceManager;
/**
* Create a new instance of th e{@link ActivityLifeCycleHandler} clreplaced. It forwards life-cycle
* activities to to the provided {@link ReactInstanceManager react instance manager}.
*
* @param activity The activity hosting a {@link ReactRootView react native view}.
* @param reactInstanceManager The {@link ReactInstanceManager} to forward life-cycle events to.
*
* @exception IllegalArgumentException if either argument is {@code null}.
*/
public ActivityLifeCycleHandler(@NonNull Activity activity, @NonNull ReactInstanceManager reactInstanceManager) {
this.activity = activity;
this.reactInstanceManager = reactInstanceManager;
}
@Override
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
}
@Override
public void onActivityStarted(Activity activity) {
}
@Override
public void onActivityResumed(Activity activity) {
if (activity == this.activity) {
reactInstanceManager.onHostResume(activity, this);
}
}
@Override
public void onActivityPaused(Activity activity) {
if (activity == this.activity) {
reactInstanceManager.onHostPause(activity);
}
}
@Override
public void onActivityStopped(Activity activity) {
}
@Override
public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
}
@Override
public void onActivityDestroyed(Activity activity) {
if (activity == this.activity) {
activity.getApplication().unregisterActivityLifecycleCallbacks(this);
reactInstanceManager.onHostDestroy(activity);
}
}
@Override
public void invokeDefaultOnBackPressed() {
activity.onBackPressed();
}
}
19
Source : ThreadBaseReactPackage.java
with MIT License
from joltup
with MIT License
from joltup
public clreplaced ThreadBaseReactPackage implements ReactPackage {
private final ReactInstanceManager reactInstanceManager;
public ThreadBaseReactPackage(ReactInstanceManager reactInstanceManager) {
this.reactInstanceManager = reactInstanceManager;
}
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext catalystApplicationContext) {
return Arrays.<NativeModule>asList(// Core list
new AndroidInfoModule(catalystApplicationContext), new ExceptionsManagerModule(reactInstanceManager.getDevSupportManager()), new AppStateModule(catalystApplicationContext), new TimingModule(catalystApplicationContext, reactInstanceManager.getDevSupportManager()), new UIManagerStubModule(catalystApplicationContext), new SourceCodeModule(catalystApplicationContext), new JSCHeapCapture(catalystApplicationContext), // Main list
new AsyncStorageModule(catalystApplicationContext), new IntentModule(catalystApplicationContext), new NetworkingModule(catalystApplicationContext), new VibrationModule(catalystApplicationContext), new WebSocketModule(catalystApplicationContext), new ThreadSelfModule(catalystApplicationContext), new DevSettingsModule(catalystApplicationContext, reactInstanceManager.getDevSupportManager()));
}
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
return new ArrayList<>(0);
}
}
19
Source : ReactContextBuilder.java
with MIT License
from joltup
with MIT License
from joltup
public ReactContextBuilder setReactInstanceManager(ReactInstanceManager manager) {
this.instanceManager = manager;
return this;
}
19
Source : RestartModule.java
with MIT License
from avishayil
with MIT License
from avishayil
private ReactInstanceManager resolveInstanceManager() throws NoSuchFieldException, IllegalAccessException {
ReactInstanceManager instanceManager = getReactInstanceManager();
if (instanceManager != null) {
return instanceManager;
}
final Activity currentActivity = getCurrentActivity();
if (currentActivity == null) {
return null;
}
ReactApplication reactApplication = (ReactApplication) currentActivity.getApplication();
instanceManager = reactApplication.getReactNativeHost().getReactInstanceManager();
return instanceManager;
}
19
Source : RestartModule.java
with MIT License
from avishayil
with MIT License
from avishayil
private void loadBundle() {
clearLifecycleEventListener();
try {
final ReactInstanceManager instanceManager = resolveInstanceManager();
if (instanceManager == null) {
return;
}
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
try {
instanceManager.recreateReactContextInBackground();
} catch (Throwable t) {
loadBundleLegacy();
}
}
});
} catch (Throwable t) {
loadBundleLegacy();
}
}
19
Source : ReactNavigationCoordinator.java
with MIT License
from airbnb
with MIT License
from airbnb
public void injectReactInstanceManager(final ReactInstanceManager reactInstanceManager) {
if (this.reactInstanceManager != null) {
// TODO: throw error. can only initialize once.
}
this.reactInstanceManager = reactInstanceManager;
this.reactInstanceManager.addReactInstanceEventListener(new ReactInstanceManager.ReactInstanceEventListener() {
@Override
public void onReactContextInitialized(ReactContext context) {
reactInstanceManager.removeReactInstanceEventListener(this);
isSuccessfullyInitialized = true;
}
});
}
18
Source : MainActivity.java
with MIT License
from sonnylazuardi
with MIT License
from sonnylazuardi
public clreplaced MainActivity extends Activity implements DefaultHardwareBackBtnHandler {
public ReactRootView mReactRootView;
private ReactInstanceManager mReactInstanceManager;
private static final int OVERLAY_PERMISSION_REQ_CODE = 2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (!Settings.canDrawOverlays(this)) {
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName()));
startActivityForResult(intent, OVERLAY_PERMISSION_REQ_CODE);
} else {
this.initializePage();
}
} else {
this.initializePage();
}
}
private void initializePage() {
mReactRootView = new ReactRootView(this);
mReactInstanceManager = ReactInstanceManager.builder().setApplication(getApplication()).setBundlereplacedetName("index.android.bundle").setJSMainModuleName("index.android").addPackage(new MainReactPackage()).addPackage(new ImageIntentPackage()).setUseDeveloperSupport(BuildConfig.DEBUG).setInitialLifecycleState(LifecycleState.RESUMED).build();
mReactRootView.startReactApplication(mReactInstanceManager, "Clarifai", null);
setContentView(com.sonnylab.imageintent.R.layout.activity_main);
((RelativeLayout) findViewById(com.sonnylab.imageintent.R.id.view_container)).addView(mReactRootView);
}
@Override
protected void onPause() {
super.onPause();
if (mReactInstanceManager != null) {
mReactInstanceManager.onHostPause(this);
}
}
@Override
protected void onResume() {
super.onResume();
if (mReactInstanceManager != null) {
mReactInstanceManager.onHostResume(this, this);
}
}
@Override
protected void onDestroy() {
super.onDestroy();
if (mReactInstanceManager != null) {
mReactInstanceManager.onHostDestroy();
}
}
@Override
public void onBackPressed() {
if (mReactInstanceManager != null) {
mReactInstanceManager.onBackPressed();
} else {
super.onBackPressed();
}
}
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_MENU && mReactInstanceManager != null) {
mReactInstanceManager.showDevOptionsDialog();
return true;
}
return super.onKeyUp(keyCode, event);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == OVERLAY_PERMISSION_REQ_CODE) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (!Settings.canDrawOverlays(this)) {
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName()));
startActivityForResult(intent, OVERLAY_PERMISSION_REQ_CODE);
} else {
this.initializePage();
}
}
} else {
super.onActivityResult(requestCode, resultCode, data);
}
}
@Override
public void invokeDefaultOnBackPressed() {
super.onBackPressed();
}
}
18
Source : RNWorkWorldFragment.java
with MIT License
from qunarcorp
with MIT License
from qunarcorp
public clreplaced RNWorkWorldFragment extends RNBaseFragment implements IMNotificaitonCenter.NotificationCenterDelegate, PermissionCallback {
private static final String MODULE = "WorkWorld";
private ReactInstanceManager mReactInstanceManager;
private ReactRootView mReactRootView;
private Activity activity;
private static final int PERMISSION_REQUIRE = PermissionDispatcher.getRequestCode();
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return super.onCreateView(inflater, container, savedInstanceState);
}
@Override
public void didReceivedNotification(String key, Object... args) {
}
@Override
public void responsePermission(int requestCode, boolean granted) {
}
}
18
Source : RNMineFragment.java
with MIT License
from qunarcorp
with MIT License
from qunarcorp
/**
* Created by hubin on 2018/3/27.
*/
public clreplaced RNMineFragment extends RNBaseFragment implements IMNotificaitonCenter.NotificationCenterDelegate {
private static final String MODULE = "MySetting";
private ReactInstanceManager mReactInstanceManager;
private ReactRootView mReactRootView;
private Activity activity;
@Override
public void onAttach(Context context) {
super.onAttach(context);
mReactRootView = new ReactRootView(context);
activity = getActivity();
mReactInstanceManager = QtalkServiceRNViewInstanceManager.getInstanceManager(activity);
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ConnectionUtil.getInstance().addEvent(this, QtalkEvent.SHOW_MY_INFO);
// ConnectionUtil.getInstance().addEvent(this, QtalkEvent.LOGIN_EVENT);
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
return mReactRootView;
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mReactRootView.startReactApplication(mReactInstanceManager, MODULE, getDefaultBundle());
}
@Override
protected void onFragmentFirstVisible() {
super.onFragmentFirstVisible();
}
public static Bundle getDefaultBundle() {
Bundle bundle = new Bundle();
return bundle;
}
private void sendEvent(ReactContext reactContext, String eventName, @Nullable WritableMap params) {
try {
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.clreplaced).emit(eventName, params);
} catch (Exception _ex) {
// null bridge
}
}
public void clearBridge() {
WritableNativeMap map = new WritableNativeMap();
sendEvent(mReactInstanceManager.getCurrentReactContext(), "QIM_RN_Will_Show", map);
}
@Override
public void didReceivedNotification(String key, Object... args) {
switch(key) {
case QtalkEvent.SHOW_MY_INFO:
clearBridge();
break;
}
}
// @Override
// public void onDestroy() {
// super.onDestroy();
// if (mReactInstanceManager != null) {
// mReactInstanceManager.onHostDestroy(getActivity());
// }
//
// if (mReactRootView != null) {
// mReactRootView.unmountReactApplication();
// mReactRootView = null;
// }
// ConnectionUtil.getInstance().removeEvent(this, QtalkEvent.SHOW_MY_INFO);
// }
}
18
Source : RNFoundFragment.java
with MIT License
from qunarcorp
with MIT License
from qunarcorp
/**
* Created by hubin on 2018/4/4.
*/
public clreplaced RNFoundFragment extends RNBaseFragment implements IMNotificaitonCenter.NotificationCenterDelegate {
private static final String MODULE = "FoundPage";
private ReactInstanceManager mReactInstanceManager;
private ReactRootView mReactRootView;
private Activity activity;
private PermissionListener mPermissionListener;
@Override
public void onAttach(Context context) {
super.onAttach(context);
mReactRootView = new ReactRootView(context);
activity = getActivity();
mReactInstanceManager = QtalkServiceRNViewInstanceManager.getInstanceManager(activity);
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ConnectionUtil.getInstance().addEvent(this, QtalkEvent.LOGIN_EVENT);
}
private void sendEvent(ReactContext reactContext, String eventName, @Nullable WritableMap params) {
try {
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.clreplaced).emit(eventName, params);
} catch (Exception _ex) {
// null bridge
}
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// super.onCreateView(inflater, container, savedInstanceState);
return mReactRootView;
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mReactRootView.startReactApplication(mReactInstanceManager, MODULE, getDefaultBundle());
}
public static Bundle getDefaultBundle() {
Bundle bundle = new Bundle();
bundle.putString("domain", QtalkNavicationService.getInstance().getXmppdomain());
// 暂时修改
return bundle;
}
public void clearBridge() {
if (mReactInstanceManager != null) {
WritableNativeMap map = new WritableNativeMap();
sendEvent(mReactInstanceManager.getCurrentReactContext(), "QIM_RN_Will_Show", map);
}
}
@Override
public void unbundling() {
super.unbundling();
mReactRootView.unmountReactApplication();
}
@Override
public void didReceivedNotification(String key, Object... args) {
switch(key) {
case QtalkEvent.LOGIN_EVENT:
if (args[0].equals(LoginStatus.Login)) {
clearBridge();
}
}
}
}
18
Source : RNContactsFragment.java
with MIT License
from qunarcorp
with MIT License
from qunarcorp
/**
* Created by hubin on 2018/3/28.
*/
public clreplaced RNContactsFragment extends RNBaseFragment implements IMNotificaitonCenter.NotificationCenterDelegate {
private static final String MODULE = "Contacts";
private ReactInstanceManager mReactInstanceManager;
private ReactRootView mReactRootView;
private Activity activity;
@Override
public void onAttach(Context context) {
super.onAttach(context);
mReactRootView = new ReactRootView(context);
activity = getActivity();
mReactInstanceManager = QtalkServiceRNViewInstanceManager.getInstanceManager(activity);
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addEvent();
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
// if(getActivity() !=null && getActivity().getFragmentManager().isDestroyed()){//fix IllegalStateException: Can't access ViewModels from
// RNViewModel rnViewModel = ViewModelProviders.of(getActivity()).get("RnVM",RNViewModel.clreplaced);
// rnViewModel.getUnreadCountLD().observe(this, new Observer<Integer>() {
// @Override
// public void onChanged(@Nullable Integer integer) {
// WritableNativeMap map = new WritableNativeMap();
// map.putString("UnreadCount",String.valueOf(integer));
// sendEvent(mReactInstanceManager.getCurrentReactContext(),"QIM_RN_UnreadCount",map);
// }
// });
// }
// }
}
public void addEvent() {
ConnectionUtil.getInstance().addEvent(this, QtalkEvent.Update_Buddy);
ConnectionUtil.getInstance().addEvent(this, QtalkEvent.USER_GET_FRIEND);
ConnectionUtil.getInstance().addEvent(this, QtalkEvent.LOGIN_EVENT);
}
public void removeEvent() {
ConnectionUtil.getInstance().removeEvent(this, QtalkEvent.USER_GET_FRIEND);
ConnectionUtil.getInstance().removeEvent(this, QtalkEvent.Update_Buddy);
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return mReactRootView;
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mReactRootView.startReactApplication(mReactInstanceManager, MODULE, getDefaultBundle());
}
@Override
protected void onFragmentFirstVisible() {
super.onFragmentFirstVisible();
}
public static Bundle getDefaultBundle() {
Bundle bundle = new Bundle();
return bundle;
}
private void sendEvent(ReactContext reactContext, String eventName, @Nullable WritableMap params) {
try {
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.clreplaced).emit(eventName, params);
} catch (Exception _ex) {
// null bridge
}
}
public void clearBridge() {
WritableNativeMap map = new WritableNativeMap();
sendEvent(mReactInstanceManager.getCurrentReactContext(), "QIM_RN_Will_Show", map);
}
@Override
public void didReceivedNotification(String key, Object... args) {
switch(key) {
// case QtalkEvent.Update_Buddy:
// //请求最新的好友
// clearBridge();
// break;
case QtalkEvent.USER_GET_FRIEND:
// 从数据库拿好友列表
clearBridge();
break;
case QtalkEvent.LOGIN_EVENT:
if (args[0].equals(LoginStatus.Login)) {
Logger.i("开始获取好友列表");
ConnectionUtil.getInstance().getFriends("");
}
}
}
}
18
Source : RNCalendarFragment.java
with MIT License
from qunarcorp
with MIT License
from qunarcorp
public clreplaced RNCalendarFragment extends RNBaseFragment implements IMNotificaitonCenter.NotificationCenterDelegate, PermissionCallback {
private static final String MODULE = "TravelCalendar";
private ReactInstanceManager mReactInstanceManager;
private ReactRootView mReactRootView;
private Activity activity;
private static final int PERMISSION_REQUIRE = PermissionDispatcher.getRequestCode();
@Override
public void onAttach(Context context) {
super.onAttach(context);
mReactRootView = new ReactRootView(context);
activity = getActivity();
mReactInstanceManager = QtalkServiceRNViewInstanceManager.getInstanceManager(activity);
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addEvent();
}
public void addEvent() {
ConnectionUtil.getInstance().addEvent(this, QtalkEvent.UPDATE_TRIP);
// ConnectionUtil.getInstance().addEvent(this, QtalkEvent.Update_Buddy);
// ConnectionUtil.getInstance().addEvent(this,QtalkEvent.USER_GET_FRIEND);
// ConnectionUtil.getInstance().addEvent(this,QtalkEvent.LOGIN_EVENT);
}
public void removeEvent() {
ConnectionUtil.getInstance().removeEvent(this, QtalkEvent.UPDATE_TRIP);
// ConnectionUtil.getInstance().removeEvent(this,QtalkEvent.USER_GET_FRIEND);
// ConnectionUtil.getInstance().removeEvent(this,QtalkEvent.Update_Buddy);
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return mReactRootView;
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mReactRootView.startReactApplication(mReactInstanceManager, MODULE, getDefaultBundle());
}
@Override
protected void onFragmentFirstVisible() {
super.onFragmentFirstVisible();
checkPermission();
}
/**
* 检查权限
*/
private void checkPermission() {
PermissionDispatcher.requestPermissionWithCheck(getActivity(), new int[] { PermissionDispatcher.REQUEST_READ_CALENDAR, PermissionDispatcher.REQUEST_WRITE_CALENDAR /*, PermissionDispatcher.REQUEST_READ_PHONE_STATE*/
}, this, PERMISSION_REQUIRE);
}
public static Bundle getDefaultBundle() {
Bundle bundle = new Bundle();
return bundle;
}
private void sendEvent(ReactContext reactContext, String eventName, @Nullable WritableMap params) {
try {
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.clreplaced).emit(eventName, params);
} catch (Exception _ex) {
// null bridge
}
}
public void clearBridge() {
WritableNativeMap map = new WritableNativeMap();
sendEvent(mReactInstanceManager.getCurrentReactContext(), "QIM_RN_Will_Show", map);
}
@Override
public void didReceivedNotification(String key, Object... args) {
switch(key) {
case QtalkEvent.UPDATE_TRIP:
// 请求最新的好友
clearBridge();
break;
}
}
@Override
public void responsePermission(int requestCode, boolean granted) {
if (requestCode == PERMISSION_REQUIRE) {
if (!granted) {
Toast.makeText(getActivity(), "没有日历权限,Qtalk无法同步日程到系统日历", Toast.LENGTH_LONG).show();
// finish();
return;
}
}
}
}
18
Source : QTalkSearchActivity.java
with MIT License
from qunarcorp
with MIT License
from qunarcorp
/**
* Created by wangyu.wang on 2016/11/30.
*/
public clreplaced QTalkSearchActivity extends AppCompatActivity implements DefaultHardwareBackBtnHandler {
private static ReactInstanceManager mReactInstanceManager;
private ReactRootView mReactRootView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (mReactInstanceManager == null) {
// if (TextUtils.isEmpty(QtalkNavicationService.getInstance().getNewSerarchUrl())) {
// mReactInstanceManager = QTalkSearchRNViewOldInstanceManager.getInstanceManager(getApplication());
// } else {
// if(QtalkNavicationService.getInstance().getXmppdomain().equals("ejabhost1")){
if (IMDatabaseManager.getInstance().getFocusSearch()) {
mReactInstanceManager = QTalkSearchRNViewOldInstanceManager.getInstanceManager(getApplication());
} else {
mReactInstanceManager = QTalkSearchRNViewInstanceManager.getInstanceManager(getApplication());
}
// }else{
// mReactInstanceManager = QTalkSearchRNViewOldInstanceManager.getInstanceManager(getApplication());
// }
// }
}
mReactRootView = new ReactRootView(this);
// render react
// if (mReactInstanceManager == null) {
// if (TextUtils.isEmpty(QtalkNavicationService.getInstance().getNewSerarchUrl())) {
// // mReactInstanceManager = QTalkSearchRNViewOldInstanceManager.getInstanceManager(getApplication());
// mReactRootView.startReactApplication(mReactInstanceManager, QTalkSearchRNViewOldInstanceManager.MODULE, getExtendBundle());
// } else {
// if(QtalkNavicationService.getInstance().getXmppdomain().equals("ejabhost1")) {
if (IMDatabaseManager.getInstance().getFocusSearch()) {
// mReactInstanceManager = QTalkSearchRNViewOldInstanceManager.getInstanceManager(getApplication());
mReactRootView.startReactApplication(mReactInstanceManager, QTalkSearchRNViewOldInstanceManager.MODULE, getExtendBundle());
} else {
// mReactInstanceManager = QTalkSearchRNViewInstanceManager.getInstanceManager(getApplication());
mReactRootView.startReactApplication(mReactInstanceManager, QTalkSearchRNViewInstanceManager.MODULE, getExtendBundle());
}
// }else{
// mReactRootView.startReactApplication(mReactInstanceManager, QTalkSearchRNViewOldInstanceManager.MODULE, getExtendBundle());
// }
// }
// }
// set to content
setContentView(mReactRootView);
}
private Bundle getExtendBundle() {
Bundle bundle = new Bundle();
bundle.putString("server", QtalkNavicationService.getInstance().getSimpleapiurl());
bundle.putString("searchUrl", QtalkNavicationService.getInstance().getNewSerarchUrl());
bundle.putString("singleDefaultPic", QimRNBModule.defaultUserImage);
bundle.putString("mucDefaultPic", QimRNBModule.defaultMucImage);
bundle.putString("imageHost", QtalkNavicationService.getInstance().getInnerFiltHttpHost());
bundle.putString("MyUserId", CurrentPreference.getInstance().getPreferenceUserId());
List<SearchKeyData> list = IMDatabaseManager.getInstance().getLocalSearchKeyHistory(0, 5);
List<String> array = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
array.add(list.get(i).getSearchKey());
}
bundle.putStringArrayList("searchKeyHistory", (ArrayList<String>) array);
return bundle;
}
public static void clearBridge() {
// TODO auto reload
}
@Override
protected void onDestroy() {
super.onDestroy();
if (mReactRootView != null)
mReactRootView.unmountReactApplication();
if (mReactInstanceManager != null)
mReactInstanceManager.onHostDestroy(this);
}
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_MENU && mReactInstanceManager != null) {
mReactInstanceManager.showDevOptionsDialog();
return true;
}
return super.onKeyUp(keyCode, event);
}
@Override
public void onBackPressed() {
if (mReactInstanceManager != null) {
mReactInstanceManager.onBackPressed();
} else {
super.onBackPressed();
}
}
@Override
public void invokeDefaultOnBackPressed() {
onBackPressed();
}
@Override
protected void onPause() {
super.onPause();
if (mReactInstanceManager != null) {
mReactInstanceManager.onHostPause();
}
}
@Override
protected void onResume() {
super.onResume();
if (mReactInstanceManager != null) {
mReactInstanceManager.onHostResume(this, new DefaultHardwareBackBtnHandler() {
@Override
public void invokeDefaultOnBackPressed() {
finish();
}
});
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (mReactInstanceManager != null) {
mReactInstanceManager.onActivityResult(mReactInstanceManager.getCurrentReactContext().getCurrentActivity(), requestCode, resultCode, data);
}
}
}
18
Source : QtalkServiceExternalRNActivity.java
with MIT License
from qunarcorp
with MIT License
from qunarcorp
public clreplaced QtalkServiceExternalRNActivity extends SwipeBackActivity implements DefaultHardwareBackBtnHandler, PermissionAwareActivity {
public static ReactInstanceManager mReactInstanceManager;
public static ReactInstanceManagerBuilder builder;
// 头部导航
protected QtNewActionBar qtNewActionBar;
public static ReactRootView mReactRootView;
private PermissionListener mPermissionListener;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.atom_ui_activity_rn_external);
bindView();
}
private void bindView() {
try {
qtNewActionBar = (QtNewActionBar) this.findViewById(R.id.my_action_bar);
setNewActionBar(qtNewActionBar);
boolean isShow = Boolean.parseBoolean(getIntent().getStringExtra("showNativeNav"));
if (isShow) {
String replacedle = getIntent().getStringExtra("navreplacedle");
setActionBarreplacedle(replacedle);
setActionBarVisibility(true);
} else {
setActionBarVisibility(false);
}
// mReactRootView = new ReactRootView(this);
mReactRootView = (ReactRootView) findViewById(R.id.mReactRootView);
startRNApplicationWithBundle(getExtendBundle());
// setContentView(mReactRootView);
} catch (Exception e) {
Logger.i("打开外部RN应用出现不可预知错误:" + e.getMessage());
}
}
private void startRNApplicationWithBundle(Bundle extendBundle) {
String bundleName = extendBundle.getString("Bundle");
String Entrance = extendBundle.getString("Entrance");
if (TextUtils.isEmpty(bundleName)) {
finish();
return;
}
// if (mReactInstanceManager == null) {
mReactInstanceManager = QtalkServiceExternalRNViewInstanceManager.getInstanceManager(this, bundleName, Entrance);
// }
String module = extendBundle.getString("name");
// render react
if (mReactInstanceManager == null) {
return;
}
mReactRootView.startReactApplication(mReactInstanceManager, module, extendBundle);
}
private Bundle getExtendBundle() {
Intent intent = getIntent();
Bundle bundle = intent.getExtras();
bundle.putString("name", intent.getStringExtra("module"));
return bundle;
}
@Override
public void invokeDefaultOnBackPressed() {
onBackPressed();
}
@Override
public void requestPermissions(String[] permissions, int requestCode, PermissionListener listener) {
mPermissionListener = listener;
ActivityCompat.requestPermissions(this, permissions, requestCode);
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
mPermissionListener.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
@Override
protected void onDestroy() {
super.onDestroy();
if (mReactInstanceManager != null) {
mReactInstanceManager.onHostDestroy(this);
}
// if (mReactRootView != null) {
// mReactRootView.unmountReactApplication();
// // mReactRootView = null;
// }
}
public void updatePage() {
if (mReactInstanceManager != null) {
mReactInstanceManager.onHostDestroy(this);
mReactInstanceManager = null;
QtalkServiceRNViewInstanceManager.mReactInstanceManager = null;
}
if (mReactRootView != null) {
mReactRootView.unmountReactApplication();
mReactRootView = null;
}
mReactRootView = new ReactRootView(this);
startRNApplicationWithBundle(getExtendBundle());
setContentView(mReactRootView);
}
@Override
public void onBackPressed() {
if (mReactInstanceManager != null) {
mReactInstanceManager.onBackPressed();
} else {
super.onBackPressed();
}
}
@Override
protected void onPause() {
super.onPause();
if (mReactInstanceManager != null) {
mReactInstanceManager.onHostPause();
}
}
@Override
protected void onResume() {
super.onResume();
if (mReactInstanceManager != null) {
mReactInstanceManager.onHostResume(this, new DefaultHardwareBackBtnHandler() {
@Override
public void invokeDefaultOnBackPressed() {
finish();
}
});
}
}
}
18
Source : QtalkOpenTravelCalendar.java
with MIT License
from qunarcorp
with MIT License
from qunarcorp
public clreplaced QtalkOpenTravelCalendar extends SwipeBackActivity implements DefaultHardwareBackBtnHandler, PermissionAwareActivity, IMNotificaitonCenter.NotificationCenterDelegate, PermissionCallback {
public ReactInstanceManager mReactInstanceManager;
private ReactRootView mReactRootView;
// 头部导航
protected QtNewActionBar qtNewActionBar;
private PermissionListener mPermissionListener;
private static final int PERMISSION_REQUIRE = PermissionDispatcher.getRequestCode();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.atom_ui_travel_calendar);
bindView();
addEvent();
startRNApplicationWithBundle(getExtendBundle());
bindData();
}
private void bindData() {
setActionBarRightSpecial(0);
// setActionBarSinglereplacedle(mreplacedles[mViewPager.getCurrenreplacedem()]);
setActionBarRightIcon(R.string.atom_ui_new_select_calendar);
setActionBarRightIconClick(new View.OnClickListener() {
@Override
public void onClick(View v) {
TimePickerView tpv = new TimePickerBuilder(QtalkOpenTravelCalendar.this, new OnTimeSelectListener() {
@Override
public void onTimeSelect(Date date, View v) {
String time = new SimpleDateFormat("yyyy-MM-dd").format(date);
IMNotificaitonCenter.getInstance().postMainThreadNotificationName(QtalkEvent.SELECT_DATE, time);
}
}).build();
tpv.show();
}
});
checkPermission();
}
/**
* 检查权限
*/
private void checkPermission() {
PermissionDispatcher.requestPermissionWithCheck(this, new int[] { PermissionDispatcher.REQUEST_READ_CALENDAR, PermissionDispatcher.REQUEST_WRITE_CALENDAR /*, PermissionDispatcher.REQUEST_READ_PHONE_STATE*/
}, this, PERMISSION_REQUIRE);
}
private void bindView() {
qtNewActionBar = (QtNewActionBar) this.findViewById(R.id.my_action_bar);
setNewActionBar(qtNewActionBar);
setActionBarreplacedle("行程");
mReactRootView = (ReactRootView) findViewById(R.id.mReactRootView);
}
private void startRNApplicationWithBundle(Bundle extendBundle) {
if (mReactInstanceManager == null) {
mReactInstanceManager = QtalkServiceRNViewInstanceManager.getInstanceManager(this);
}
String module = extendBundle.getString("name");
// render react
mReactRootView.startReactApplication(mReactInstanceManager, module, extendBundle);
}
private Bundle getExtendBundle() {
Intent intent = getIntent();
Uri data = intent.getData();
Bundle bundle = intent.getExtras();
if (bundle == null) {
bundle = new Bundle();
}
if (data != null) {
// schema 跳转
HashMap<String, String> map = Protocol.splitParams(data);
for (Map.Entry<String, String> entry : map.entrySet()) {
bundle.putString(entry.getKey(), entry.getValue());
}
bundle.putString("name", map.get("module"));
} else {
// intent 跳转
bundle.putString("name", intent.getStringExtra("module"));
}
return bundle;
}
@Override
public void requestPermissions(String[] permissions, int requestCode, PermissionListener listener) {
mPermissionListener = listener;
ActivityCompat.requestPermissions(this, permissions, requestCode);
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
if (mPermissionListener != null) {
mPermissionListener.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
}
@Override
protected void onDestroy() {
super.onDestroy();
if (mReactInstanceManager != null) {
mReactInstanceManager.onHostDestroy(this);
}
// if (mReactRootView != null) {
// mReactRootView.unmountReactApplication();
// // mReactRootView = null;
// }
removeEvent();
}
public void updatePage() {
if (mReactInstanceManager != null) {
mReactInstanceManager.onHostDestroy(this);
mReactInstanceManager = null;
QtalkServiceRNViewInstanceManager.mReactInstanceManager = null;
}
if (mReactRootView != null) {
mReactRootView.unmountReactApplication();
mReactRootView = null;
}
mReactRootView = new ReactRootView(this);
startRNApplicationWithBundle(getExtendBundle());
setContentView(mReactRootView);
}
@Override
public void onBackPressed() {
if (mReactInstanceManager != null) {
mReactInstanceManager.onBackPressed();
} else {
super.onBackPressed();
}
}
@Override
protected void onPause() {
super.onPause();
if (mReactInstanceManager != null) {
mReactInstanceManager.onHostPause();
}
}
@Override
protected void onResume() {
super.onResume();
if (mReactInstanceManager != null) {
mReactInstanceManager.onHostResume(this, new DefaultHardwareBackBtnHandler() {
@Override
public void invokeDefaultOnBackPressed() {
finish();
}
});
}
}
private void addEvent() {
ConnectionUtil.getInstance().addEvent(this, QtalkEvent.RN_UPDATE);
ConnectionUtil.getInstance().addEvent(this, QtalkEvent.UPDATE_TRIP);
}
private void removeEvent() {
ConnectionUtil.getInstance().removeEvent(this, QtalkEvent.RN_UPDATE);
ConnectionUtil.getInstance().removeEvent(this, QtalkEvent.UPDATE_TRIP);
}
@Override
public void invokeDefaultOnBackPressed() {
onBackPressed();
}
private void sendEvent(ReactContext reactContext, String eventName, @Nullable WritableMap params) {
try {
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.clreplaced).emit(eventName, params);
} catch (Exception _ex) {
// null bridge
}
}
@Override
public void didReceivedNotification(String key, Object... args) {
switch(key) {
case QtalkEvent.RN_UPDATE:
updatePage();
break;
case QtalkEvent.UPDATE_TRIP:
// 请求最新的好友
WritableNativeMap map = new WritableNativeMap();
sendEvent(mReactInstanceManager.getCurrentReactContext(), "QIM_RN_Will_Show", map);
// clearBridge();
break;
}
}
@Override
public void responsePermission(int requestCode, boolean granted) {
if (requestCode == PERMISSION_REQUIRE) {
if (!granted) {
Toast.makeText(this, "没有日历权限,Qtalk无法同步日程到系统日历", Toast.LENGTH_LONG).show();
// finish();
return;
}
}
}
}
18
Source : ReactContextBuilder.java
with MIT License
from joltup
with MIT License
from joltup
public clreplaced ReactContextBuilder {
private Context parentContext;
private JSBundleLoader jsBundleLoader;
private DevSupportManager devSupportManager;
private ReactInstanceManager instanceManager;
private ArrayList<ReactPackage> reactPackages;
public ReactContextBuilder(Context context) {
this.parentContext = context;
SoLoader.init(context, /* native exopackage */
false);
}
public ReactContextBuilder setJSBundleLoader(JSBundleLoader jsBundleLoader) {
this.jsBundleLoader = jsBundleLoader;
return this;
}
public ReactContextBuilder setDevSupportManager(DevSupportManager devSupportManager) {
this.devSupportManager = devSupportManager;
return this;
}
public ReactContextBuilder setReactInstanceManager(ReactInstanceManager manager) {
this.instanceManager = manager;
return this;
}
public ReactContextBuilder setReactPackages(ArrayList<ReactPackage> reactPackages) {
this.reactPackages = reactPackages;
return this;
}
private JavaScriptExecutorFactory getJSExecutorFactory() {
try {
String appName = Uri.encode(parentContext.getPackageName());
String deviceName = Uri.encode(getFriendlyDeviceName());
// If JSC is included, use it as normal
SoLoader.loadLibrary("jscexecutor");
return new JSCExecutorFactory(appName, deviceName);
} catch (UnsatisfiedLinkError jscE) {
// Otherwise use Hermes
return new HermesExecutorFactory();
}
}
public ReactApplicationContext build() throws Exception {
JavaScriptExecutor jsExecutor = getJSExecutorFactory().create();
// fresh new react context
final ReactApplicationContext reactContext = new ReactApplicationContext(parentContext);
if (devSupportManager != null) {
reactContext.setNativeModuleCallExceptionHandler(devSupportManager);
}
// load native modules
NativeModuleRegistryBuilder nativeRegistryBuilder = new NativeModuleRegistryBuilder(reactContext, this.instanceManager);
addNativeModules(nativeRegistryBuilder);
CatalystInstanceImpl.Builder catalystInstanceBuilder = new CatalystInstanceImpl.Builder().setReactQueueConfigurationSpec(ReactQueueConfigurationSpec.createDefault()).setJSExecutor(jsExecutor).setRegistry(nativeRegistryBuilder.build()).setJSBundleLoader(jsBundleLoader).setNativeModuleCallExceptionHandler(devSupportManager != null ? devSupportManager : createNativeModuleExceptionHandler());
final CatalystInstance catalystInstance;
catalystInstance = catalystInstanceBuilder.build();
catalystInstance.getReactQueueConfiguration().getJSQueueThread().callOnQueue(new Callable<Object>() {
@Override
public Object call() throws Exception {
try {
reactContext.initializeWithInstance(catalystInstance);
catalystInstance.runJSBundle();
} catch (Exception e) {
e.printStackTrace();
devSupportManager.handleException(e);
}
return null;
}
}).get();
catalystInstance.getReactQueueConfiguration().getUIQueueThread().callOnQueue(new Callable<Object>() {
@Override
public Object call() throws Exception {
try {
catalystInstance.initialize();
reactContext.onHostResume(null);
} catch (Exception e) {
e.printStackTrace();
devSupportManager.handleException(e);
}
return null;
}
}).get();
return reactContext;
}
private NativeModuleCallExceptionHandler createNativeModuleExceptionHandler() {
return new NativeModuleCallExceptionHandler() {
@Override
public void handleException(Exception e) {
throw new RuntimeException(e);
}
};
}
private void addNativeModules(NativeModuleRegistryBuilder nativeRegistryBuilder) {
for (int i = 0; i < reactPackages.size(); i++) {
ReactPackage reactPackage = reactPackages.get(i);
nativeRegistryBuilder.processPackage(reactPackage);
}
}
}
18
Source : ReactActivity.java
with MIT License
from bevkoski
with MIT License
from bevkoski
public clreplaced ReactActivity extends Activity implements DefaultHardwareBackBtnHandler {
private static final String REACT_MODULE_NAME = "TheNativeParts";
private ReactRootView mReactRootView;
private ReactInstanceManager mReactInstanceManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
List<ReactPackage> packages = new ArrayList<>();
packages.add(new MainReactPackage());
packages.add(new CommunicationPackage());
packages.add(new CounterViewPackage());
mReactRootView = new ReactRootView(ReactActivity.this);
mReactInstanceManager = ReactInstanceManager.builder().setApplication(getApplication()).setBundlereplacedetName("index.android.bundle").setJSMainModulePath("index.android").addPackages(packages).setUseDeveloperSupport(BuildConfig.DEBUG).setInitialLifecycleState(LifecycleState.RESUMED).build();
mReactRootView.startReactApplication(mReactInstanceManager, REACT_MODULE_NAME, null);
setContentView(mReactRootView);
}
@Override
protected void onPause() {
super.onPause();
if (mReactInstanceManager != null) {
mReactInstanceManager.onHostPause(ReactActivity.this);
}
}
@Override
protected void onResume() {
super.onResume();
if (mReactInstanceManager != null) {
mReactInstanceManager.onHostResume(ReactActivity.this, ReactActivity.this);
}
}
@Override
protected void onDestroy() {
super.onDestroy();
if (mReactInstanceManager != null) {
mReactInstanceManager.onHostDestroy(ReactActivity.this);
}
if (mReactRootView != null) {
mReactRootView.unmountReactApplication();
}
}
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_MENU && mReactInstanceManager != null) {
mReactInstanceManager.showDevOptionsDialog();
return true;
}
return super.onKeyUp(keyCode, event);
}
@Override
public void onBackPressed() {
if (mReactInstanceManager != null) {
mReactInstanceManager.onBackPressed();
} else {
super.onBackPressed();
}
}
@Override
public void invokeDefaultOnBackPressed() {
super.onBackPressed();
}
}
18
Source : NotificationsMessagingService.java
with MIT License
from b8ne
with MIT License
from b8ne
public clreplaced NotificationsMessagingService {
private static String notificationEvent = "notification";
private static ReactContext context;
private static ReactInstanceManager reactInstanceManager;
public static void read(final ReactInstanceManager reactInstanceManager, Activity reactActivity) {
Intent intent = reactActivity.getIntent();
final WritableMap map = new WritableNativeMap();
boolean launchedFromHistory = intent != null ? (intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0 : false;
Bundle extras = intent.getExtras();
if (!launchedFromHistory & extras != null) {
WritableMap payload = Arguments.createMap();
for (String key : extras.keySet()) {
Object value = extras.get(key);
payload.putString(key, value.toString());
}
map.putMap("data", payload);
if (payload != null) {
// We need to run this on the main thread, as the React code replacedumes that is true.
// Namely, DevServerHelper constructs a Handler() without a Looper, which triggers:
// "Can't create handler inside thread that has not called Looper.prepare()"
Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() {
public void run() {
// Construct and load our normal React JS code data
// ReactInstanceManager reactInstanceManager = ((ReactApplication) getApplication()).getReactNativeHost().getReactInstanceManager();
ReactContext context = reactInstanceManager.getCurrentReactContext();
// If it's constructed, send a notification
if (context != null) {
context.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.clreplaced).emit(notificationEvent, map);
} else {
// Otherwise wait for construction, then send the notification
reactInstanceManager.addReactInstanceEventListener(new ReactInstanceManager.ReactInstanceEventListener() {
public void onReactContextInitialized(ReactContext context) {
context.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.clreplaced).emit(notificationEvent, map);
}
});
if (!reactInstanceManager.hreplacedtartedCreatingInitialContext()) {
// Construct it in the background
reactInstanceManager.createReactContextInBackground();
}
}
}
});
}
}
}
}
18
Source : ReactAwareActivity.java
with MIT License
from airbnb
with MIT License
from airbnb
public abstract clreplaced ReactAwareActivity extends AppCompatActivity implements ReactAwareActivityFacade, DefaultHardwareBackBtnHandler {
private DoubleTapReloadRecognizer mDoubleTapReloadRecognizer = new DoubleTapReloadRecognizer();
ReactNavigationCoordinator reactNavigationCoordinator = ReactNavigationCoordinator.sharedInstance;
ReactInstanceManager reactInstanceManager = reactNavigationCoordinator.getReactInstanceManager();
@Override
protected void onPause() {
reactInstanceManager.onHostPause(this);
super.onPause();
}
@Override
protected void onResume() {
super.onResume();
reactInstanceManager.onHostResume(this, this);
}
@Override
public void invokeDefaultOnBackPressed() {
onBackPressed();
}
/**
* Schedules the shared element transition to be started immediately after the shared element has been measured and laid out within the activity's
* view hierarchy. Some common places where it might make sense to call this method are:
* <p>
* (1) Inside a Fragment's onCreateView() method (if the shared element lives inside a Fragment hosted by the called Activity).
* <p>
* (2) Inside a Glide Callback object (if you need to wait for Glide to asynchronously load/scale a bitmap before the transition can begin).
*/
public void scheduleStartPostponedTransition() {
getWindow().getDecorView().getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
getWindow().getDecorView().getViewTreeObserver().removeOnPreDrawListener(this);
supportStartPostponedEnterTransition();
return true;
}
});
}
boolean supportIsDestroyed() {
return AndroidVersion.isAtLeastJellyBeanMR1() && isDestroyed();
}
boolean isSuccessfullyInitialized() {
return reactNavigationCoordinator.isSuccessfullyInitialized();
}
NavigationImplementation getImplementation() {
return reactNavigationCoordinator.getImplementation();
}
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (/* BuildConfig.DEBUG && */
keyCode == KeyEvent.KEYCODE_MENU) {
// TODO(lmr): disable this in prod
reactInstanceManager.getDevSupportManager().showDevOptionsDialog();
return true;
}
if (keyCode == 0) {
// this is the "backtick"
// TODO(lmr): disable this in prod
reactInstanceManager.getDevSupportManager().showDevOptionsDialog();
return true;
}
if (mDoubleTapReloadRecognizer.didDoubleTapR(keyCode, getCurrentFocus())) {
reactInstanceManager.getDevSupportManager().handleReloadJS();
}
return super.onKeyUp(keyCode, event);
}
}
17
Source : MainApplication.java
with MIT License
from zoontek
with MIT License
from zoontek
/**
* 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 clreplaced that initializes Flipper,
since Flipper library is not available in release mode
*/
Clreplaced<?> aClreplaced = Clreplaced.forName("com.rnlocalizeexample.ReactNativeFlipper");
aClreplaced.getMethod("initializeFlipper", Context.clreplaced, ReactInstanceManager.clreplaced).invoke(null, context, reactInstanceManager);
} catch (ClreplacedNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
17
Source : MainApplication.java
with MIT License
from zoontek
with MIT License
from zoontek
/**
* 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 clreplaced that initializes Flipper,
since Flipper library is not available in release mode
*/
Clreplaced<?> aClreplaced = Clreplaced.forName("com.rndevmenuexample.ReactNativeFlipper");
aClreplaced.getMethod("initializeFlipper", Context.clreplaced, ReactInstanceManager.clreplaced).invoke(null, context, reactInstanceManager);
} catch (ClreplacedNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
17
Source : MainApplication.java
with MIT License
from zoontek
with MIT License
from zoontek
/**
* 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 clreplaced that initializes Flipper,
since Flipper library is not available in release mode
*/
Clreplaced<?> aClreplaced = Clreplaced.forName("com.rnbootsplashexample.ReactNativeFlipper");
aClreplaced.getMethod("initializeFlipper", Context.clreplaced, ReactInstanceManager.clreplaced).invoke(null, context, reactInstanceManager);
} catch (ClreplacedNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
17
Source : MainApplication.java
with MIT License
from WrathChaos
with MIT License
from WrathChaos
/**
* 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 clreplaced that initializes Flipper,
since Flipper library is not available in release mode
*/
Clreplaced<?> aClreplaced = Clreplaced.forName("com.example.ReactNativeFlipper");
aClreplaced.getMethod("initializeFlipper", Context.clreplaced, ReactInstanceManager.clreplaced).invoke(null, context, reactInstanceManager);
} catch (ClreplacedNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
17
Source : MainApplication.java
with MIT License
from wix-incubator
with MIT License
from wix-incubator
/**
* 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 clreplaced that initializes Flipper,
since Flipper library is not available in release mode
*/
Clreplaced<?> aClreplaced = Clreplaced.forName("com.reactnativewixengine.ReactNativeFlipper");
aClreplaced.getMethod("initializeFlipper", Context.clreplaced, ReactInstanceManager.clreplaced).invoke(null, context, reactInstanceManager);
} catch (ClreplacedNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
17
Source : MainApplication.java
with MIT License
from walterholohan
with MIT License
from walterholohan
/**
* Loads Flipper in React Native templates.
*
* @param context
*/
private static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
if (BuildConfig.DEBUG) {
try {
/*
We use reflection here to pick up the clreplaced that initializes Flipper,
since Flipper library is not available in release mode
*/
Clreplaced<?> aClreplaced = Clreplaced.forName("com.reactnativecrispchatsdkExample.ReactNativeFlipper");
aClreplaced.getMethod("initializeFlipper", Context.clreplaced, ReactInstanceManager.clreplaced).invoke(null, context, reactInstanceManager);
} catch (ClreplacedNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
17
Source : MainApplication.java
with MIT License
from uiwjs
with MIT License
from uiwjs
/**
* 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 clreplaced that initializes Flipper,
since Flipper library is not available in release mode
*/
Clreplaced<?> aClreplaced = Clreplaced.forName("com.uiwjs.example.geolocation.ReactNativeFlipper");
aClreplaced.getMethod("initializeFlipper", Context.clreplaced, ReactInstanceManager.clreplaced).invoke(null, context, reactInstanceManager);
} catch (ClreplacedNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
17
Source : MainApplication.java
with MIT License
from tscharke
with MIT License
from tscharke
/**
* 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 clreplaced that initializes Flipper,
since Flipper library is not available in release mode
*/
Clreplaced<?> aClreplaced = Clreplaced.forName("com.rndiffapp.ReactNativeFlipper");
aClreplaced.getMethod("initializeFlipper", Context.clreplaced, ReactInstanceManager.clreplaced).invoke(null, context, reactInstanceManager);
} catch (ClreplacedNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
17
Source : MainApplication.java
with MIT License
from TheLartians
with MIT License
from TheLartians
/**
* 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 clreplaced that initializes Flipper,
since Flipper library is not available in release mode
*/
Clreplaced<?> aClreplaced = Clreplaced.forName("com.showcase.ReactNativeFlipper");
aClreplaced.getMethod("initializeFlipper", Context.clreplaced, ReactInstanceManager.clreplaced).invoke(null, context, reactInstanceManager);
} catch (ClreplacedNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
17
Source : MainApplication.java
with MIT License
from thebergamo
with MIT License
from thebergamo
/**
* 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 clreplaced that initializes Flipper,
since Flipper library is not available in release mode
*/
Clreplaced<?> aClreplaced = Clreplaced.forName("com.rnfbsdkexample.ReactNativeFlipper");
aClreplaced.getMethod("initializeFlipper", Context.clreplaced, ReactInstanceManager.clreplaced).invoke(null, context, reactInstanceManager);
} catch (ClreplacedNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
17
Source : MainApplication.java
with MIT License
from techsnitch
with MIT License
from techsnitch
/**
* 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 clreplaced that initializes Flipper,
since Flipper library is not available in release mode
*/
Clreplaced<?> aClreplaced = Clreplaced.forName("com.teleconfmvp.ReactNativeFlipper");
aClreplaced.getMethod("initializeFlipper", Context.clreplaced, ReactInstanceManager.clreplaced).invoke(null, context, reactInstanceManager);
} catch (ClreplacedNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
17
Source : MainApplication.java
with MIT License
from sparkfabrik
with MIT License
from sparkfabrik
/**
* Loads Flipper in React Native templates.
*
* @param context
*/
private static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
if (BuildConfig.DEBUG) {
try {
/*
We use reflection here to pick up the clreplaced that initializes Flipper,
since Flipper library is not available in release mode
*/
Clreplaced<?> aClreplaced = Clreplaced.forName("com.sparkfabrikreactnativeidfaaaidExample.ReactNativeFlipper");
aClreplaced.getMethod("initializeFlipper", Context.clreplaced, ReactInstanceManager.clreplaced).invoke(null, context, reactInstanceManager);
} catch (ClreplacedNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
17
Source : ScriptLoadUtil.java
with MIT License
from smallnew
with MIT License
from smallnew
public static void recreateReactContextInBackgroundInner(ReactInstanceManager manager) {
try {
// recreateReactContextInBackground replace this
Method method = ReactInstanceManager.clreplaced.getDeclaredMethod("recreateReactContextInBackgroundInner");
method.setAccessible(true);
method.invoke(manager);
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
17
Source : ScriptLoadUtil.java
with MIT License
from smallnew
with MIT License
from smallnew
public static void moveToResumedLifecycleState(ReactInstanceManager manager, boolean force) {
try {
Method method = ReactInstanceManager.clreplaced.getDeclaredMethod("moveToResumedLifecycleState", boolean.clreplaced);
method.setAccessible(true);
method.invoke(manager, force);
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
17
Source : MainApplication.java
with Apache License 2.0
from skrafft
with Apache License 2.0
from skrafft
/**
* 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 clreplaced that initializes Flipper,
since Flipper library is not available in release mode
*/
Clreplaced<?> aClreplaced = Clreplaced.forName("com.exemple.ReactNativeFlipper");
aClreplaced.getMethod("initializeFlipper", Context.clreplaced, ReactInstanceManager.clreplaced).invoke(null, context, reactInstanceManager);
} catch (ClreplacedNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
17
Source : MainApplication.java
with MIT License
from skb1129
with MIT License
from skb1129
/**
* Loads Flipper in React Native templates.
*
* @param context
*/
private static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
if (BuildConfig.DEBUG) {
try {
/*
We use reflection here to pick up the clreplaced that initializes Flipper,
since Flipper library is not available in release mode
*/
Clreplaced<?> aClreplaced = Clreplaced.forName("com.reactnativechangeiconExample.ReactNativeFlipper");
aClreplaced.getMethod("initializeFlipper", Context.clreplaced, ReactInstanceManager.clreplaced).invoke(null, context, reactInstanceManager);
} catch (ClreplacedNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
17
Source : MainApplication.java
with Apache License 2.0
from Shajeel-Afzal
with Apache License 2.0
from Shajeel-Afzal
/**
* 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 clreplaced that initializes Flipper,
since Flipper library is not available in release mode
*/
Clreplaced<?> aClreplaced = Clreplaced.forName("com.counterapp.ReactNativeFlipper");
aClreplaced.getMethod("initializeFlipper", Context.clreplaced, ReactInstanceManager.clreplaced).invoke(null, context, reactInstanceManager);
} catch (ClreplacedNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
17
Source : MainApplication.java
with Apache License 2.0
from Shajeel-Afzal
with Apache License 2.0
from Shajeel-Afzal
/**
* 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 clreplaced that initializes Flipper,
since Flipper library is not available in release mode
*/
Clreplaced<?> aClreplaced = Clreplaced.forName("com.hello_world.ReactNativeFlipper");
aClreplaced.getMethod("initializeFlipper", Context.clreplaced, ReactInstanceManager.clreplaced).invoke(null, context, reactInstanceManager);
} catch (ClreplacedNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
17
Source : MainApplication.java
with Apache License 2.0
from Shajeel-Afzal
with Apache License 2.0
from Shajeel-Afzal
/**
* 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 clreplaced that initializes Flipper,
since Flipper library is not available in release mode
*/
Clreplaced<?> aClreplaced = Clreplaced.forName("com.sixsep.ReactNativeFlipper");
aClreplaced.getMethod("initializeFlipper", Context.clreplaced, ReactInstanceManager.clreplaced).invoke(null, context, reactInstanceManager);
} catch (ClreplacedNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
17
Source : MainApplication.java
with MIT License
from safaiyeh
with MIT License
from safaiyeh
/**
* Loads Flipper in React Native templates.
*
* @param context
*/
private static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
if (BuildConfig.DEBUG) {
try {
/*
We use reflection here to pick up the clreplaced that initializes Flipper,
since Flipper library is not available in release mode
*/
Clreplaced<?> aClreplaced = Clreplaced.forName("com.reactnativeappreviewExample.ReactNativeFlipper");
aClreplaced.getMethod("initializeFlipper", Context.clreplaced, ReactInstanceManager.clreplaced).invoke(null, context, reactInstanceManager);
} catch (ClreplacedNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
17
Source : MainApplication.java
with MIT License
from rumax
with MIT License
from rumax
/**
* 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 clreplaced that initializes Flipper,
since Flipper library is not available in release mode
*/
Clreplaced<?> aClreplaced = Clreplaced.forName("com.demo.ReactNativeFlipper");
aClreplaced.getMethod("initializeFlipper", Context.clreplaced, ReactInstanceManager.clreplaced).invoke(null, context, reactInstanceManager);
} catch (ClreplacedNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
17
Source : MainApplication.java
with MIT License
from reason-react-native
with MIT License
from reason-react-native
/**
* 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 clreplaced that initializes Flipper,
since Flipper library is not available in release mode
*/
Clreplaced<?> aClreplaced = Clreplaced.forName("com.projectname.ReactNativeFlipper");
aClreplaced.getMethod("initializeFlipper", Context.clreplaced, ReactInstanceManager.clreplaced).invoke(null, context, reactInstanceManager);
} catch (ClreplacedNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
17
Source : MainApplication.java
with Apache License 2.0
from react-native-webrtc-kit
with Apache License 2.0
from react-native-webrtc-kit
/**
* 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 clreplaced that initializes Flipper,
since Flipper library is not available in release mode
*/
Clreplaced<?> aClreplaced = Clreplaced.forName("com.touchstone.ReactNativeFlipper");
aClreplaced.getMethod("initializeFlipper", Context.clreplaced, ReactInstanceManager.clreplaced).invoke(null, context, reactInstanceManager);
} catch (ClreplacedNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
17
Source : MainApplication.java
with MIT License
from react-native-progress-view
with MIT License
from react-native-progress-view
/**
* Loads Flipper in React Native templates.
*
* @param context
*/
private static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
if (BuildConfig.DEBUG) {
try {
/*
* We use reflection here to pick up the clreplaced that initializes Flipper, since
* Flipper library is not available in release mode
*/
Clreplaced<?> aClreplaced = Clreplaced.forName("com.androidprogressbar.ReactNativeFlipper");
aClreplaced.getMethod("initializeFlipper", Context.clreplaced).invoke(null, context, reactInstanceManager);
} catch (ClreplacedNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
17
Source : MainApplication.java
with MIT License
from react-native-community
with MIT License
from react-native-community
/**
* 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 clreplaced that initializes Flipper,
since Flipper library is not available in release mode
*/
Clreplaced<?> aClreplaced = Clreplaced.forName("com.helloworld.ReactNativeFlipper");
aClreplaced.getMethod("initializeFlipper", Context.clreplaced, ReactInstanceManager.clreplaced).invoke(null, context, reactInstanceManager);
} catch (ClreplacedNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
17
Source : MainApplication.java
with MIT License
from Rapsssito
with MIT License
from Rapsssito
/**
* 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 clreplaced that initializes Flipper,
since Flipper library is not available in release mode
*/
Clreplaced<?> aClreplaced = Clreplaced.forName("com.tcpsockets.ReactNativeFlipper");
aClreplaced.getMethod("initializeFlipper", Context.clreplaced, ReactInstanceManager.clreplaced).invoke(null, context, reactInstanceManager);
} catch (ClreplacedNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
See More Examples