mirror of
https://github.com/status-im/react-native.git
synced 2025-02-10 08:26:23 +00:00
Add the onNewIntent listener to React Native Android
Reviewed By: foghina Differential Revision: D3475896 fbshipit-source-id: d8e5d7734974132307a85d21e4c1602327a479fa
This commit is contained in:
parent
93a1244144
commit
2fc0f4041e
@ -69,8 +69,6 @@ import com.facebook.react.uimanager.ViewManager;
|
|||||||
import com.facebook.soloader.SoLoader;
|
import com.facebook.soloader.SoLoader;
|
||||||
import com.facebook.systrace.Systrace;
|
import com.facebook.systrace.Systrace;
|
||||||
|
|
||||||
import static com.facebook.react.bridge.ReactMarkerConstants.BUILD_JS_MODULE_CONFIG_END;
|
|
||||||
import static com.facebook.react.bridge.ReactMarkerConstants.BUILD_JS_MODULE_CONFIG_START;
|
|
||||||
import static com.facebook.react.bridge.ReactMarkerConstants.BUILD_NATIVE_MODULE_REGISTRY_END;
|
import static com.facebook.react.bridge.ReactMarkerConstants.BUILD_NATIVE_MODULE_REGISTRY_END;
|
||||||
import static com.facebook.react.bridge.ReactMarkerConstants.BUILD_NATIVE_MODULE_REGISTRY_START;
|
import static com.facebook.react.bridge.ReactMarkerConstants.BUILD_NATIVE_MODULE_REGISTRY_START;
|
||||||
import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_CATALYST_INSTANCE_END;
|
import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_CATALYST_INSTANCE_END;
|
||||||
@ -480,6 +478,8 @@ import static com.facebook.react.bridge.ReactMarkerConstants.RUN_JS_BUNDLE_START
|
|||||||
Assertions.assertNotNull(mCurrentReactContext).getNativeModule(DeviceEventManagerModule.class);
|
Assertions.assertNotNull(mCurrentReactContext).getNativeModule(DeviceEventManagerModule.class);
|
||||||
deviceEventManagerModule.emitNewIntentReceived(uri);
|
deviceEventManagerModule.emitNewIntentReceived(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mCurrentReactContext.onNewIntent(mCurrentActivity, intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -519,7 +519,6 @@ import static com.facebook.react.bridge.ReactMarkerConstants.RUN_JS_BUNDLE_START
|
|||||||
public void onHostResume(Activity activity, DefaultHardwareBackBtnHandler defaultBackButtonImpl) {
|
public void onHostResume(Activity activity, DefaultHardwareBackBtnHandler defaultBackButtonImpl) {
|
||||||
UiThreadUtil.assertOnUiThread();
|
UiThreadUtil.assertOnUiThread();
|
||||||
|
|
||||||
|
|
||||||
mDefaultBackButtonImpl = defaultBackButtonImpl;
|
mDefaultBackButtonImpl = defaultBackButtonImpl;
|
||||||
if (mUseDeveloperSupport) {
|
if (mUseDeveloperSupport) {
|
||||||
mDevSupportManager.setDevSupportEnabled(true);
|
mDevSupportManager.setDevSupportEnabled(true);
|
||||||
@ -852,7 +851,6 @@ import static com.facebook.react.bridge.ReactMarkerConstants.RUN_JS_BUNDLE_START
|
|||||||
ReactMarker.logMarker(BUILD_NATIVE_MODULE_REGISTRY_END);
|
ReactMarker.logMarker(BUILD_NATIVE_MODULE_REGISTRY_END);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NativeModuleCallExceptionHandler exceptionHandler = mNativeModuleCallExceptionHandler != null
|
NativeModuleCallExceptionHandler exceptionHandler = mNativeModuleCallExceptionHandler != null
|
||||||
? mNativeModuleCallExceptionHandler
|
? mNativeModuleCallExceptionHandler
|
||||||
: mDevSupportManager;
|
: mDevSupportManager;
|
||||||
|
@ -463,6 +463,8 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE;
|
|||||||
Assertions.assertNotNull(mCurrentReactContext).getNativeModule(DeviceEventManagerModule.class);
|
Assertions.assertNotNull(mCurrentReactContext).getNativeModule(DeviceEventManagerModule.class);
|
||||||
deviceEventManagerModule.emitNewIntentReceived(uri);
|
deviceEventManagerModule.emitNewIntentReceived(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mCurrentReactContext.onNewIntent(mCurrentActivity, intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -862,7 +864,6 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE;
|
|||||||
catalystInstance.addBridgeIdleDebugListener(mBridgeIdleDebugListener);
|
catalystInstance.addBridgeIdleDebugListener(mBridgeIdleDebugListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ReactMarker.logMarker(RUN_JS_BUNDLE_START);
|
ReactMarker.logMarker(RUN_JS_BUNDLE_START);
|
||||||
try {
|
try {
|
||||||
catalystInstance.getReactQueueConfiguration().getJSQueueThread().callOnQueue(
|
catalystInstance.getReactQueueConfiguration().getJSQueueThread().callOnQueue(
|
||||||
|
@ -13,4 +13,9 @@ public interface ActivityEventListener {
|
|||||||
* Called when host (activity/service) receives an {@link Activity#onActivityResult} call.
|
* Called when host (activity/service) receives an {@link Activity#onActivityResult} call.
|
||||||
*/
|
*/
|
||||||
void onActivityResult(int requestCode, int resultCode, Intent data);
|
void onActivityResult(int requestCode, int resultCode, Intent data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a new intent is passed to the activity
|
||||||
|
*/
|
||||||
|
void onNewIntent(Intent intent);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
// Copyright 2004-present Facebook. All Rights Reserved.
|
||||||
|
|
||||||
|
package com.facebook.react.bridge;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An empty implementation of {@link ActivityEventListener}
|
||||||
|
*/
|
||||||
|
public class BaseActivityEventListener implements ActivityEventListener {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityResult(int requestCode, int resultCode, Intent data) { }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNewIntent(Intent intent) { }
|
||||||
|
}
|
@ -162,6 +162,14 @@ public class ReactContext extends ContextWrapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onNewIntent(@Nullable Activity activity, Intent intent) {
|
||||||
|
UiThreadUtil.assertOnUiThread();
|
||||||
|
mCurrentActivity = new WeakReference(activity);
|
||||||
|
for (ActivityEventListener listener : mActivityEventListeners) {
|
||||||
|
listener.onNewIntent(intent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should be called by the hosting Fragment in {@link Fragment#onPause}
|
* Should be called by the hosting Fragment in {@link Fragment#onPause}
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user