diff --git a/RNTester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterActivity.java b/RNTester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterActivity.java index 8a90535223f..a5e1f0a3523 100644 --- a/RNTester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterActivity.java +++ b/RNTester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterActivity.java @@ -1,18 +1,14 @@ /** * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * + *
This source code is licensed under the MIT license found in the LICENSE file in the root + * directory of this source tree. */ - package com.facebook.react.uiapp; import android.os.Bundle; - import com.facebook.react.ReactActivity; import com.facebook.react.ReactActivityDelegate; - import javax.annotation.Nullable; public class RNTesterActivity extends ReactActivity { @@ -31,10 +27,11 @@ public class RNTesterActivity extends ReactActivity { // Get remote param before calling super which uses it Bundle bundle = mActivity.getIntent().getExtras(); if (bundle != null && bundle.containsKey(PARAM_ROUTE)) { - String routeUri = new StringBuilder("rntester://example/") - .append(bundle.getString(PARAM_ROUTE)) - .append("Example") - .toString(); + String routeUri = + new StringBuilder("rntester://example/") + .append(bundle.getString(PARAM_ROUTE)) + .append("Example") + .toString(); mInitialProps = new Bundle(); mInitialProps.putString("exampleFromAppetizeParams", routeUri); } diff --git a/RNTester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java b/RNTester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java index a6601115ad9..bbfbd557417 100644 --- a/RNTester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java +++ b/RNTester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java @@ -1,49 +1,44 @@ /** * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * + *
This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.uiapp;
import android.app.Application;
-
import com.facebook.react.BuildConfig;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.react.views.text.ReactFontManager;
-
import java.util.Arrays;
import java.util.List;
public class RNTesterApplication extends Application implements ReactApplication {
- private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
- @Override
- public String getJSMainModuleName() {
- return "RNTester/js/RNTesterApp.android";
- }
+ private final ReactNativeHost mReactNativeHost =
+ new ReactNativeHost(this) {
+ @Override
+ public String getJSMainModuleName() {
+ return "RNTester/js/RNTesterApp.android";
+ }
- @Override
- public String getBundleAssetName() {
- return "RNTesterApp.android.bundle";
- }
+ @Override
+ public String getBundleAssetName() {
+ return "RNTesterApp.android.bundle";
+ }
- @Override
- public boolean getUseDeveloperSupport() {
- return BuildConfig.DEBUG;
- }
+ @Override
+ public boolean getUseDeveloperSupport() {
+ return BuildConfig.DEBUG;
+ }
- @Override
- public List This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.testing;
+import com.facebook.react.bridge.BaseJavaModule;
+import com.facebook.react.bridge.JavaScriptModule;
+import com.facebook.react.bridge.ReactMethod;
import java.util.ArrayList;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
-import com.facebook.react.bridge.BaseJavaModule;
-import com.facebook.react.bridge.ReactMethod;
-import com.facebook.react.bridge.JavaScriptModule;
-import com.facebook.react.testing.ReactInstanceSpecForTest;
-import com.facebook.react.testing.ReactAppInstrumentationTestCase;
-
/**
- * Shared by {@link ReactScrollViewTestCase} and {@link ReactHorizontalScrollViewTestCase}.
- * See also ScrollViewTestModule.js
+ * Shared by {@link ReactScrollViewTestCase} and {@link ReactHorizontalScrollViewTestCase}. See also
+ * ScrollViewTestModule.js
*/
public abstract class AbstractScrollViewTestCase extends ReactAppInstrumentationTestCase {
@@ -38,8 +34,7 @@ public abstract class AbstractScrollViewTestCase extends ReactAppInstrumentation
@Override
protected ReactInstanceSpecForTest createReactInstanceSpecForTest() {
mScrollListenerModule = new ScrollListenerModule();
- return super.createReactInstanceSpecForTest()
- .addNativeModule(mScrollListenerModule);
+ return super.createReactInstanceSpecForTest().addNativeModule(mScrollListenerModule);
}
// See ScrollViewListenerModule.js
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/AssertModule.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/AssertModule.java
index 16ac3f8182c..d5a4f5376fd 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/AssertModule.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/AssertModule.java
@@ -1,23 +1,19 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.testing;
-import javax.annotation.Nullable;
-
-import com.facebook.react.bridge.BaseJavaModule;
-import com.facebook.react.bridge.ReactMethod;
-
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
-/**
- * NativeModule for tests that allows assertions from JS to propagate to Java.
- */
+import com.facebook.react.bridge.BaseJavaModule;
+import com.facebook.react.bridge.ReactMethod;
+import javax.annotation.Nullable;
+
+/** NativeModule for tests that allows assertions from JS to propagate to Java. */
public class AssertModule extends BaseJavaModule {
private boolean mGotSuccess;
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/FakeAsyncLocalStorage.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/FakeAsyncLocalStorage.java
index 34e1c2f19ff..762d37f316a 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/FakeAsyncLocalStorage.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/FakeAsyncLocalStorage.java
@@ -1,10 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.testing;
import com.facebook.react.bridge.Arguments;
@@ -14,12 +13,11 @@ import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.WritableMap;
-/**
- * Dummy implementation of storage module, used for testing
- */
+/** Dummy implementation of storage module, used for testing */
public final class FakeAsyncLocalStorage extends BaseJavaModule {
private static WritableMap errorMessage;
+
static {
errorMessage = Arguments.createMap();
errorMessage.putString("message", "Fake Async Local Storage");
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/FakeWebSocketModule.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/FakeWebSocketModule.java
index 52d0467e4a0..0800f24b45e 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/FakeWebSocketModule.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/FakeWebSocketModule.java
@@ -1,22 +1,18 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.testing;
-import javax.annotation.Nullable;
-
import com.facebook.react.bridge.BaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
+import javax.annotation.Nullable;
-/**
- * Dummy implementation of storage module, used for testing
- */
+/** Dummy implementation of storage module, used for testing */
public final class FakeWebSocketModule extends BaseJavaModule {
@Override
@@ -31,21 +27,17 @@ public final class FakeWebSocketModule extends BaseJavaModule {
@ReactMethod
public void connect(
- final String url,
- @Nullable final ReadableArray protocols,
- @Nullable final ReadableMap headers,
- final int id) {
- }
+ final String url,
+ @Nullable final ReadableArray protocols,
+ @Nullable final ReadableMap headers,
+ final int id) {}
@ReactMethod
- public void close(int code, String reason, int id) {
- }
+ public void close(int code, String reason, int id) {}
@ReactMethod
- public void send(String message, int id) {
- }
+ public void send(String message, int id) {}
@ReactMethod
- public void sendBinary(String base64String, int id) {
- }
+ public void sendBinary(String base64String, int id) {}
}
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/InstanceSpecForTestPackage.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/InstanceSpecForTestPackage.java
index 4e939977167..8edc2a6be5c 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/InstanceSpecForTestPackage.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/InstanceSpecForTestPackage.java
@@ -1,21 +1,16 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.testing;
-import java.util.List;
-
-import android.view.View;
-
+import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
-import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.uimanager.ViewManager;
-import com.facebook.react.ReactPackage;
+import java.util.List;
/**
* This class wraps {@class ReactInstanceSpecForTest} in {@class ReactPackage} interface.
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/IntRecordingModule.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/IntRecordingModule.java
index 1650611acb9..f29f9d54c62 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/IntRecordingModule.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/IntRecordingModule.java
@@ -1,23 +1,21 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.testing;
+import com.facebook.react.bridge.BaseJavaModule;
+import com.facebook.react.bridge.ReactMethod;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-import com.facebook.react.bridge.BaseJavaModule;
-import com.facebook.react.bridge.ReactMethod;
-
/**
- * Native module provides single method {@link #record} which records its single int argument
- * in calls array
+ * Native module provides single method {@link #record} which records its single int argument in
+ * calls array
*/
public class IntRecordingModule extends BaseJavaModule {
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/JSIntegrationTestChecker.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/JSIntegrationTestChecker.java
index 478cd0d2ea2..32a855a64a9 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/JSIntegrationTestChecker.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/JSIntegrationTestChecker.java
@@ -1,26 +1,23 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.testing;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
import com.facebook.react.bridge.BaseJavaModule;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.ReactMethod;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
/**
- * This class is used to verify that some JS integration tests have completed successfully.
- * The JS integration tests can be started from a ReactIntegrationTestCase and upon
- * finishing successfully the {@link JSIntegrationTestChecker#testDone()} method will be called.
- * To verify if the test has completed successfully, call {#link JSIntegrationTestChecker#await()}
- * to wait for the test to run, and {#link JSIntegrationTestChecker#isTestDone()} to check if it
- * completed successfully.
+ * This class is used to verify that some JS integration tests have completed successfully. The JS
+ * integration tests can be started from a ReactIntegrationTestCase and upon finishing successfully
+ * the {@link JSIntegrationTestChecker#testDone()} method will be called. To verify if the test has
+ * completed successfully, call {#link JSIntegrationTestChecker#await()} to wait for the test to
+ * run, and {#link JSIntegrationTestChecker#isTestDone()} to check if it completed successfully.
*/
public class JSIntegrationTestChecker extends BaseJavaModule {
@@ -41,8 +38,7 @@ public class JSIntegrationTestChecker extends BaseJavaModule {
}
@ReactMethod
- public void verifySnapshot(Callback callback) {
- }
+ public void verifySnapshot(Callback callback) {}
public boolean await(long ms) {
try {
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/MultipleFailureException.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/MultipleFailureException.java
index 533fa1aa49a..93ca3008879 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/MultipleFailureException.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/MultipleFailureException.java
@@ -1,10 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.testing;
import java.io.PrintWriter;
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactAppInstrumentationTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactAppInstrumentationTestCase.java
index 18f35707ac5..2c3c5866514 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactAppInstrumentationTestCase.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactAppInstrumentationTestCase.java
@@ -1,10 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.testing;
import android.content.Intent;
@@ -19,11 +18,9 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;
-/**
- * Base class for instrumentation tests that runs React based react application in UI mode
- */
-public abstract class ReactAppInstrumentationTestCase extends
- ActivityInstrumentationTestCase2 Finally,{@link ReactInstanceManagerBuilder#build()} will create instance of {@link
+ * ReactInstanceManager}. And also will set {@link ReactContext#mCurrentActivity}.
*/
builder.setCurrentActivity(this);
builder
@@ -250,11 +247,15 @@ public class ReactAppTestActivity extends FragmentActivity
@Override
public UIManager get() {
ViewManagerRegistry viewManagerRegistry =
- new ViewManagerRegistry(
- mReactInstanceManager.getOrCreateViewManagers(reactApplicationContext));
+ new ViewManagerRegistry(
+ mReactInstanceManager.getOrCreateViewManagers(
+ reactApplicationContext));
FabricUIManagerFactory factory = spec.getFabricUIManagerFactory();
- return factory != null ? factory.getFabricUIManager(reactApplicationContext, viewManagerRegistry, jsContext) : null;
+ return factory != null
+ ? factory.getFabricUIManager(
+ reactApplicationContext, viewManagerRegistry, jsContext)
+ : null;
}
};
}
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactInstanceSpecForTest.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactInstanceSpecForTest.java
index f26917dc3de..6b92b88e73c 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactInstanceSpecForTest.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactInstanceSpecForTest.java
@@ -53,7 +53,8 @@ public class ReactInstanceSpecForTest {
return this;
}
- public ReactInstanceSpecForTest setFabricUIManagerFactory(@Nullable FabricUIManagerFactory fabricUIManagerFactory) {
+ public ReactInstanceSpecForTest setFabricUIManagerFactory(
+ @Nullable FabricUIManagerFactory fabricUIManagerFactory) {
mFabricUIManagerFactory = fabricUIManagerFactory;
return this;
}
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactIntegrationTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactIntegrationTestCase.java
index af5f72a0098..73d57e00181 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactIntegrationTestCase.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactIntegrationTestCase.java
@@ -1,24 +1,16 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.testing;
-import com.facebook.react.modules.core.ReactChoreographer;
-import javax.annotation.Nullable;
+import static org.mockito.Mockito.mock;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.Semaphore;
-import java.util.concurrent.TimeUnit;
-
-import android.app.Application;
import android.test.AndroidTestCase;
import android.view.View;
import android.view.ViewGroup;
-
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.BaseJavaModule;
import com.facebook.react.bridge.CatalystInstance;
@@ -29,26 +21,27 @@ import com.facebook.react.bridge.SoftAssertions;
import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.common.futures.SimpleSettableFuture;
import com.facebook.react.devsupport.interfaces.DevSupportManager;
+import com.facebook.react.modules.core.ReactChoreographer;
import com.facebook.react.modules.core.Timing;
import com.facebook.react.testing.idledetection.ReactBridgeIdleSignaler;
import com.facebook.react.testing.idledetection.ReactIdleDetectionUtil;
import com.facebook.soloader.SoLoader;
-
-import static org.mockito.Mockito.mock;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+import javax.annotation.Nullable;
/**
- * Use this class for writing integration tests of catalyst. This class will run all JNI call
- * within separate android looper, thus you don't need to care about starting your own looper.
+ * Use this class for writing integration tests of catalyst. This class will run all JNI call within
+ * separate android looper, thus you don't need to care about starting your own looper.
*
- * Keep in mind that all JS remote method calls and script load calls are asynchronous and you
+ * Keep in mind that all JS remote method calls and script load calls are asynchronous and you
* should not expect them to return results immediately.
*
- * In order to write catalyst integration:
- * 1) Make {@link ReactIntegrationTestCase} a base class of your test case
- * 2) Use {@link ReactTestHelper#catalystInstanceBuilder()}
- * instead of {@link com.facebook.react.bridge.CatalystInstanceImpl.Builder} to build catalyst
- * instance for testing purposes
- *
+ * In order to write catalyst integration: 1) Make {@link ReactIntegrationTestCase} a base class
+ * of your test case 2) Use {@link ReactTestHelper#catalystInstanceBuilder()} instead of {@link
+ * com.facebook.react.bridge.CatalystInstanceImpl.Builder} to build catalyst instance for testing
+ * purposes
*/
public abstract class ReactIntegrationTestCase extends AndroidTestCase {
@@ -76,22 +69,23 @@ public abstract class ReactIntegrationTestCase extends AndroidTestCase {
mInstance = null;
final SimpleSettableFuture This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.testing;
import com.facebook.react.modules.debug.interfaces.DeveloperSettings;
@@ -47,7 +46,5 @@ public class ReactSettingsForTests implements DeveloperSettings {
}
@Override
- public void setRemoteJSDebugEnabled(boolean remoteJSDebugEnabled) {
-
- }
+ public void setRemoteJSDebugEnabled(boolean remoteJSDebugEnabled) {}
}
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactTestAppShell.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactTestAppShell.java
index 8ec1cf9ab0e..095442752f2 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactTestAppShell.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactTestAppShell.java
@@ -1,10 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.testing;
import com.facebook.buck.android.support.exopackage.ApplicationLike;
@@ -15,9 +14,9 @@ import com.facebook.soloader.SoLoader;
/**
* Application class for the Catalyst Launcher to allow it to work as an exopackage.
*
- * Any app-specific code that should run before secondary dex files are loaded
- * (like setting up crash reporting) should go in onBaseContextAttached.
- * Anything that should run after secondary dex should go in CatalystApplicationImpl.onCreate.
+ * Any app-specific code that should run before secondary dex files are loaded (like setting up
+ * crash reporting) should go in onBaseContextAttached. Anything that should run after secondary dex
+ * should go in CatalystApplicationImpl.onCreate.
*/
public class ReactTestAppShell extends ExopackageApplication This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.testing;
import android.app.Application;
-
import com.facebook.buck.android.support.exopackage.DefaultApplicationLike;
public class ReactTestApplicationImpl extends DefaultApplicationLike {
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactTestFactory.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactTestFactory.java
index f22dbb7b206..4abf69c9685 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactTestFactory.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactTestFactory.java
@@ -1,14 +1,12 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.testing;
import android.content.Context;
-
import com.facebook.react.ReactInstanceManagerBuilder;
import com.facebook.react.bridge.CatalystInstance;
import com.facebook.react.bridge.NativeModule;
@@ -16,10 +14,13 @@ import com.facebook.react.bridge.NativeModule;
public interface ReactTestFactory {
interface ReactInstanceEasyBuilder {
ReactInstanceEasyBuilder setContext(Context context);
+
ReactInstanceEasyBuilder addNativeModule(NativeModule module);
+
CatalystInstance build();
}
ReactInstanceEasyBuilder getCatalystInstanceBuilder();
+
ReactInstanceManagerBuilder getReactInstanceManagerBuilder();
}
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactTestHelper.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactTestHelper.java
index 360d10b7bc7..a737f543c04 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactTestHelper.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactTestHelper.java
@@ -1,23 +1,15 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.testing;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import javax.annotation.Nullable;
-
-import android.app.Instrumentation;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
-
+import com.android.internal.util.Predicate;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.NativeModuleRegistryBuilder;
import com.facebook.react.R;
@@ -25,19 +17,20 @@ import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactInstanceManagerBuilder;
import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.CatalystInstance;
-import com.facebook.react.bridge.JavaScriptModuleRegistry;
-import com.facebook.react.bridge.NativeModule;
-import com.facebook.react.bridge.NativeModuleCallExceptionHandler;
-import com.facebook.react.bridge.ReactApplicationContext;
-import com.facebook.react.bridge.WritableNativeMap;
-import com.facebook.react.bridge.queue.ReactQueueConfigurationSpec;
import com.facebook.react.bridge.CatalystInstanceImpl;
import com.facebook.react.bridge.JSBundleLoader;
import com.facebook.react.bridge.JavaScriptExecutor;
+import com.facebook.react.bridge.NativeModule;
+import com.facebook.react.bridge.NativeModuleCallExceptionHandler;
+import com.facebook.react.bridge.ReactApplicationContext;
+import com.facebook.react.bridge.queue.ReactQueueConfigurationSpec;
import com.facebook.react.jscexecutor.JSCExecutorFactory;
import com.facebook.react.modules.core.ReactChoreographer;
import com.facebook.react.uimanager.ViewManager;
-import com.android.internal.util.Predicate;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import javax.annotation.Nullable;
public class ReactTestHelper {
private static class DefaultReactTestFactory implements ReactTestFactory {
@@ -56,31 +49,30 @@ public class ReactTestHelper {
@Override
public ReactInstanceEasyBuilder addNativeModule(final NativeModule nativeModule) {
if (mNativeModuleRegistryBuilder == null) {
- mNativeModuleRegistryBuilder = new NativeModuleRegistryBuilder(
- (ReactApplicationContext) mContext,
- null);
+ mNativeModuleRegistryBuilder =
+ new NativeModuleRegistryBuilder((ReactApplicationContext) mContext, null);
}
Assertions.assertNotNull(nativeModule);
- mNativeModuleRegistryBuilder.processPackage(new ReactPackage(){
- @Override
- public List This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.testing;
-import javax.annotation.Nullable;
-
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.os.Looper;
import android.widget.FrameLayout;
+import javax.annotation.Nullable;
/**
* A FrameLayout that allows you to access the result of the last time its hierarchy was drawn. It
@@ -35,8 +33,8 @@ public class ScreenshotingFrameLayout extends FrameLayout {
if (mBitmap == null) {
mBitmap = createNewBitmap(canvas);
mCanvas.setBitmap(mBitmap);
- } else if (mBitmap.getWidth() != canvas.getWidth() ||
- mBitmap.getHeight() != canvas.getHeight()) {
+ } else if (mBitmap.getWidth() != canvas.getWidth()
+ || mBitmap.getHeight() != canvas.getHeight()) {
mBitmap.recycle();
mBitmap = createNewBitmap(canvas);
mCanvas.setBitmap(mBitmap);
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/SingleTouchGestureGenerator.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/SingleTouchGestureGenerator.java
index 8340977b73e..056740a7de2 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/SingleTouchGestureGenerator.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/SingleTouchGestureGenerator.java
@@ -1,28 +1,26 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.testing;
import android.os.SystemClock;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
-
import com.facebook.react.testing.idledetection.IdleWaiter;
/**
* Provides methods for generating touch events and dispatching them directly to a given view.
* Events scenarios are based on {@link android.test.TouchUtils} but they get gets dispatched
- * directly through the view hierarchy using {@link View#dispatchTouchEvent} method instead of
- * using instrumentation API.
- *
- * All the events for a gesture are dispatched immediately which makes tests run very fast.
- * The eventTime for each event is still set correctly. Android's gesture recognizers check
- * eventTime in order to figure out gesture speed, and therefore scroll vs fling is recognized.
+ * directly through the view hierarchy using {@link View#dispatchTouchEvent} method instead of using
+ * instrumentation API.
+ *
+ * All the events for a gesture are dispatched immediately which makes tests run very fast. The
+ * eventTime for each event is still set correctly. Android's gesture recognizers check eventTime in
+ * order to figure out gesture speed, and therefore scroll vs fling is recognized.
*/
public class SingleTouchGestureGenerator {
@@ -44,10 +42,7 @@ public class SingleTouchGestureGenerator {
}
private SingleTouchGestureGenerator dispatchEvent(
- final int action,
- final float x,
- final float y,
- long eventTime) {
+ final int action, final float x, final float y, long eventTime) {
mEventTime = eventTime;
if (action == MotionEvent.ACTION_DOWN) {
mLastDownTime = eventTime;
@@ -90,10 +85,7 @@ public class SingleTouchGestureGenerator {
}
private SingleTouchGestureGenerator dispatchDelayedEvent(
- int action,
- float x,
- float y,
- long delay) {
+ int action, float x, float y, long delay) {
return dispatchEvent(action, x, y, mEventTime + delay);
}
@@ -127,12 +119,7 @@ public class SingleTouchGestureGenerator {
}
public SingleTouchGestureGenerator drag(
- float fromX,
- float fromY,
- float toX,
- float toY,
- int stepCount,
- long totalDelay) {
+ float fromX, float fromY, float toX, float toY, int stepCount, long totalDelay) {
float xStep = (toX - fromX) / stepCount;
float yStep = (toY - fromY) / stepCount;
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/StringRecordingModule.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/StringRecordingModule.java
index 9103a265ec5..fb4db8e8eaa 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/StringRecordingModule.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/StringRecordingModule.java
@@ -1,21 +1,19 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.testing;
-import java.util.ArrayList;
-import java.util.List;
-
import com.facebook.react.bridge.BaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
+import java.util.ArrayList;
+import java.util.List;
/**
- * Native module provides single method {@link #record} which records its single string argument
- * in calls array
+ * Native module provides single method {@link #record} which records its single string argument in
+ * calls array
*/
public class StringRecordingModule extends BaseJavaModule {
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/idledetection/IdleWaiter.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/idledetection/IdleWaiter.java
index 958e15dfec6..6f224683614 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/idledetection/IdleWaiter.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/idledetection/IdleWaiter.java
@@ -1,15 +1,12 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.testing.idledetection;
-/**
- * Interface for something that knows how to wait for bridge and UI idle.
- */
+/** Interface for something that knows how to wait for bridge and UI idle. */
public interface IdleWaiter {
void waitForBridgeAndUIIdle();
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/idledetection/ReactBridgeIdleSignaler.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/idledetection/ReactBridgeIdleSignaler.java
index 72aa0d46c4b..6599fdc1cf3 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/idledetection/ReactBridgeIdleSignaler.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/idledetection/ReactBridgeIdleSignaler.java
@@ -1,17 +1,15 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.testing.idledetection;
+import com.facebook.react.bridge.NotThreadSafeBridgeIdleDebugListener;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
-import com.facebook.react.bridge.NotThreadSafeBridgeIdleDebugListener;
-
/**
* Utility class that uses {@link NotThreadSafeBridgeIdleDebugListener} interface to allow callers
* to wait for the bridge to be idle.
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/idledetection/ReactIdleDetectionUtil.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/idledetection/ReactIdleDetectionUtil.java
index 4410d808a2f..3b54f975acf 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/idledetection/ReactIdleDetectionUtil.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/idledetection/ReactIdleDetectionUtil.java
@@ -1,10 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.testing.idledetection;
import com.facebook.react.bridge.ReactContext;
@@ -16,104 +15,102 @@ public class ReactIdleDetectionUtil {
* bridge to become idle, then waiting for the UI thread to become idle, then checking if the
* bridge is idle again (if the bridge was idle before and is still idle after running the UI
* thread to idle, then there are no more events to process in either place).
- * Also waits for any Choreographer callbacks to run after the initial sync since things like
+ * UI events are initiated from Choreographer callbacks.
*/
public static void waitForBridgeAndUIIdle(
- ReactBridgeIdleSignaler idleSignaler,
- final ReactContext reactContext,
- long timeoutMs) {
+ ReactBridgeIdleSignaler idleSignaler, final ReactContext reactContext, long timeoutMs) {
- return ;
+ return;
// TODO: re-enable after cleanup of android-x migration
-// UiThreadUtil.assertNotOnUiThread();
-//
-// long startTime = SystemClock.uptimeMillis();
-// waitInner(idleSignaler, timeoutMs);
-//
-// long timeToWait = Math.max(1, timeoutMs - (SystemClock.uptimeMillis() - startTime));
-// waitForChoreographer(timeToWait);
-// waitForJSIdle(reactContext);
-//
-// timeToWait = Math.max(1, timeoutMs - (SystemClock.uptimeMillis() - startTime));
-// waitInner(idleSignaler, timeToWait);
-// timeToWait = Math.max(1, timeoutMs - (SystemClock.uptimeMillis() - startTime));
-// waitForChoreographer(timeToWait);
+ // UiThreadUtil.assertNotOnUiThread();
+ //
+ // long startTime = SystemClock.uptimeMillis();
+ // waitInner(idleSignaler, timeoutMs);
+ //
+ // long timeToWait = Math.max(1, timeoutMs - (SystemClock.uptimeMillis() - startTime));
+ // waitForChoreographer(timeToWait);
+ // waitForJSIdle(reactContext);
+ //
+ // timeToWait = Math.max(1, timeoutMs - (SystemClock.uptimeMillis() - startTime));
+ // waitInner(idleSignaler, timeToWait);
+ // timeToWait = Math.max(1, timeoutMs - (SystemClock.uptimeMillis() - startTime));
+ // waitForChoreographer(timeToWait);
}
-// private static void waitForChoreographer(long timeToWait) {
-// final int waitFrameCount = 2;
-// final CountDownLatch latch = new CountDownLatch(1);
-// UiThreadUtil.runOnUiThread(
-// new Runnable() {
-// @Override
-// public void run() {
-// final ChoreographerCompat choreographerCompat = ChoreographerCompat.getInstance();
-// choreographerCompat.postFrameCallback(
-// new ChoreographerCompat.FrameCallback() {
-//
-// private int frameCount = 0;
-//
-// @Override
-// public void doFrame(long frameTimeNanos) {
-// frameCount++;
-// if (frameCount == waitFrameCount) {
-// latch.countDown();
-// } else {
-// choreographerCompat.postFrameCallback(this);
-// }
-// }
-// });
-// }
-// });
-// try {
-// if (!latch.await(timeToWait, TimeUnit.MILLISECONDS)) {
-// throw new RuntimeException("Timed out waiting for Choreographer");
-// }
-// } catch (Exception e) {
-// throw new RuntimeException(e);
-// }
-// }
-//
-// private static void waitForJSIdle(ReactContext reactContext) {
-// if (!reactContext.hasActiveCatalystInstance()) {
-// return;
-// }
-// final CountDownLatch latch = new CountDownLatch(1);
-//
-// reactContext.runOnJSQueueThread(
-// new Runnable() {
-// @Override
-// public void run() {
-// latch.countDown();
-// }
-// });
-//
-// try {
-// if (!latch.await(5000, TimeUnit.MILLISECONDS)) {
-// throw new RuntimeException("Timed out waiting for JS thread");
-// }
-// } catch (Exception e) {
-// throw new RuntimeException(e);
-// }
-// }
-//
-// private static void waitInner(ReactBridgeIdleSignaler idleSignaler, long timeToWait) {
-// // TODO gets broken in gradle, do we need it?
-// Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
-// long startTime = SystemClock.uptimeMillis();
-// boolean bridgeWasIdle = false;
-// while (SystemClock.uptimeMillis() - startTime < timeToWait) {
-// boolean bridgeIsIdle = idleSignaler.isBridgeIdle();
-// if (bridgeIsIdle && bridgeWasIdle) {
-// return;
-// }
-// bridgeWasIdle = bridgeIsIdle;
-// long newTimeToWait = Math.max(1, timeToWait - (SystemClock.uptimeMillis() - startTime));
-// idleSignaler.waitForIdle(newTimeToWait);
-// instrumentation.waitForIdleSync();
-// }
-// throw new RuntimeException("Timed out waiting for bridge and UI idle!");
-// }
+ // private static void waitForChoreographer(long timeToWait) {
+ // final int waitFrameCount = 2;
+ // final CountDownLatch latch = new CountDownLatch(1);
+ // UiThreadUtil.runOnUiThread(
+ // new Runnable() {
+ // @Override
+ // public void run() {
+ // final ChoreographerCompat choreographerCompat = ChoreographerCompat.getInstance();
+ // choreographerCompat.postFrameCallback(
+ // new ChoreographerCompat.FrameCallback() {
+ //
+ // private int frameCount = 0;
+ //
+ // @Override
+ // public void doFrame(long frameTimeNanos) {
+ // frameCount++;
+ // if (frameCount == waitFrameCount) {
+ // latch.countDown();
+ // } else {
+ // choreographerCompat.postFrameCallback(this);
+ // }
+ // }
+ // });
+ // }
+ // });
+ // try {
+ // if (!latch.await(timeToWait, TimeUnit.MILLISECONDS)) {
+ // throw new RuntimeException("Timed out waiting for Choreographer");
+ // }
+ // } catch (Exception e) {
+ // throw new RuntimeException(e);
+ // }
+ // }
+ //
+ // private static void waitForJSIdle(ReactContext reactContext) {
+ // if (!reactContext.hasActiveCatalystInstance()) {
+ // return;
+ // }
+ // final CountDownLatch latch = new CountDownLatch(1);
+ //
+ // reactContext.runOnJSQueueThread(
+ // new Runnable() {
+ // @Override
+ // public void run() {
+ // latch.countDown();
+ // }
+ // });
+ //
+ // try {
+ // if (!latch.await(5000, TimeUnit.MILLISECONDS)) {
+ // throw new RuntimeException("Timed out waiting for JS thread");
+ // }
+ // } catch (Exception e) {
+ // throw new RuntimeException(e);
+ // }
+ // }
+ //
+ // private static void waitInner(ReactBridgeIdleSignaler idleSignaler, long timeToWait) {
+ // // TODO gets broken in gradle, do we need it?
+ // Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
+ // long startTime = SystemClock.uptimeMillis();
+ // boolean bridgeWasIdle = false;
+ // while (SystemClock.uptimeMillis() - startTime < timeToWait) {
+ // boolean bridgeIsIdle = idleSignaler.isBridgeIdle();
+ // if (bridgeIsIdle && bridgeWasIdle) {
+ // return;
+ // }
+ // bridgeWasIdle = bridgeIsIdle;
+ // long newTimeToWait = Math.max(1, timeToWait - (SystemClock.uptimeMillis() - startTime));
+ // idleSignaler.waitForIdle(newTimeToWait);
+ // instrumentation.waitForIdleSync();
+ // }
+ // throw new RuntimeException("Timed out waiting for bridge and UI idle!");
+ // }
}
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/network/NetworkRecordingModuleMock.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/network/NetworkRecordingModuleMock.java
index 64bb99301d7..09babeee703 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/network/NetworkRecordingModuleMock.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/network/NetworkRecordingModuleMock.java
@@ -1,14 +1,11 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.testing.network;
-import javax.annotation.Nullable;
-
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.ReactApplicationContext;
@@ -20,6 +17,7 @@ import com.facebook.react.bridge.WritableArray;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.modules.core.DeviceEventManagerModule;
+import javax.annotation.Nullable;
/**
* Mock Networking module that records last request received by {@link #sendRequest} method and
@@ -70,10 +68,7 @@ public class NetworkRecordingModuleMock extends ReactContextBaseJavaModule {
}
private void fireReactCallback(
- Callback callback,
- int status,
- @Nullable String headers,
- @Nullable String body) {
+ Callback callback, int status, @Nullable String headers, @Nullable String body) {
callback.invoke(status, headers, body);
}
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/rule/ReactNativeTestRule.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/rule/ReactNativeTestRule.java
index c4bf721717e..0067f4220d3 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/rule/ReactNativeTestRule.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/rule/ReactNativeTestRule.java
@@ -6,16 +6,14 @@
package com.facebook.react.testing.rule;
import android.app.Activity;
-import android.os.Build;
-import androidx.test.rule.ActivityTestRule;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
+import androidx.test.rule.ActivityTestRule;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactPackage;
import com.facebook.react.ReactRootView;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.common.LifecycleState;
import com.facebook.react.shell.MainReactPackage;
-import com.facebook.react.testing.ReactInstanceSpecForTest;
import com.facebook.react.testing.ReactTestHelper;
import com.facebook.react.testing.idledetection.ReactBridgeIdleSignaler;
import com.facebook.react.testing.idledetection.ReactIdleDetectionUtil;
@@ -164,9 +162,7 @@ public class ReactNativeTestRule implements TestRule {
public void waitForIdleSync() {
ReactIdleDetectionUtil.waitForBridgeAndUIIdle(
- mBridgeIdleSignaler,
- mReactInstanceManager.getCurrentReactContext(),
- IDLE_TIMEOUT_MS);
+ mBridgeIdleSignaler, mReactInstanceManager.getCurrentReactContext(), IDLE_TIMEOUT_MS);
}
/** Returns the react view */
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/AnimatedTransformTest.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/AnimatedTransformTest.java
index f2ddc0d2e9e..0c6280c7d74 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/AnimatedTransformTest.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/AnimatedTransformTest.java
@@ -1,20 +1,16 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.tests;
import android.view.View;
-
-
-import com.facebook.react.testing.ReactInstanceSpecForTest;
-import com.facebook.react.testing.StringRecordingModule;
-import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.testing.ReactAppInstrumentationTestCase;
+import com.facebook.react.testing.ReactInstanceSpecForTest;
import com.facebook.react.testing.ReactTestHelper;
+import com.facebook.react.testing.StringRecordingModule;
/**
* Integration test for {@code removeClippedSubviews} property that verify correct scrollview
@@ -32,18 +28,16 @@ public class AnimatedTransformTest extends ReactAppInstrumentationTestCase {
@Override
protected ReactInstanceSpecForTest createReactInstanceSpecForTest() {
mStringRecordingModule = new StringRecordingModule();
- return super.createReactInstanceSpecForTest()
- .addNativeModule(mStringRecordingModule);
+ return super.createReactInstanceSpecForTest().addNativeModule(mStringRecordingModule);
}
public void testAnimatedRotation() {
waitForBridgeAndUIIdle();
- View button = ReactTestHelper.getViewWithReactTestId(
- getActivity().getRootView(),
- "TouchableOpacity");
+ View button =
+ ReactTestHelper.getViewWithReactTestId(getActivity().getRootView(), "TouchableOpacity");
- // Tap the button which triggers the animated transform containing the
+ // Tap the button which triggers the animated transform containing the
// rotation strings.
createGestureGenerator().startGesture(button).endGesture();
waitForBridgeAndUIIdle();
@@ -51,5 +45,4 @@ public class AnimatedTransformTest extends ReactAppInstrumentationTestCase {
// The previous cast error will prevent it from getting here
assertEquals(2, mStringRecordingModule.getCalls().size());
}
-
}
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystMeasureLayoutTest.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystMeasureLayoutTest.java
index a86805fb62c..274d1f94e8b 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystMeasureLayoutTest.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystMeasureLayoutTest.java
@@ -1,58 +1,54 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.tests;
-import com.facebook.react.testing.ReactInstanceSpecForTest;
import com.facebook.react.bridge.JavaScriptModule;
-import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.testing.AssertModule;
import com.facebook.react.testing.ReactAppInstrumentationTestCase;
+import com.facebook.react.testing.ReactInstanceSpecForTest;
+import com.facebook.react.uimanager.UIManagerModule;
/**
- * Tests for {@link UIManagerModule#measure}, {@link UIManagerModule#measureLayout}, and
- * {@link UIManagerModule#measureLayoutRelativeToParent}. Tests measurement for views in the
- * following hierarchy:
+ * Tests for {@link UIManagerModule#measure}, {@link UIManagerModule#measureLayout}, and {@link
+ * UIManagerModule#measureLayoutRelativeToParent}. Tests measurement for views in the following
+ * hierarchy:
*
- * +---------------------------------------------+
- * | A |
- * | |
- * | +-----------+ +---------+ |
- * | | B | | D | |
- * | | +---+ | | | |
- * | | | C | | | | |
- * | | | | | +---------+ |
- * | | +---+ | |
- * | +-----------+ |
- * | |
- * | |
- * | |
- * +---------------------------------------------+
+ * +---------------------------------------------+ | A | | | | +-----------+ +---------+ | | | B
+ * | | D | | | | +---+ | | | | | | | C | | | | | | | | | | +---------+ | | | +---+ | | |
+ * +-----------+ | | | | | | | +---------------------------------------------+
*
- * View locations and dimensions:
- * A - (0,0) to (500, 500) (500x500)
- * B - (50,80) to (250, 380) (200x300)
- * C - (150,150) to (200, 300) (50x150)
- * D - (400,100) to (450, 300) (50x200)
+ * View locations and dimensions: A - (0,0) to (500, 500) (500x500) B - (50,80) to (250, 380)
+ * (200x300) C - (150,150) to (200, 300) (50x150) D - (400,100) to (450, 300) (50x200)
*/
public class CatalystMeasureLayoutTest extends ReactAppInstrumentationTestCase {
private static interface MeasureLayoutTestModule extends JavaScriptModule {
public void verifyMeasureOnViewA();
+
public void verifyMeasureOnViewC();
+
public void verifyMeasureLayoutCRelativeToA();
+
public void verifyMeasureLayoutCRelativeToB();
+
public void verifyMeasureLayoutCRelativeToSelf();
+
public void verifyMeasureLayoutRelativeToParentOnViewA();
+
public void verifyMeasureLayoutRelativeToParentOnViewB();
+
public void verifyMeasureLayoutRelativeToParentOnViewC();
+
public void verifyMeasureLayoutDRelativeToB();
+
public void verifyMeasureLayoutNonExistentTag();
+
public void verifyMeasureLayoutNonExistentAncestor();
+
public void verifyMeasureLayoutRelativeToParentNonExistentTag();
}
@@ -73,8 +69,7 @@ public class CatalystMeasureLayoutTest extends ReactAppInstrumentationTestCase {
@Override
protected ReactInstanceSpecForTest createReactInstanceSpecForTest() {
mAssertModule = new AssertModule();
- return super.createReactInstanceSpecForTest()
- .addNativeModule(mAssertModule);
+ return super.createReactInstanceSpecForTest().addNativeModule(mAssertModule);
}
private void waitForBridgeIdleAndVerifyAsserts() {
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystMultitouchHandlingTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystMultitouchHandlingTestCase.java
index 9a18ca66cb5..7aae6556514 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystMultitouchHandlingTestCase.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystMultitouchHandlingTestCase.java
@@ -1,19 +1,16 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.tests;
-import java.util.List;
-
import android.view.MotionEvent;
-
-import com.facebook.react.testing.ReactInstanceSpecForTest;
import com.facebook.react.testing.ReactAppInstrumentationTestCase;
+import com.facebook.react.testing.ReactInstanceSpecForTest;
import com.facebook.react.testing.StringRecordingModule;
+import java.util.List;
/**
* Test case for verifying that multitouch events are directed to the React's view touch handlers
@@ -30,8 +27,7 @@ public class CatalystMultitouchHandlingTestCase extends ReactAppInstrumentationT
@Override
protected ReactInstanceSpecForTest createReactInstanceSpecForTest() {
- return new ReactInstanceSpecForTest()
- .addNativeModule(mRecordingModule);
+ return new ReactInstanceSpecForTest().addNativeModule(mRecordingModule);
}
/**
@@ -102,27 +98,41 @@ public class CatalystMultitouchHandlingTestCase extends ReactAppInstrumentationT
final int pointerCount,
final MotionEvent.PointerProperties[] pointerProps,
final MotionEvent.PointerCoords[] pointerCoords) {
- getRootView().post(
- new Runnable() {
- @Override
- public void run() {
- MotionEvent event =
- MotionEvent.obtain(start, when, action, pointerCount, pointerProps, pointerCoords, 0, 0, 1.0f, 1.0f, 0, 0, 0, 0);
- getRootView().dispatchTouchEvent(event);
- event.recycle();
- }
- });
+ getRootView()
+ .post(
+ new Runnable() {
+ @Override
+ public void run() {
+ MotionEvent event =
+ MotionEvent.obtain(
+ start,
+ when,
+ action,
+ pointerCount,
+ pointerProps,
+ pointerCoords,
+ 0,
+ 0,
+ 1.0f,
+ 1.0f,
+ 0,
+ 0,
+ 0,
+ 0);
+ getRootView().dispatchTouchEvent(event);
+ event.recycle();
+ }
+ });
getInstrumentation().waitForIdleSync();
}
/**
* This method "replay" multi-touch gesture recorded with modified TouchesHelper class that
- * generated this piece of code (see https://phabricator.fb.com/P19756940).
- * This is not intended to be copied/reused and once we need to have more multitouch gestures
- * in instrumentation tests we should either:
- * - implement nice generator similar to {@link SingleTouchGestureGenerator}
- * - implement gesture recorded that will record touch data using arbitrary format and then read
- * this recorded touch sequence during tests instead of generating code like this
+ * generated this piece of code (see https://phabricator.fb.com/P19756940). This is not intended
+ * to be copied/reused and once we need to have more multitouch gestures in instrumentation tests
+ * we should either: - implement nice generator similar to {@link SingleTouchGestureGenerator} -
+ * implement gesture recorded that will record touch data using arbitrary format and then read
+ * this recorded touch sequence during tests instead of generating code like this
*/
private void generateRecordedPinchTouchEvents() {
// START OF GENERATED CODE
@@ -149,7 +159,13 @@ public class CatalystMultitouchHandlingTestCase extends ReactAppInstrumentationT
pointerCoords[0] = createPointerCoords(267.0f, 346.0f);
pointerProps[1] = createPointerProps(1, 1);
pointerCoords[1] = createPointerCoords(225.0f, 542.0f);
- dispatchEvent(MotionEvent.ACTION_POINTER_DOWN | (1 << MotionEvent.ACTION_POINTER_INDEX_SHIFT), 446560605, 446560630, 2, pointerProps, pointerCoords);
+ dispatchEvent(
+ MotionEvent.ACTION_POINTER_DOWN | (1 << MotionEvent.ACTION_POINTER_INDEX_SHIFT),
+ 446560605,
+ 446560630,
+ 2,
+ pointerProps,
+ pointerCoords);
}
{
@@ -639,7 +655,13 @@ public class CatalystMultitouchHandlingTestCase extends ReactAppInstrumentationT
pointerCoords[0] = createPointerCoords(349.0f, 110.0f);
pointerProps[1] = createPointerProps(1, 1);
pointerCoords[1] = createPointerCoords(151.0f, 680.0f);
- dispatchEvent(MotionEvent.ACTION_POINTER_UP | (0 << MotionEvent.ACTION_POINTER_INDEX_SHIFT), 446560605, 446561443, 2, pointerProps, pointerCoords);
+ dispatchEvent(
+ MotionEvent.ACTION_POINTER_UP | (0 << MotionEvent.ACTION_POINTER_INDEX_SHIFT),
+ 446560605,
+ 446561443,
+ 2,
+ pointerProps,
+ pointerCoords);
}
{
@@ -651,5 +673,4 @@ public class CatalystMultitouchHandlingTestCase extends ReactAppInstrumentationT
}
// END OF GENERATED CODE
}
-
}
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJSToJavaParametersTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJSToJavaParametersTestCase.java
index 5631647bcd8..42d41c77f49 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJSToJavaParametersTestCase.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJSToJavaParametersTestCase.java
@@ -1,10 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.tests;
import com.facebook.react.bridge.BaseJavaModule;
@@ -44,35 +43,45 @@ import org.junit.Ignore;
/**
* Integration test to verify passing various types of parameters from JS to Java works
*
- * TODO: we should run these tests with isBlockingSynchronousMethod = true as well,
- * since they currently use a completely different codepath
+ * TODO: we should run these tests with isBlockingSynchronousMethod = true as well, since they
+ * currently use a completely different codepath
*/
@Ignore("Fix prop types and view managers.")
public class CatalystNativeJSToJavaParametersTestCase extends ReactIntegrationTestCase {
private interface TestJSToJavaParametersModule extends JavaScriptModule {
void returnBasicTypes();
+
void returnBoxedTypes();
+
void returnDynamicTypes();
void returnArrayWithBasicTypes();
+
void returnNestedArray();
+
void returnArrayWithMaps();
void returnMapWithBasicTypes();
+
void returnNestedMap();
+
void returnMapWithArrays();
void returnArrayWithStringDoubleIntMapArrayBooleanNull();
+
void returnMapWithStringDoubleIntMapArrayBooleanNull();
void returnMapForMerge1();
+
void returnMapForMerge2();
void returnMapWithMultibyteUTF8CharacterString();
+
void returnArrayWithMultibyteUTF8CharacterString();
void returnArrayWithLargeInts();
+
void returnMapWithLargeInts();
}
@@ -83,10 +92,8 @@ public class CatalystNativeJSToJavaParametersTestCase extends ReactIntegrationTe
protected void setUp() throws Exception {
super.setUp();
- List This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.tests;
import com.facebook.react.bridge.CatalystInstance;
@@ -28,9 +27,7 @@ import java.util.Arrays;
import java.util.List;
import org.junit.Ignore;
-/**
- * Test marshalling arguments from Java to JS to appropriate native classes.
- */
+/** Test marshalling arguments from Java to JS to appropriate native classes. */
@Ignore("Fix prop types and view managers.")
public class CatalystNativeJavaToJSArgumentsTestCase extends ReactIntegrationTestCase {
@@ -38,16 +35,21 @@ public class CatalystNativeJavaToJSArgumentsTestCase extends ReactIntegrationTes
void receiveBasicTypes(String s, double d, boolean b, String nullString);
void receiveArrayWithBasicTypes(WritableArray array);
+
void receiveNestedArray(WritableArray nestedArray);
+
void receiveArrayWithMaps(WritableArray arrayWithMaps);
void receiveMapWithBasicTypes(WritableMap map);
+
void receiveNestedMap(WritableMap nestedMap);
+
void receiveMapWithArrays(WritableMap mapWithArrays);
- void receiveMapAndArrayWithNullValues(
- WritableMap map,
- WritableArray array);
+
+ void receiveMapAndArrayWithNullValues(WritableMap map, WritableArray array);
+
void receiveMapWithMultibyteUTF8CharacterString(WritableMap map);
+
void receiveArrayWithMultibyteUTF8CharacterString(WritableArray array);
}
@@ -58,10 +60,8 @@ public class CatalystNativeJavaToJSArgumentsTestCase extends ReactIntegrationTes
protected void setUp() throws Exception {
super.setUp();
- List This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.tests;
import com.facebook.react.bridge.BaseJavaModule;
@@ -27,14 +26,13 @@ import com.facebook.react.uimanager.ViewManager;
import java.util.ArrayList;
import org.junit.Ignore;
-/**
- * Test marshalling return values from Java to JS
- */
+/** Test marshalling return values from Java to JS */
@Ignore("Fix prop types and view managers.")
public class CatalystNativeJavaToJSReturnValuesTestCase extends ReactIntegrationTestCase {
private interface TestJavaToJSReturnValuesModule extends JavaScriptModule {
void callMethod(String methodName, String expectedReturnType, String expectedJSON);
+
void triggerException();
}
@@ -110,19 +108,19 @@ public class CatalystNativeJavaToJSReturnValuesTestCase extends ReactIntegration
super.setUp();
final UIManagerModule mUIManager =
- new UIManagerModule(
- getContext(), new ArrayList This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.tests;
-import java.util.ArrayList;
-import java.util.List;
-
import android.content.Context;
-import javax.annotation.Nullable;
import android.widget.ScrollView;
-
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.testing.ReactAppInstrumentationTestCase;
import com.facebook.react.testing.ReactInstanceSpecForTest;
import com.facebook.react.uimanager.PixelUtil;
-import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.uimanager.ThemedReactContext;
+import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.views.view.ReactViewGroup;
import com.facebook.react.views.view.ReactViewManager;
-
+import java.util.ArrayList;
+import java.util.List;
+import javax.annotation.Nullable;
import org.junit.Assert;
-import org.junit.Ignore;
/**
* Integration test for {@code removeClippedSubviews} property that verify correct scrollview
@@ -34,9 +29,13 @@ public class CatalystSubviewsClippingTestCase extends ReactAppInstrumentationTes
private interface SubviewsClippingTestModule extends JavaScriptModule {
void renderClippingSample1();
+
void renderClippingSample2();
+
void renderScrollViewTest();
+
void renderUpdatingSample1(boolean update1, boolean update2);
+
void renderUpdatingSample2(boolean update);
}
@@ -49,78 +48,50 @@ public class CatalystSubviewsClippingTestCase extends ReactAppInstrumentationTes
@Override
protected ReactInstanceSpecForTest createReactInstanceSpecForTest() {
- return super.createReactInstanceSpecForTest()
- .addViewManager(new ClippableViewManager(mEvents));
+ return super.createReactInstanceSpecForTest().addViewManager(new ClippableViewManager(mEvents));
}
/**
- * In this test view are layout in a following way:
- * +-----------------------------+
- * | |
- * | +---------------------+ |
- * | | inner1 | |
- * | +---------------------+ |
- * | +-------------------------+ |
- * | | outer (clip=true) | |
- * | | +---------------------+ | |
- * | | | inner2 | | |
- * | | +---------------------+ | |
- * | | | |
- * | +-------------------------+ |
- * | +---------------------+ |
- * | | inner3 | |
- * | +---------------------+ |
- * | |
+ * In this test view are layout in a following way: +-----------------------------+ | | |
+ * +---------------------+ | | | inner1 | | | +---------------------+ | |
+ * +-------------------------+ | | | outer (clip=true) | | | | +---------------------+ | | | | |
+ * inner2 | | | | | +---------------------+ | | | | | | | +-------------------------+ | |
+ * +---------------------+ | | | inner3 | | | +---------------------+ | | |
* +-----------------------------+
*
- * We expect only outer and inner2 to be attached
+ * We expect only outer and inner2 to be attached
*/
public void XtestOneLevelClippingInView() throws Throwable {
mEvents.clear();
getReactContext().getJSModule(SubviewsClippingTestModule.class).renderClippingSample1();
waitForBridgeAndUIIdle();
- Assert.assertArrayEquals(new String[]{"Attach_outer", "Attach_inner2"}, mEvents.toArray());
+ Assert.assertArrayEquals(new String[] {"Attach_outer", "Attach_inner2"}, mEvents.toArray());
}
/**
- * In this test view are layout in a following way:
- * +-----------------------------+
- * | outer (clip=true) |
- * | |
- * | |
- * | |
- * | +-----------------------------+
- * | | complexInner (clip=true) |
- * | | +----------+ | +---------+ |
- * | | | inner1 | | | inner2 | |
- * | | | | | | | |
- * | | +----------+ | +---------+ |
- * +--------------+--------------+ |
- * | +----------+ +---------+ |
- * | | inner3 | | inner4 | |
- * | | | | | |
- * | +----------+ +---------+ |
- * | |
- * +-----------------------------+
+ * In this test view are layout in a following way: +-----------------------------+ | outer
+ * (clip=true) | | | | | | | | +-----------------------------+ | | complexInner (clip=true) | | |
+ * +----------+ | +---------+ | | | | inner1 | | | inner2 | | | | | | | | | | | | +----------+ |
+ * +---------+ | +--------------+--------------+ | | +----------+ +---------+ | | | inner3 | |
+ * inner4 | | | | | | | | | +----------+ +---------+ | | | +-----------------------------+
*
- * We expect outer, complexInner & inner1 to be attached
+ * We expect outer, complexInner & inner1 to be attached
*/
public void XtestTwoLevelClippingInView() throws Throwable {
mEvents.clear();
getReactContext().getJSModule(SubviewsClippingTestModule.class).renderClippingSample2();
waitForBridgeAndUIIdle();
Assert.assertArrayEquals(
- new String[]{"Attach_outer", "Attach_complexInner", "Attach_inner1"},
- mEvents.toArray());
+ new String[] {"Attach_outer", "Attach_complexInner", "Attach_inner1"}, mEvents.toArray());
}
/**
* This test verifies that we update clipped subviews appropriately when some of them gets
* re-layouted.
*
- * In this test scenario we render clipping view ("outer") with two subviews, one is outside and
- * clipped and one is inside (absolutely positioned). By updating view props we first change the
- * height of the first element so that it should intersect with clipping "outer" view. Then we
+ * In this test scenario we render clipping view ("outer") with two subviews, one is outside
+ * and clipped and one is inside (absolutely positioned). By updating view props we first change
+ * the height of the first element so that it should intersect with clipping "outer" view. Then we
* update top position of the second view so that is should go off screen.
*/
public void testClippingAfterLayoutInner() {
@@ -130,24 +101,24 @@ public class CatalystSubviewsClippingTestCase extends ReactAppInstrumentationTes
mEvents.clear();
subviewsClippingTestModule.renderUpdatingSample1(false, false);
waitForBridgeAndUIIdle();
- Assert.assertArrayEquals(new String[]{"Attach_outer", "Attach_inner2"}, mEvents.toArray());
+ Assert.assertArrayEquals(new String[] {"Attach_outer", "Attach_inner2"}, mEvents.toArray());
mEvents.clear();
subviewsClippingTestModule.renderUpdatingSample1(true, false);
waitForBridgeAndUIIdle();
- Assert.assertArrayEquals(new String[]{"Attach_inner1"}, mEvents.toArray());
+ Assert.assertArrayEquals(new String[] {"Attach_inner1"}, mEvents.toArray());
mEvents.clear();
subviewsClippingTestModule.renderUpdatingSample1(true, true);
waitForBridgeAndUIIdle();
- Assert.assertArrayEquals(new String[]{"Detach_inner2"}, mEvents.toArray());
+ Assert.assertArrayEquals(new String[] {"Detach_inner2"}, mEvents.toArray());
}
/**
* This test verifies that we update clipping views appropriately when parent view layout changes
* in a way that affects clipping.
*
- * In this test we render clipping view ("outer") set to be 100x100dp with inner view that is
+ * In this test we render clipping view ("outer") set to be 100x100dp with inner view that is
* absolutely positioned out of the clipping area of the parent view. Then we resize parent view
* so that inner view should be visible.
*/
@@ -158,12 +129,12 @@ public class CatalystSubviewsClippingTestCase extends ReactAppInstrumentationTes
mEvents.clear();
subviewsClippingTestModule.renderUpdatingSample2(false);
waitForBridgeAndUIIdle();
- Assert.assertArrayEquals(new String[]{"Attach_outer"}, mEvents.toArray());
+ Assert.assertArrayEquals(new String[] {"Attach_outer"}, mEvents.toArray());
mEvents.clear();
subviewsClippingTestModule.renderUpdatingSample2(true);
waitForBridgeAndUIIdle();
- Assert.assertArrayEquals(new String[]{"Attach_inner"}, mEvents.toArray());
+ Assert.assertArrayEquals(new String[] {"Attach_inner"}, mEvents.toArray());
}
public void testOneLevelClippingInScrollView() throws Throwable {
@@ -171,13 +142,13 @@ public class CatalystSubviewsClippingTestCase extends ReactAppInstrumentationTes
waitForBridgeAndUIIdle();
// Only 3 first views should be attached at the beginning
- Assert.assertArrayEquals(new String[]{"Attach_0", "Attach_1", "Attach_2"}, mEvents.toArray());
+ Assert.assertArrayEquals(new String[] {"Attach_0", "Attach_1", "Attach_2"}, mEvents.toArray());
mEvents.clear();
// We scroll down such that first view get out of the bounds, we expect the first view to be
// detached and 4th view to get attached
scrollToDpInUIThread(120);
- Assert.assertArrayEquals(new String[]{"Detach_0", "Attach_3"}, mEvents.toArray());
+ Assert.assertArrayEquals(new String[] {"Detach_0", "Attach_3"}, mEvents.toArray());
}
public void testTwoLevelClippingInScrollView() throws Throwable {
@@ -197,38 +168,38 @@ public class CatalystSubviewsClippingTestCase extends ReactAppInstrumentationTes
// Scroll a little bit so that "complex" view is visible, but it's inner views are not
scrollToDpInUIThread(complexViewOffset + 5);
- Assert.assertArrayEquals(new String[]{"Attach_C0"}, mEvents.toArray());
+ Assert.assertArrayEquals(new String[] {"Attach_C0"}, mEvents.toArray());
mEvents.clear();
// Step 3
// Scroll even more so that first subview of "complex" view is visible, view 1 will get off
// screen
scrollToDpInUIThread(complexViewOffset + 100);
- Assert.assertArrayEquals(new String[]{"Detach_1", "Attach_C0.1"}, mEvents.toArray());
+ Assert.assertArrayEquals(new String[] {"Detach_1", "Attach_C0.1"}, mEvents.toArray());
mEvents.clear();
// Step 4
// Scroll even more to reveal second subview of "complex" view
scrollToDpInUIThread(complexViewOffset + 150);
- Assert.assertArrayEquals(new String[]{"Attach_C0.2"}, mEvents.toArray());
+ Assert.assertArrayEquals(new String[] {"Attach_C0.2"}, mEvents.toArray());
mEvents.clear();
// Step 5
// Scroll back to previous position (Step 3), second view should get detached
scrollToDpInUIThread(complexViewOffset + 100);
- Assert.assertArrayEquals(new String[]{"Detach_C0.2"}, mEvents.toArray());
+ Assert.assertArrayEquals(new String[] {"Detach_C0.2"}, mEvents.toArray());
mEvents.clear();
// Step 6
// Scroll back to Step 2, complex view should be visible but all subviews should be detached
scrollToDpInUIThread(complexViewOffset + 5);
- Assert.assertArrayEquals(new String[]{"Attach_1", "Detach_C0.1"}, mEvents.toArray());
+ Assert.assertArrayEquals(new String[] {"Attach_1", "Detach_C0.1"}, mEvents.toArray());
mEvents.clear();
// Step 7
// Scroll back to Step 1, complex view should be gone
scrollToDpInUIThread(complexViewOffset);
- Assert.assertArrayEquals(new String[]{"Detach_C0"}, mEvents.toArray());
+ Assert.assertArrayEquals(new String[] {"Detach_C0"}, mEvents.toArray());
}
private void scrollToDpInUIThread(final int yPositionInDP) throws Throwable {
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystTouchBubblingTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystTouchBubblingTestCase.java
index 7b9a7f8431d..60dc3de87c8 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystTouchBubblingTestCase.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystTouchBubblingTestCase.java
@@ -1,51 +1,35 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.tests;
import android.view.View;
-
-import com.facebook.react.testing.ReactInstanceSpecForTest;
import com.facebook.react.testing.ReactAppInstrumentationTestCase;
+import com.facebook.react.testing.ReactInstanceSpecForTest;
import com.facebook.react.testing.SingleTouchGestureGenerator;
import com.facebook.react.testing.StringRecordingModule;
/**
- * This test is to verify that touch events bubbles up to the right handler. We emulate couple
- * of different gestures on top of the application reflecting following layout:
+ * This test is to verify that touch events bubbles up to the right handler. We emulate couple of
+ * different gestures on top of the application reflecting following layout:
*
- * +---------------------------------------------------------------------------------------+
- * | |
- * | +----------------------------------------------------------------------------------+ |
- * | | +-------------+ +----------------+ | |
- * | | | +---+ | | | | |
- * | | | | A | | | | | |
- * | | | +---+ | | C | | |
- * | | | {B} | | | | |
- * | | | | {D} | | | |
- * | | +-------------+ +----------------+ | |
- * | | | |
- * | | | |
- * | +----------------------------------------------------------------------------------+ |
- * |
- * | +----------------------------------------------------------------------------------+ |
- * | | | |
- * | | | |
- * | | | |
- * | | {E} | |
- * | | | |
- * | | | |
- * | +----------------------------------------------------------------------------------+ |
+ * +---------------------------------------------------------------------------------------+ | |
+ * | +----------------------------------------------------------------------------------+ | | |
+ * +-------------+ +----------------+ | | | | | +---+ | | | | | | | | | A | | | | | | | | | +---+ |
+ * | C | | | | | | {B} | | | | | | | | | {D} | | | | | | +-------------+ +----------------+ | | | |
+ * | | | | | | |
+ * +----------------------------------------------------------------------------------+ | | |
+ * +----------------------------------------------------------------------------------+ | | | | | |
+ * | | | | | | | | | {E} | | | | | | | | | | |
+ * +----------------------------------------------------------------------------------+ |
* +---------------------------------------------------------------------------------------+
*
- * Then in each test case we either tap the center of a particular view (from A to E) or we start
- * a gesture in one view and end it with another.
- * View with names in brackets (e.g. {D}) have touch handlers set whereas all other views are not
- * declared to handler touch events.
+ * Then in each test case we either tap the center of a particular view (from A to E) or we start
+ * a gesture in one view and end it with another. View with names in brackets (e.g. {D}) have touch
+ * handlers set whereas all other views are not declared to handler touch events.
*/
public class CatalystTouchBubblingTestCase extends ReactAppInstrumentationTestCase {
@@ -57,8 +41,8 @@ public class CatalystTouchBubblingTestCase extends ReactAppInstrumentationTestCa
}
/**
- * 1) Simulate touch event at view A, expect {B} touch handler to fire
- * 2) Simulate touch event at view C, expect {D} touch handler to fire
+ * 1) Simulate touch event at view A, expect {B} touch handler to fire 2) Simulate touch event at
+ * view C, expect {D} touch handler to fire
*/
public void testSimpleClickAtInnerElements() {
mRecordingModule.reset();
@@ -80,8 +64,7 @@ public class CatalystTouchBubblingTestCase extends ReactAppInstrumentationTestCa
/**
* 1) Start touch at view A, then drag and release on view {B} (but outside of A), expect {B}'s
- * touch handler to fire
- * 2) Do the same with view C and {D}
+ * touch handler to fire 2) Do the same with view C and {D}
*/
public void testDownOnInnerUpOnTouchableParent() {
View innerButton = getViewByTestId("A");
@@ -151,7 +134,6 @@ public class CatalystTouchBubblingTestCase extends ReactAppInstrumentationTestCa
@Override
protected ReactInstanceSpecForTest createReactInstanceSpecForTest() {
- return new ReactInstanceSpecForTest()
- .addNativeModule(mRecordingModule);
+ return new ReactInstanceSpecForTest().addNativeModule(mRecordingModule);
}
}
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystUIManagerTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystUIManagerTestCase.java
index 1c98ec39d21..63424cdb6e6 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystUIManagerTestCase.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystUIManagerTestCase.java
@@ -1,10 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.tests;
import android.util.DisplayMetrics;
@@ -30,17 +29,21 @@ import com.facebook.react.views.view.ReactViewManager;
import java.util.Arrays;
import java.util.List;
-/**
- * Test case for basic {@link UIManagerModule} functionality.
- */
+/** Test case for basic {@link UIManagerModule} functionality. */
public class CatalystUIManagerTestCase extends ReactIntegrationTestCase {
private interface UIManagerTestModule extends JavaScriptModule {
void renderFlexTestApplication(int rootTag);
+
void renderFlexWithTextApplication(int rootTag);
+
void renderAbsolutePositionTestApplication(int rootTag);
+
void renderAbsolutePositionBottomRightTestApplication(int rootTag);
+
void renderCenteredTextViewTestApplication(int rootTag, String text);
+
void renderUpdatePositionInListTestApplication(int rootTag);
+
void flushUpdatePositionInList();
}
@@ -71,28 +74,28 @@ public class CatalystUIManagerTestCase extends ReactIntegrationTestCase {
protected void setUp() throws Exception {
super.setUp();
- List This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.tests;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.List;
-
import android.app.DatePickerDialog;
import android.content.DialogInterface;
+import android.widget.DatePicker;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
-import android.widget.DatePicker;
-
import com.facebook.react.bridge.BaseJavaModule;
-import com.facebook.react.testing.ReactInstanceSpecForTest;
-import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.JavaScriptModule;
+import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeMap;
import com.facebook.react.modules.datepicker.DatePickerDialogModule;
import com.facebook.react.testing.ReactAppInstrumentationTestCase;
+import com.facebook.react.testing.ReactInstanceSpecForTest;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.List;
-/**
- * Test case for {@link DatePickerDialogModule} options and callbacks.
- */
+/** Test case for {@link DatePickerDialogModule} options and callbacks. */
public class DatePickerDialogTestCase extends ReactAppInstrumentationTestCase {
private static interface DatePickerDialogTestModule extends JavaScriptModule {
@@ -78,8 +73,7 @@ public class DatePickerDialogTestCase extends ReactAppInstrumentationTestCase {
@Override
protected ReactInstanceSpecForTest createReactInstanceSpecForTest() {
- return super.createReactInstanceSpecForTest()
- .addNativeModule(mRecordingModule);
+ return super.createReactInstanceSpecForTest().addNativeModule(mRecordingModule);
}
@Override
@@ -105,8 +99,10 @@ public class DatePickerDialogTestCase extends ReactAppInstrumentationTestCase {
waitForBridgeAndUIIdle();
getInstrumentation().waitForIdleSync();
- return (DialogFragment) getActivity().getSupportFragmentManager()
- .findFragmentByTag(DatePickerDialogModule.FRAGMENT_TAG);
+ return (DialogFragment)
+ getActivity()
+ .getSupportFragmentManager()
+ .findFragmentByTag(DatePickerDialogModule.FRAGMENT_TAG);
}
public void testShowBasicDatePicker() {
@@ -139,7 +135,8 @@ public class DatePickerDialogTestCase extends ReactAppInstrumentationTestCase {
@Override
public void run() {
((DatePickerDialog) datePickerFragment.getDialog())
- .getButton(DialogInterface.BUTTON_POSITIVE).performClick();
+ .getButton(DialogInterface.BUTTON_POSITIVE)
+ .performClick();
}
});
@@ -171,5 +168,4 @@ public class DatePickerDialogTestCase extends ReactAppInstrumentationTestCase {
assertEquals(0, mRecordingModule.getDates().size());
assertEquals(1, mRecordingModule.getDismissed());
}
-
}
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ImageErrorTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ImageErrorTestCase.java
index 3676a9cd202..f500599cd94 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ImageErrorTestCase.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ImageErrorTestCase.java
@@ -1,20 +1,16 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.tests;
-import android.view.View;
import com.facebook.react.testing.ReactAppInstrumentationTestCase;
import com.facebook.react.testing.ReactInstanceSpecForTest;
import com.facebook.react.testing.StringRecordingModule;
-/**
- * Simple test case to check that onError does not get called with undefined
- */
+/** Simple test case to check that onError does not get called with undefined */
public class ImageErrorTestCase extends ReactAppInstrumentationTestCase {
private StringRecordingModule mStringRecordingModule;
@@ -30,17 +26,21 @@ public class ImageErrorTestCase extends ReactAppInstrumentationTestCase {
assertNotNull(getViewByTestId("image-3"));
Thread.sleep(3000);
-
+
assertEquals(3, mStringRecordingModule.getCalls().size());
- assertEquals("Got error: Unsupported uri scheme! Uri is: ", mStringRecordingModule.getCalls().get(0));
- assertEquals("Got error: /does/not/exist: open failed: ENOENT (No such file or directory)", mStringRecordingModule.getCalls().get(1));
- assertEquals("Got error: Unexpected HTTP code Response{protocol=http/1.1, code=404, message=Not Found, url=https://typo_error_facebook.github.io/react/logo-og.png}", mStringRecordingModule.getCalls().get(2));
+ assertEquals(
+ "Got error: Unsupported uri scheme! Uri is: ", mStringRecordingModule.getCalls().get(0));
+ assertEquals(
+ "Got error: /does/not/exist: open failed: ENOENT (No such file or directory)",
+ mStringRecordingModule.getCalls().get(1));
+ assertEquals(
+ "Got error: Unexpected HTTP code Response{protocol=http/1.1, code=404, message=Not Found, url=https://typo_error_facebook.github.io/react/logo-og.png}",
+ mStringRecordingModule.getCalls().get(2));
}
@Override
protected ReactInstanceSpecForTest createReactInstanceSpecForTest() {
mStringRecordingModule = new StringRecordingModule();
- return super.createReactInstanceSpecForTest()
- .addNativeModule(mStringRecordingModule);
+ return super.createReactInstanceSpecForTest().addNativeModule(mStringRecordingModule);
}
}
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ImageOverlayColorTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ImageOverlayColorTestCase.java
index 4dd334af88f..1dd531ad2ef 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ImageOverlayColorTestCase.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ImageOverlayColorTestCase.java
@@ -1,18 +1,15 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.tests;
import android.view.View;
import com.facebook.react.testing.ReactAppInstrumentationTestCase;
-/**
- * Simple test case for passing overlayColor prop to the Image component
- */
+/** Simple test case for passing overlayColor prop to the Image component */
public class ImageOverlayColorTestCase extends ReactAppInstrumentationTestCase {
@Override
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/InitialPropsTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/InitialPropsTestCase.java
index bf754df05df..6a7c84f35bd 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/InitialPropsTestCase.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/InitialPropsTestCase.java
@@ -1,28 +1,23 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.tests;
import android.os.Bundle;
import android.test.ActivityInstrumentationTestCase2;
-
import com.facebook.react.bridge.BaseJavaModule;
-import com.facebook.react.testing.FakeWebSocketModule;
-import com.facebook.react.testing.ReactInstanceSpecForTest;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
+import com.facebook.react.testing.FakeWebSocketModule;
import com.facebook.react.testing.ReactAppTestActivity;
+import com.facebook.react.testing.ReactInstanceSpecForTest;
-/**
- * Simple test case for passing initial props to the root React application.
- */
-public class InitialPropsTestCase extends
- ActivityInstrumentationTestCase2 This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.tests;
import com.facebook.react.bridge.CatalystInstance;
@@ -23,13 +22,12 @@ import com.facebook.react.views.view.ReactViewManager;
import java.util.Arrays;
import java.util.List;
-/**
- * Test locale-based functionality of JS VM
- */
+/** Test locale-based functionality of JS VM */
public class JSLocaleTest extends ReactIntegrationTestCase {
private interface TestJSLocaleModule extends JavaScriptModule {
void toUpper(String string);
+
void toLower(String string);
}
@@ -41,12 +39,8 @@ public class JSLocaleTest extends ReactIntegrationTestCase {
protected void setUp() throws Exception {
super.setUp();
- List This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.tests;
import android.widget.ScrollView;
-
-import com.facebook.react.uimanager.PixelUtil;
import com.facebook.react.testing.ReactAppInstrumentationTestCase;
import com.facebook.react.testing.SingleTouchGestureGenerator;
+import com.facebook.react.uimanager.PixelUtil;
/**
* Test case to verify that JSResponder flow work correctly.
*
- * In a single test case scenario we have a view with pan gesture recognizer containing a scrollview
- * We verify that by vertical drags affects a scrollview while horizontal drags are suppose to
- * be recognized by pan responder and setJSResponder should be triggered resulting in scrollview
- * events being intercepted.
+ * In a single test case scenario we have a view with pan gesture recognizer containing a
+ * scrollview We verify that by vertical drags affects a scrollview while horizontal drags are
+ * suppose to be recognized by pan responder and setJSResponder should be triggered resulting in
+ * scrollview events being intercepted.
*/
public class JSResponderTestCase extends ReactAppInstrumentationTestCase {
@@ -55,13 +53,9 @@ public class JSResponderTestCase extends ReactAppInstrumentationTestCase {
waitForBridgeAndUIIdle();
- gestureGenerator
- .dragTo(30 + inpx40dp, 30, 10, 1200)
- .endGesture();
+ gestureGenerator.dragTo(30 + inpx40dp, 30, 10, 1200).endGesture();
waitForBridgeAndUIIdle();
assertEquals("Expected not to scroll", scrollView.getScrollY(), previousScroll);
-
}
-
}
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/LayoutEventsTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/LayoutEventsTestCase.java
index f9f7741d8c7..1f075eaca3d 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/LayoutEventsTestCase.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/LayoutEventsTestCase.java
@@ -1,19 +1,16 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.tests;
import com.facebook.react.testing.ReactAppInstrumentationTestCase;
import com.facebook.react.testing.ReactInstanceSpecForTest;
import com.facebook.react.testing.StringRecordingModule;
-/**
- * Simple test to verify that layout events (onLayout) propagate to JS from native.
- */
+/** Simple test to verify that layout events (onLayout) propagate to JS from native. */
public class LayoutEventsTestCase extends ReactAppInstrumentationTestCase {
private StringRecordingModule mStringRecordingModule;
@@ -23,9 +20,7 @@ public class LayoutEventsTestCase extends ReactAppInstrumentationTestCase {
return "LayoutEventsTestApp";
}
- /**
- * Creates a UI in JS and verifies the onLayout handler is called.
- */
+ /** Creates a UI in JS and verifies the onLayout handler is called. */
public void testOnLayoutCalled() {
assertEquals(3, mStringRecordingModule.getCalls().size());
assertEquals("10,10-100x100", mStringRecordingModule.getCalls().get(0));
@@ -36,7 +31,6 @@ public class LayoutEventsTestCase extends ReactAppInstrumentationTestCase {
@Override
protected ReactInstanceSpecForTest createReactInstanceSpecForTest() {
mStringRecordingModule = new StringRecordingModule();
- return super.createReactInstanceSpecForTest()
- .addNativeModule(mStringRecordingModule);
+ return super.createReactInstanceSpecForTest().addNativeModule(mStringRecordingModule);
}
}
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/NativeIdTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/NativeIdTestCase.java
index 0cfd4d6c277..ce5c89c7b9d 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/NativeIdTestCase.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/NativeIdTestCase.java
@@ -1,23 +1,20 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.tests;
+import android.view.View;
+import com.facebook.react.testing.ReactAppInstrumentationTestCase;
+import com.facebook.react.uimanager.util.ReactFindViewUtil;
import java.util.Arrays;
import java.util.List;
-import android.view.View;
-
-import com.facebook.react.testing.ReactAppInstrumentationTestCase;
-import com.facebook.react.uimanager.util.ReactFindViewUtil;
-
/**
- * Tests that the 'nativeID' property can be set on various views.
- * The 'nativeID' property is used to reference react managed views from native code.
+ * Tests that the 'nativeID' property can be set on various views. The 'nativeID' property is used
+ * to reference react managed views from native code.
*/
public class NativeIdTestCase extends ReactAppInstrumentationTestCase {
@@ -26,43 +23,43 @@ public class NativeIdTestCase extends ReactAppInstrumentationTestCase {
return "NativeIdTestApp";
}
- private final List This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.tests;
import android.content.res.Resources;
@@ -32,9 +31,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
-/**
- * Test to verify that Progress bar renders as a view of the right size
- */
+/** Test to verify that Progress bar renders as a view of the right size */
public class ProgressBarTestCase extends ReactIntegrationTestCase {
// Has same order of progressBars in ProgressBarTestModule
@@ -49,7 +46,7 @@ public class ProgressBarTestCase extends ReactIntegrationTestCase {
styles.put("Inverse", android.R.attr.progressBarStyleInverse);
styles.put("SmallInverse", android.R.attr.progressBarStyleSmallInverse);
styles.put("LargeInverse", android.R.attr.progressBarStyleLargeInverse);
-}
+ }
private static interface ProgressBarTestModule extends JavaScriptModule {
public void renderProgressBarApplication(int rootTag);
@@ -63,11 +60,9 @@ public class ProgressBarTestCase extends ReactIntegrationTestCase {
protected void setUp() throws Exception {
super.setUp();
- List This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.tests;
-import java.util.ArrayList;
-
import android.view.View;
import android.widget.HorizontalScrollView;
-
import com.facebook.react.testing.AbstractScrollViewTestCase;
import com.facebook.react.testing.SingleTouchGestureGenerator;
import com.facebook.react.uimanager.PixelUtil;
+import java.util.ArrayList;
-/**
- * Integration test for horizontal ScrollView.
- * See ScrollViewTestModule.js
- */
+/** Integration test for horizontal ScrollView. See ScrollViewTestModule.js */
public class ReactHorizontalScrollViewTestCase extends AbstractScrollViewTestCase {
@Override
@@ -61,8 +55,7 @@ public class ReactHorizontalScrollViewTestCase extends AbstractScrollViewTestCas
assertFalse("Expected to receive at least one scroll event", xOffsets.isEmpty());
assertTrue("Expected offset to be greater than 0", xOffsets.get(xOffsets.size() - 1) > 0);
assertTrue(
- "Expected no item click event fired",
- mScrollListenerModule.getItemsPressed().isEmpty());
+ "Expected no item click event fired", mScrollListenerModule.getItemsPressed().isEmpty());
assertEquals(
"Expected last offset to be offset of scroll view",
PixelUtil.toDIPFromPixel(scrollView.getScrollX()),
@@ -103,9 +96,7 @@ public class ReactHorizontalScrollViewTestCase extends AbstractScrollViewTestCas
assertEquals(visibleItemNumber, (int) itemIds.get(0));
}
- /**
- * Verify that 'scrollTo' command makes ScrollView start scrolling
- */
+ /** Verify that 'scrollTo' command makes ScrollView start scrolling */
public void testScrollToCommand() throws Exception {
HorizontalScrollView scrollView = getViewAtPath(0);
ScrollViewTestModule jsModule =
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ReactPickerTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ReactPickerTestCase.java
index ec8fd977a0a..24bf069a0bd 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ReactPickerTestCase.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ReactPickerTestCase.java
@@ -1,29 +1,26 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.tests;
-import java.util.ArrayList;
-import java.util.List;
-
import android.graphics.Color;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import android.widget.TextView;
-
import com.facebook.react.bridge.BaseJavaModule;
-import com.facebook.react.testing.ReactInstanceSpecForTest;
-import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.JavaScriptModule;
+import com.facebook.react.bridge.ReactMethod;
+import com.facebook.react.testing.ReactAppInstrumentationTestCase;
+import com.facebook.react.testing.ReactInstanceSpecForTest;
import com.facebook.react.views.picker.ReactDialogPickerManager;
import com.facebook.react.views.picker.ReactDropdownPickerManager;
import com.facebook.react.views.picker.ReactPicker;
import com.facebook.react.views.picker.ReactPickerManager;
-import com.facebook.react.testing.ReactAppInstrumentationTestCase;
+import java.util.ArrayList;
+import java.util.List;
/**
* Integration test for {@link ReactDialogPickerManager} and {@link ReactDropdownPickerManager}
@@ -34,7 +31,9 @@ public class ReactPickerTestCase extends ReactAppInstrumentationTestCase {
private static interface PickerAndroidTestModule extends JavaScriptModule {
public void selectItem(int position);
+
public void setMode(String mode);
+
public void setPrimaryColor(String color);
}
@@ -66,8 +65,7 @@ public class ReactPickerTestCase extends ReactAppInstrumentationTestCase {
@Override
protected ReactInstanceSpecForTest createReactInstanceSpecForTest() {
mRecordingModule = new PickerAndroidRecordingModule();
- return super.createReactInstanceSpecForTest()
- .addNativeModule(mRecordingModule);
+ return super.createReactInstanceSpecForTest().addNativeModule(mRecordingModule);
}
public void testBasicProperties() {
@@ -88,29 +86,22 @@ public class ReactPickerTestCase extends ReactAppInstrumentationTestCase {
assertEquals(Color.GREEN, ((TextView) adapter.getView(1, null, null)).getCurrentTextColor());
assertEquals(Color.BLUE, ((TextView) adapter.getView(2, null, null)).getCurrentTextColor());
assertEquals(
- Color.RED,
- ((TextView) adapter.getDropDownView(0, null, null)).getCurrentTextColor());
+ Color.RED, ((TextView) adapter.getDropDownView(0, null, null)).getCurrentTextColor());
assertEquals(
- Color.GREEN,
- ((TextView) adapter.getDropDownView(1, null, null)).getCurrentTextColor());
+ Color.GREEN, ((TextView) adapter.getDropDownView(1, null, null)).getCurrentTextColor());
assertEquals(
- Color.BLUE,
- ((TextView) adapter.getDropDownView(2, null, null)).getCurrentTextColor());
+ Color.BLUE, ((TextView) adapter.getDropDownView(2, null, null)).getCurrentTextColor());
getTestModule().setPrimaryColor("black");
waitForBridgeAndUIIdle();
assertEquals(Color.BLACK, ((TextView) adapter.getView(0, null, null)).getCurrentTextColor());
assertEquals(Color.BLACK, ((TextView) adapter.getView(1, null, null)).getCurrentTextColor());
assertEquals(Color.BLACK, ((TextView) adapter.getView(2, null, null)).getCurrentTextColor());
assertEquals(
- Color.RED,
- ((TextView) adapter.getDropDownView(0, null, null)).getCurrentTextColor());
+ Color.RED, ((TextView) adapter.getDropDownView(0, null, null)).getCurrentTextColor());
assertEquals(
- Color.GREEN,
- ((TextView) adapter.getDropDownView(1, null, null)).getCurrentTextColor());
+ Color.GREEN, ((TextView) adapter.getDropDownView(1, null, null)).getCurrentTextColor());
assertEquals(
- Color.BLUE,
- ((TextView) adapter.getDropDownView(2, null, null)).getCurrentTextColor());
-
+ Color.BLUE, ((TextView) adapter.getDropDownView(2, null, null)).getCurrentTextColor());
}
public void testDropdownPicker() {
@@ -176,9 +167,8 @@ public class ReactPickerTestCase extends ReactAppInstrumentationTestCase {
updateFirstSpinnerAndCheckLastSpinnerMatches(2);
}
- private void updateFirstSpinnerAndCheckLastSpinnerMatches(
- final int indexToSelect
- ) throws Throwable {
+ private void updateFirstSpinnerAndCheckLastSpinnerMatches(final int indexToSelect)
+ throws Throwable {
// The last spinner has the same selected value as the first one.
// Test that user selection is propagated correctly to JS, to setState, and to Spinners.
runTestOnUiThread(
@@ -194,13 +184,12 @@ public class ReactPickerTestCase extends ReactAppInstrumentationTestCase {
ReactPicker spinnerInSync = getViewAtPath(0, 3);
assertEquals(
- "Picker selection was not updated correctly via setState.",
- indexToSelect,
- spinnerInSync.getSelectedItemPosition());
+ "Picker selection was not updated correctly via setState.",
+ indexToSelect,
+ spinnerInSync.getSelectedItemPosition());
}
private PickerAndroidTestModule getTestModule() {
return getReactContext().getCatalystInstance().getJSModule(PickerAndroidTestModule.class);
}
-
}
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ReactScrollViewTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ReactScrollViewTestCase.java
index 0267bb8e28b..434d98cb97b 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ReactScrollViewTestCase.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ReactScrollViewTestCase.java
@@ -1,25 +1,19 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.tests;
-import java.util.ArrayList;
-
import android.view.View;
import android.widget.ScrollView;
-
import com.facebook.react.testing.AbstractScrollViewTestCase;
import com.facebook.react.testing.SingleTouchGestureGenerator;
import com.facebook.react.uimanager.PixelUtil;
+import java.util.ArrayList;
-/**
- * Integration test for vertical ScrollView.
- * See ScrollViewTestModule.js
- */
+/** Integration test for vertical ScrollView. See ScrollViewTestModule.js */
public class ReactScrollViewTestCase extends AbstractScrollViewTestCase {
@Override
@@ -61,8 +55,7 @@ public class ReactScrollViewTestCase extends AbstractScrollViewTestCase {
assertFalse("Expected to receive at least one scroll event", yOffsets.isEmpty());
assertTrue("Expected offset to be greater than 0", yOffsets.get(yOffsets.size() - 1) > 0);
assertTrue(
- "Expected no item click event fired",
- mScrollListenerModule.getItemsPressed().isEmpty());
+ "Expected no item click event fired", mScrollListenerModule.getItemsPressed().isEmpty());
assertEquals(
"Expected last offset to be offset of scroll view",
PixelUtil.toDIPFromPixel(scrollView.getScrollY()),
@@ -104,9 +97,7 @@ public class ReactScrollViewTestCase extends AbstractScrollViewTestCase {
assertEquals(visibleItemNumber, (int) itemIds.get(0));
}
- /**
- * Verify that 'scrollTo' command makes ScrollView start scrolling
- */
+ /** Verify that 'scrollTo' command makes ScrollView start scrolling */
public void testScrollToCommand() throws Exception {
ScrollView scrollView = getViewAtPath(0);
ScrollViewTestModule jsModule =
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ReactSwipeRefreshLayoutTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ReactSwipeRefreshLayoutTestCase.java
index a75b217131f..a4054cf88fb 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ReactSwipeRefreshLayoutTestCase.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ReactSwipeRefreshLayoutTestCase.java
@@ -1,24 +1,20 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.tests;
import android.view.View;
-
-import com.facebook.react.testing.ReactAppInstrumentationTestCase;
-import com.facebook.react.testing.ReactInstanceSpecForTest;
import com.facebook.react.bridge.BaseJavaModule;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.ReactMethod;
+import com.facebook.react.testing.ReactAppInstrumentationTestCase;
+import com.facebook.react.testing.ReactInstanceSpecForTest;
import com.facebook.react.views.swiperefresh.ReactSwipeRefreshLayout;
-/**
- * Test case for {@link ReactSwipeRefreshLayout}.
- */
+/** Test case for {@link ReactSwipeRefreshLayout}. */
public class ReactSwipeRefreshLayoutTestCase extends ReactAppInstrumentationTestCase {
private class SwipeRefreshLayoutRecordingModule extends BaseJavaModule {
@@ -53,8 +49,7 @@ public class ReactSwipeRefreshLayoutTestCase extends ReactAppInstrumentationTest
@Override
protected ReactInstanceSpecForTest createReactInstanceSpecForTest() {
- return super.createReactInstanceSpecForTest()
- .addNativeModule(mRecordingModule);
+ return super.createReactInstanceSpecForTest().addNativeModule(mRecordingModule);
}
public void testRefreshNoScroll() {
@@ -98,5 +93,4 @@ public class ReactSwipeRefreshLayoutTestCase extends ReactAppInstrumentationTest
waitForBridgeAndUIIdle();
assertEquals(0, mRecordingModule.getCount());
}
-
}
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ShareTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ShareTestCase.java
index 83d382d112c..356d84186a1 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ShareTestCase.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ShareTestCase.java
@@ -1,36 +1,24 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.tests;
-import java.util.ArrayList;
-import java.util.List;
-
-import android.app.Activity;
-import android.app.AlertDialog;
import android.app.Instrumentation.ActivityMonitor;
-import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
-import android.content.IntentFilter.MalformedMimeTypeException;
-import androidx.fragment.app.DialogFragment;
-
import com.facebook.react.bridge.BaseJavaModule;
-import com.facebook.react.testing.ReactInstanceSpecForTest;
-import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.JavaScriptModule;
+import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeMap;
import com.facebook.react.modules.share.ShareModule;
import com.facebook.react.testing.ReactAppInstrumentationTestCase;
+import com.facebook.react.testing.ReactInstanceSpecForTest;
-/**
- * Test case for {@link ShareModule}.
- */
+/** Test case for {@link ShareModule}. */
public class ShareTestCase extends ReactAppInstrumentationTestCase {
private static interface ShareTestModule extends JavaScriptModule {
@@ -64,15 +52,13 @@ public class ShareTestCase extends ReactAppInstrumentationTestCase {
public int getErrors() {
return mErrors;
}
-
}
final ShareRecordingModule mRecordingModule = new ShareRecordingModule();
@Override
protected ReactInstanceSpecForTest createReactInstanceSpecForTest() {
- return super.createReactInstanceSpecForTest()
- .addNativeModule(mRecordingModule);
+ return super.createReactInstanceSpecForTest().addNativeModule(mRecordingModule);
}
@Override
@@ -101,7 +87,5 @@ public class ShareTestCase extends ReactAppInstrumentationTestCase {
assertEquals(1, monitor.getHits());
assertEquals(1, mRecordingModule.getOpened());
assertEquals(0, mRecordingModule.getErrors());
-
}
-
}
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/TestIdTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/TestIdTestCase.java
index 47696a68460..54eedf9ddeb 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/TestIdTestCase.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/TestIdTestCase.java
@@ -1,25 +1,20 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.tests;
+import android.view.View;
+import com.facebook.react.testing.ReactAppInstrumentationTestCase;
+import com.facebook.react.testing.ReactTestHelper;
import java.util.Arrays;
import java.util.List;
-import android.view.View;
-
-import com.facebook.react.views.picker.ReactDropdownPickerManager;
-import com.facebook.react.testing.ReactAppInstrumentationTestCase;
-import com.facebook.react.testing.ReactInstanceSpecForTest;
-import com.facebook.react.testing.ReactTestHelper;
-
/**
- * Tests that the 'testID' property can be set on various views.
- * The 'testID' property is used to locate views in UI tests.
+ * Tests that the 'testID' property can be set on various views. The 'testID' property is used to
+ * locate views in UI tests.
*/
public class TestIdTestCase extends ReactAppInstrumentationTestCase {
@@ -28,22 +23,20 @@ public class TestIdTestCase extends ReactAppInstrumentationTestCase {
return "TestIdTestApp";
}
- private final List This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.tests;
import android.graphics.Color;
import android.text.style.ForegroundColorSpan;
import android.util.TypedValue;
-import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
-
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.testing.ReactAppInstrumentationTestCase;
import com.facebook.react.testing.ReactInstanceSpecForTest;
@@ -23,9 +20,7 @@ import com.facebook.react.testing.StringRecordingModule;
import com.facebook.react.uimanager.PixelUtil;
import com.facebook.react.views.textinput.ReactEditText;
-/**
- * Test to verify that TextInput renders correctly
- */
+/** Test to verify that TextInput renders correctly */
public class TextInputTestCase extends ReactAppInstrumentationTestCase {
private final StringRecordingModule mRecordingModule = new StringRecordingModule();
@@ -47,20 +42,17 @@ public class TextInputTestCase extends ReactAppInstrumentationTestCase {
EditText editText = new EditText(textInputViewNoHeight.getContext());
editText.setTextSize(
- TypedValue.COMPLEX_UNIT_PX,
- (float) Math.ceil(PixelUtil.toPixelFromSP(21.f)));
+ TypedValue.COMPLEX_UNIT_PX, (float) Math.ceil(PixelUtil.toPixelFromSP(21.f)));
editText.setPadding(0, 0, 0, 0);
- int measureSpec = View.MeasureSpec.makeMeasureSpec(
- ViewGroup.LayoutParams.WRAP_CONTENT,
- View.MeasureSpec.UNSPECIFIED);
+ int measureSpec =
+ View.MeasureSpec.makeMeasureSpec(
+ ViewGroup.LayoutParams.WRAP_CONTENT, View.MeasureSpec.UNSPECIFIED);
editText.measure(measureSpec, measureSpec);
assertEquals(editText.getMeasuredHeight(), textInputViewNoHeight.getHeight());
}
- /**
- * Test that the cursor moves to the end of the word.
- */
+ /** Test that the cursor moves to the end of the word. */
public void testTextInputCursorPosition() throws Throwable {
final EditText textInputWithText = getViewByTestId("textInput3");
@@ -71,7 +63,8 @@ public class TextInputTestCase extends ReactAppInstrumentationTestCase {
textInputWithText.setSelection(3);
}
});
- getReactContext().getJSModule(TextInputTestModule.class)
+ getReactContext()
+ .getJSModule(TextInputTestModule.class)
.setValueRef("textInput3", "Some other value");
waitForBridgeAndUIIdle();
@@ -79,9 +72,7 @@ public class TextInputTestCase extends ReactAppInstrumentationTestCase {
assertEquals(4, textInputWithText.getSelectionEnd());
}
- /**
- * Test that the colors are applied to new text
- */
+ /** Test that the colors are applied to new text */
public void testTextInputColors() throws Throwable {
String testIDs[] = new String[] {"textInput4", "textInput5", "textInput6"};
@@ -94,7 +85,9 @@ public class TextInputTestCase extends ReactAppInstrumentationTestCase {
ReactEditText reactEditText = getViewByTestId(testID);
assertEquals(
Color.GREEN,
- reactEditText.getText().getSpans(0, 1, ForegroundColorSpan.class)[0]
+ reactEditText
+ .getText()
+ .getSpans(0, 1, ForegroundColorSpan.class)[0]
.getForegroundColor());
}
}
@@ -113,26 +106,26 @@ public class TextInputTestCase extends ReactAppInstrumentationTestCase {
fireEditorActionAndCheckRecording(reactEditText, EditorInfo.IME_ACTION_NONE);
}
- private void fireEditorActionAndCheckRecording(final ReactEditText reactEditText,
- final int actionId) throws Throwable {
+ private void fireEditorActionAndCheckRecording(
+ final ReactEditText reactEditText, final int actionId) throws Throwable {
fireEditorActionAndCheckRecording(reactEditText, actionId, true);
fireEditorActionAndCheckRecording(reactEditText, actionId, false);
}
- private void fireEditorActionAndCheckRecording(final ReactEditText reactEditText,
- final int actionId,
- final boolean blurOnSubmit) throws Throwable {
+ private void fireEditorActionAndCheckRecording(
+ final ReactEditText reactEditText, final int actionId, final boolean blurOnSubmit)
+ throws Throwable {
mRecordingModule.reset();
runTestOnUiThread(
- new Runnable() {
- @Override
- public void run() {
- reactEditText.requestFocusFromJS();
- reactEditText.setBlurOnSubmit(blurOnSubmit);
- reactEditText.onEditorAction(actionId);
- }
- });
+ new Runnable() {
+ @Override
+ public void run() {
+ reactEditText.requestFocusFromJS();
+ reactEditText.setBlurOnSubmit(blurOnSubmit);
+ reactEditText.onEditorAction(actionId);
+ }
+ });
waitForBridgeAndUIIdle();
assertEquals(1, mRecordingModule.getCalls().size());
@@ -140,114 +133,68 @@ public class TextInputTestCase extends ReactAppInstrumentationTestCase {
}
/**
- * Test that the mentions input has colors displayed correctly.
- * Removed for being flaky in open source, December 2016
- public void testMetionsInputColors() throws Throwable {
- EventDispatcher eventDispatcher =
- getReactContext().getNativeModule(UIManagerModule.class).getEventDispatcher();
- ReactEditText reactEditText = getViewByTestId("tokenizedInput");
- String newText = "#Things and more #things";
- int contentWidth = reactEditText.getWidth();
- int contentHeight = reactEditText.getHeight();
- int start = 0;
- int count = newText.length();
-
- eventDispatcher.dispatchEvent(
- new ReactTextChangedEvent(
- reactEditText.getId(),
- newText.toString(),
- (int) PixelUtil.toDIPFromPixel(contentWidth),
- (int) PixelUtil.toDIPFromPixel(contentHeight),
- reactEditText.incrementAndGetEventCounter()));
-
- eventDispatcher.dispatchEvent(
- new ReactTextInputEvent(
- reactEditText.getId(),
- newText.toString(),
- "",
- start,
- start + count - 1));
- waitForBridgeAndUIIdle();
-
- ForegroundColorSpan[] spans = reactEditText
- .getText().getSpans(0, reactEditText.getText().length(), ForegroundColorSpan.class);
- assertEquals(2, spans.length);
- assertEquals(spans[0].getForegroundColor(), spans[1].getForegroundColor());
- assertEquals(0, reactEditText.getText().getSpanStart(spans[1]));
- assertEquals(7, reactEditText.getText().getSpanEnd(spans[1]));
- assertEquals(newText.length() - 7, reactEditText.getText().getSpanStart(spans[0]));
- assertEquals(newText.length(), reactEditText.getText().getSpanEnd(spans[0]));
-
- String moreText = "andsuch ";
- String previousText = newText;
- newText += moreText;
- count = moreText.length();
- start = previousText.length();
-
- eventDispatcher.dispatchEvent(
- new ReactTextChangedEvent(
- reactEditText.getId(),
- newText.toString(),
- (int) PixelUtil.toDIPFromPixel(contentWidth),
- (int) PixelUtil.toDIPFromPixel(contentHeight),
- reactEditText.incrementAndGetEventCounter()));
-
- eventDispatcher.dispatchEvent(
- new ReactTextInputEvent(
- reactEditText.getId(),
- moreText,
- "",
- start,
- start + count - 1));
- waitForBridgeAndUIIdle();
-
- spans = reactEditText.getText()
- .getSpans(0, reactEditText.getText().length(), ForegroundColorSpan.class);
- assertEquals(2, spans.length);
- assertEquals(spans[0].getForegroundColor(), spans[1].getForegroundColor());
- assertEquals(0, reactEditText.getText().getSpanStart(spans[1]));
- assertEquals(7, reactEditText.getText().getSpanEnd(spans[1]));
- assertEquals(newText.length() - 15, reactEditText.getText().getSpanStart(spans[0]));
- assertEquals(newText.length() - 1, reactEditText.getText().getSpanEnd(spans[0]));
-
- moreText = "morethings";
- previousText = newText;
- newText += moreText;
- count = moreText.length();
- start = previousText.length();
-
- eventDispatcher.dispatchEvent(
- new ReactTextChangedEvent(
- reactEditText.getId(),
- newText.toString(),
- (int) PixelUtil.toDIPFromPixel(contentWidth),
- (int) PixelUtil.toDIPFromPixel(contentHeight),
- reactEditText.incrementAndGetEventCounter()));
-
- eventDispatcher.dispatchEvent(
- new ReactTextInputEvent(
- reactEditText.getId(),
- moreText,
- "",
- start,
- start + count - 1));
- waitForBridgeAndUIIdle();
-
- spans = reactEditText.getText()
- .getSpans(0, reactEditText.getText().length(), ForegroundColorSpan.class);
- assertEquals(spans[0].getForegroundColor(), spans[1].getForegroundColor());
- assertEquals(2, spans.length);
- assertEquals(0, reactEditText.getText().getSpanStart(spans[1]));
- assertEquals(7, reactEditText.getText().getSpanEnd(spans[1]));
- assertEquals(newText.length() - 25, reactEditText.getText().getSpanStart(spans[0]));
- assertEquals(newText.length() - 11, reactEditText.getText().getSpanEnd(spans[0]));
- }
- */
-
+ * Test that the mentions input has colors displayed correctly. Removed for being flaky in open
+ * source, December 2016 public void testMetionsInputColors() throws Throwable { EventDispatcher
+ * eventDispatcher =
+ * getReactContext().getNativeModule(UIManagerModule.class).getEventDispatcher(); ReactEditText
+ * reactEditText = getViewByTestId("tokenizedInput"); String newText = "#Things and more #things";
+ * int contentWidth = reactEditText.getWidth(); int contentHeight = reactEditText.getHeight(); int
+ * start = 0; int count = newText.length();
+ *
+ * eventDispatcher.dispatchEvent( new ReactTextChangedEvent( reactEditText.getId(),
+ * newText.toString(), (int) PixelUtil.toDIPFromPixel(contentWidth), (int)
+ * PixelUtil.toDIPFromPixel(contentHeight), reactEditText.incrementAndGetEventCounter()));
+ *
+ * eventDispatcher.dispatchEvent( new ReactTextInputEvent( reactEditText.getId(),
+ * newText.toString(), "", start, start + count - 1)); waitForBridgeAndUIIdle();
+ *
+ * ForegroundColorSpan[] spans = reactEditText .getText().getSpans(0,
+ * reactEditText.getText().length(), ForegroundColorSpan.class); assertEquals(2, spans.length);
+ * assertEquals(spans[0].getForegroundColor(), spans[1].getForegroundColor()); assertEquals(0,
+ * reactEditText.getText().getSpanStart(spans[1])); assertEquals(7,
+ * reactEditText.getText().getSpanEnd(spans[1])); assertEquals(newText.length() - 7,
+ * reactEditText.getText().getSpanStart(spans[0])); assertEquals(newText.length(),
+ * reactEditText.getText().getSpanEnd(spans[0]));
+ *
+ * String moreText = "andsuch "; String previousText = newText; newText += moreText; count =
+ * moreText.length(); start = previousText.length();
+ *
+ * eventDispatcher.dispatchEvent( new ReactTextChangedEvent( reactEditText.getId(),
+ * newText.toString(), (int) PixelUtil.toDIPFromPixel(contentWidth), (int)
+ * PixelUtil.toDIPFromPixel(contentHeight), reactEditText.incrementAndGetEventCounter()));
+ *
+ * eventDispatcher.dispatchEvent( new ReactTextInputEvent( reactEditText.getId(), moreText, "",
+ * start, start + count - 1)); waitForBridgeAndUIIdle();
+ *
+ * spans = reactEditText.getText() .getSpans(0, reactEditText.getText().length(),
+ * ForegroundColorSpan.class); assertEquals(2, spans.length);
+ * assertEquals(spans[0].getForegroundColor(), spans[1].getForegroundColor()); assertEquals(0,
+ * reactEditText.getText().getSpanStart(spans[1])); assertEquals(7,
+ * reactEditText.getText().getSpanEnd(spans[1])); assertEquals(newText.length() - 15,
+ * reactEditText.getText().getSpanStart(spans[0])); assertEquals(newText.length() - 1,
+ * reactEditText.getText().getSpanEnd(spans[0]));
+ *
+ * moreText = "morethings"; previousText = newText; newText += moreText; count =
+ * moreText.length(); start = previousText.length();
+ *
+ * eventDispatcher.dispatchEvent( new ReactTextChangedEvent( reactEditText.getId(),
+ * newText.toString(), (int) PixelUtil.toDIPFromPixel(contentWidth), (int)
+ * PixelUtil.toDIPFromPixel(contentHeight), reactEditText.incrementAndGetEventCounter()));
+ *
+ * eventDispatcher.dispatchEvent( new ReactTextInputEvent( reactEditText.getId(), moreText, "",
+ * start, start + count - 1)); waitForBridgeAndUIIdle();
+ *
+ * spans = reactEditText.getText() .getSpans(0, reactEditText.getText().length(),
+ * ForegroundColorSpan.class); assertEquals(spans[0].getForegroundColor(),
+ * spans[1].getForegroundColor()); assertEquals(2, spans.length); assertEquals(0,
+ * reactEditText.getText().getSpanStart(spans[1])); assertEquals(7,
+ * reactEditText.getText().getSpanEnd(spans[1])); assertEquals(newText.length() - 25,
+ * reactEditText.getText().getSpanStart(spans[0])); assertEquals(newText.length() - 11,
+ * reactEditText.getText().getSpanEnd(spans[0])); }
+ */
@Override
protected ReactInstanceSpecForTest createReactInstanceSpecForTest() {
- return super.createReactInstanceSpecForTest()
- .addNativeModule(mRecordingModule);
+ return super.createReactInstanceSpecForTest().addNativeModule(mRecordingModule);
}
@Override
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/TimePickerDialogTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/TimePickerDialogTestCase.java
index a899098dbd6..e88eb555d75 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/TimePickerDialogTestCase.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/TimePickerDialogTestCase.java
@@ -1,31 +1,26 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.tests;
-import java.util.ArrayList;
-import java.util.List;
-
import android.app.TimePickerDialog;
import android.content.DialogInterface;
import androidx.fragment.app.DialogFragment;
-
import com.facebook.react.bridge.BaseJavaModule;
-import com.facebook.react.testing.ReactInstanceSpecForTest;
-import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.JavaScriptModule;
+import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeMap;
import com.facebook.react.modules.timepicker.TimePickerDialogModule;
import com.facebook.react.testing.ReactAppInstrumentationTestCase;
+import com.facebook.react.testing.ReactInstanceSpecForTest;
+import java.util.ArrayList;
+import java.util.List;
-/**
- * Test case for {@link TimePickerDialogModule} options and callbacks.
- */
+/** Test case for {@link TimePickerDialogModule} options and callbacks. */
public class TimePickerDialogTestCase extends ReactAppInstrumentationTestCase {
private static interface TimePickerDialogTestModule extends JavaScriptModule {
@@ -75,8 +70,7 @@ public class TimePickerDialogTestCase extends ReactAppInstrumentationTestCase {
@Override
protected ReactInstanceSpecForTest createReactInstanceSpecForTest() {
- return super.createReactInstanceSpecForTest()
- .addNativeModule(mRecordingModule);
+ return super.createReactInstanceSpecForTest().addNativeModule(mRecordingModule);
}
@Override
@@ -94,8 +88,10 @@ public class TimePickerDialogTestCase extends ReactAppInstrumentationTestCase {
waitForBridgeAndUIIdle();
getInstrumentation().waitForIdleSync();
- return (DialogFragment) getActivity().getSupportFragmentManager()
- .findFragmentByTag(TimePickerDialogModule.FRAGMENT_TAG);
+ return (DialogFragment)
+ getActivity()
+ .getSupportFragmentManager()
+ .findFragmentByTag(TimePickerDialogModule.FRAGMENT_TAG);
}
public void testShowBasicTimePicker() {
@@ -119,7 +115,8 @@ public class TimePickerDialogTestCase extends ReactAppInstrumentationTestCase {
@Override
public void run() {
((TimePickerDialog) fragment.getDialog())
- .getButton(DialogInterface.BUTTON_POSITIVE).performClick();
+ .getButton(DialogInterface.BUTTON_POSITIVE)
+ .performClick();
}
});
@@ -155,5 +152,4 @@ public class TimePickerDialogTestCase extends ReactAppInstrumentationTestCase {
assertEquals(0, mRecordingModule.getTimes().size());
assertEquals(1, mRecordingModule.getDismissed());
}
-
}
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ViewRenderingTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ViewRenderingTestCase.java
index edccc5e89f9..d9b36924147 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ViewRenderingTestCase.java
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ViewRenderingTestCase.java
@@ -1,10 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.tests;
import android.graphics.Color;
@@ -32,9 +31,13 @@ public class ViewRenderingTestCase extends ReactIntegrationTestCase {
private interface ViewRenderingTestModule extends JavaScriptModule {
void renderViewApplication(int rootTag);
+
void renderMarginApplication(int rootTag);
+
void renderBorderApplication(int rootTag);
+
void updateMargins();
+
void renderTransformApplication(int rootTag);
}
@@ -47,8 +50,7 @@ public class ViewRenderingTestCase extends ReactIntegrationTestCase {
super.setUp();
List NB: THREAD SAFETY (this comment also exists at Countable.cpp)
*
- * {@link #dispose} deletes the corresponding native object on whatever thread the method is called
- * on. In the common case when this is called by Countable#finalize(), this will be called on the
- * system finalizer thread. If you manually call dispose on the Java object, the native object
+ * {@link #dispose} deletes the corresponding native object on whatever thread the method is
+ * called on. In the common case when this is called by Countable#finalize(), this will be called on
+ * the system finalizer thread. If you manually call dispose on the Java object, the native object
* will be deleted synchronously on that thread.
*/
@DoNotStrip
@@ -26,8 +26,7 @@ public class Countable {
}
// Private C++ instance
- @DoNotStrip
- private long mInstance = 0;
+ @DoNotStrip private long mInstance = 0;
public native void dispose();
diff --git a/ReactAndroid/src/main/java/com/facebook/jni/CpuCapabilitiesJni.java b/ReactAndroid/src/main/java/com/facebook/jni/CpuCapabilitiesJni.java
index d0df3db702b..c4c3e84cef9 100644
--- a/ReactAndroid/src/main/java/com/facebook/jni/CpuCapabilitiesJni.java
+++ b/ReactAndroid/src/main/java/com/facebook/jni/CpuCapabilitiesJni.java
@@ -8,9 +8,7 @@ package com.facebook.jni;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.soloader.SoLoader;
-/**
- * Utility class to determine CPU capabilities
- */
+/** Utility class to determine CPU capabilities */
@DoNotStrip
public class CpuCapabilitiesJni {
@@ -26,5 +24,4 @@ public class CpuCapabilitiesJni {
@DoNotStrip
public static native boolean nativeDeviceSupportsX86();
-
}
diff --git a/ReactAndroid/src/main/java/com/facebook/jni/DestructorThread.java b/ReactAndroid/src/main/java/com/facebook/jni/DestructorThread.java
index 38bc2e7d848..7acc8f4c28d 100644
--- a/ReactAndroid/src/main/java/com/facebook/jni/DestructorThread.java
+++ b/ReactAndroid/src/main/java/com/facebook/jni/DestructorThread.java
@@ -12,12 +12,12 @@ import java.util.concurrent.atomic.AtomicReference;
/**
* A thread which invokes the "destruct" routine for objects after they have been garbage collected.
*
- * An object which needs to be destructed should create a static subclass of {@link Destructor}.
- * Once the referent object is garbage collected, the DestructorThread will callback to the
- * {@link Destructor#destruct()} method.
+ * An object which needs to be destructed should create a static subclass of {@link Destructor}.
+ * Once the referent object is garbage collected, the DestructorThread will callback to the {@link
+ * Destructor#destruct()} method.
*
- * The underlying thread in DestructorThread starts when the first Destructor is constructed
- * and then runs indefinitely.
+ * The underlying thread in DestructorThread starts when the first Destructor is constructed and
+ * then runs indefinitely.
*/
public class DestructorThread {
@@ -48,6 +48,7 @@ public class DestructorThread {
private static DestructorList sDestructorList;
/** A thread safe stack where new Destructors are placed before being add to sDestructorList. */
private static DestructorStack sDestructorStack;
+
private static ReferenceQueue sReferenceQueue;
private static Thread sThread;
@@ -55,27 +56,28 @@ public class DestructorThread {
sDestructorStack = new DestructorStack();
sReferenceQueue = new ReferenceQueue();
sDestructorList = new DestructorList();
- sThread = new Thread("HybridData DestructorThread") {
- @Override
- public void run() {
- while (true) {
- try {
- Destructor current = (Destructor) sReferenceQueue.remove();
- current.destruct();
+ sThread =
+ new Thread("HybridData DestructorThread") {
+ @Override
+ public void run() {
+ while (true) {
+ try {
+ Destructor current = (Destructor) sReferenceQueue.remove();
+ current.destruct();
- // If current is in the sDestructorStack,
- // transfer all the Destructors in the stack to the list.
- if (current.previous == null) {
- sDestructorStack.transferAllToList();
+ // If current is in the sDestructorStack,
+ // transfer all the Destructors in the stack to the list.
+ if (current.previous == null) {
+ sDestructorStack.transferAllToList();
+ }
+
+ DestructorList.drop(current);
+ } catch (InterruptedException e) {
+ // Continue. This thread should never be terminated.
+ }
}
-
- DestructorList.drop(current);
- } catch (InterruptedException e) {
- // Continue. This thread should never be terminated.
}
- }
- }
- };
+ };
sThread.start();
}
diff --git a/ReactAndroid/src/main/java/com/facebook/jni/HybridClassBase.java b/ReactAndroid/src/main/java/com/facebook/jni/HybridClassBase.java
index 540c1ca5e05..c27b5c14456 100644
--- a/ReactAndroid/src/main/java/com/facebook/jni/HybridClassBase.java
+++ b/ReactAndroid/src/main/java/com/facebook/jni/HybridClassBase.java
@@ -4,8 +4,8 @@
// LICENSE file in the root directory of this source tree.
package com.facebook.jni;
+
import com.facebook.proguard.annotations.DoNotStrip;
@DoNotStrip
-public abstract class HybridClassBase extends HybridData {
-}
+public abstract class HybridClassBase extends HybridData {}
diff --git a/ReactAndroid/src/main/java/com/facebook/jni/HybridData.java b/ReactAndroid/src/main/java/com/facebook/jni/HybridData.java
index 47a331e24c1..158182df3ab 100644
--- a/ReactAndroid/src/main/java/com/facebook/jni/HybridData.java
+++ b/ReactAndroid/src/main/java/com/facebook/jni/HybridData.java
@@ -5,19 +5,16 @@
package com.facebook.jni;
-import android.util.Log;
-
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.soloader.SoLoader;
/**
* This object holds a native C++ member for hybrid Java/C++ objects.
*
- * NB: THREAD SAFETY
+ * NB: THREAD SAFETY
*
- * {@link #resetNative} deletes the corresponding native object synchronously on whatever thread
- * the method is called on. Otherwise, deletion will occur on the {@link DestructorThread}
- * thread.
+ * {@link #resetNative} deletes the corresponding native object synchronously on whatever thread
+ * the method is called on. Otherwise, deletion will occur on the {@link DestructorThread} thread.
*/
@DoNotStrip
public class HybridData {
@@ -26,26 +23,24 @@ public class HybridData {
SoLoader.loadLibrary("fb");
}
- @DoNotStrip
- private Destructor mDestructor = new Destructor(this);
+ @DoNotStrip private Destructor mDestructor = new Destructor(this);
/**
- * To explicitly delete the instance, call resetNative(). If the C++
- * instance is referenced after this is called, a NullPointerException will
- * be thrown. resetNative() may be called multiple times safely. Because
- * the {@link DestructorThread} also calls resetNative, the instance will not leak if this is
- * not called, but timing of deletion and the thread the C++ dtor is called
- * on will be at the whim of the Java GC. If you want to control the thread
- * and timing of the destructor, you should call resetNative() explicitly.
+ * To explicitly delete the instance, call resetNative(). If the C++ instance is referenced after
+ * this is called, a NullPointerException will be thrown. resetNative() may be called multiple
+ * times safely. Because the {@link DestructorThread} also calls resetNative, the instance will
+ * not leak if this is not called, but timing of deletion and the thread the C++ dtor is called on
+ * will be at the whim of the Java GC. If you want to control the thread and timing of the
+ * destructor, you should call resetNative() explicitly.
*/
public synchronized void resetNative() {
mDestructor.destruct();
}
/**
- * N.B. Thread safety.
- * If you call isValid from a different thread than {@link #resetNative()} then be sure to
- * do so while synchronizing on the hybrid. For example:
+ * N.B. Thread safety. If you call isValid from a different thread than {@link #resetNative()}
+ * then be sure to do so while synchronizing on the hybrid. For example:
+ *
* This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.jni;
import com.facebook.proguard.annotations.DoNotStrip;
-
+import java.util.Iterator;
import javax.annotation.Nullable;
-import java.util.Iterator;
-
/**
- * To iterate over an Iterator from C++ requires two calls per entry: hasNext()
- * and next(). This helper reduces it to one call and one field get per entry.
- * It does not use a generic argument, since in C++, the types will be erased,
- * anyway. This is *not* a {@link java.util.Iterator}.
+ * To iterate over an Iterator from C++ requires two calls per entry: hasNext() and next(). This
+ * helper reduces it to one call and one field get per entry. It does not use a generic argument,
+ * since in C++, the types will be erased, anyway. This is *not* a {@link java.util.Iterator}.
*/
@DoNotStrip
public class IteratorHelper {
private final Iterator mIterator;
// This is private, but accessed via JNI.
- @DoNotStrip
- private @Nullable Object mElement;
+ @DoNotStrip private @Nullable Object mElement;
@DoNotStrip
public IteratorHelper(Iterator iterator) {
@@ -38,8 +33,8 @@ public class IteratorHelper {
}
/**
- * Moves the helper to the next entry in the map, if any. Returns true iff
- * there is an entry to read.
+ * Moves the helper to the next entry in the map, if any. Returns true iff there is an entry to
+ * read.
*/
@DoNotStrip
boolean hasNext() {
diff --git a/ReactAndroid/src/main/java/com/facebook/jni/MapIteratorHelper.java b/ReactAndroid/src/main/java/com/facebook/jni/MapIteratorHelper.java
index e57cb9f1733..49749292ca3 100644
--- a/ReactAndroid/src/main/java/com/facebook/jni/MapIteratorHelper.java
+++ b/ReactAndroid/src/main/java/com/facebook/jni/MapIteratorHelper.java
@@ -1,24 +1,21 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.jni;
-import javax.annotation.Nullable;
-
+import com.facebook.proguard.annotations.DoNotStrip;
import java.util.Iterator;
import java.util.Map;
-
-import com.facebook.proguard.annotations.DoNotStrip;
+import javax.annotation.Nullable;
/**
- * To iterate over a Map from C++ requires four calls per entry: hasNext(),
- * next(), getKey(), getValue(). This helper reduces it to one call and two
- * field gets per entry. It does not use a generic argument, since in C++, the
- * types will be erased, anyway. This is *not* a {@link java.util.Iterator}.
+ * To iterate over a Map from C++ requires four calls per entry: hasNext(), next(), getKey(),
+ * getValue(). This helper reduces it to one call and two field gets per entry. It does not use a
+ * generic argument, since in C++, the types will be erased, anyway. This is *not* a {@link
+ * java.util.Iterator}.
*/
@DoNotStrip
public class MapIteratorHelper {
@@ -32,8 +29,8 @@ public class MapIteratorHelper {
}
/**
- * Moves the helper to the next entry in the map, if any. Returns true iff
- * there is an entry to read.
+ * Moves the helper to the next entry in the map, if any. Returns true iff there is an entry to
+ * read.
*/
@DoNotStrip
boolean hasNext() {
diff --git a/ReactAndroid/src/main/java/com/facebook/jni/NativeRunnable.java b/ReactAndroid/src/main/java/com/facebook/jni/NativeRunnable.java
index 10a2517a223..290de68d91f 100644
--- a/ReactAndroid/src/main/java/com/facebook/jni/NativeRunnable.java
+++ b/ReactAndroid/src/main/java/com/facebook/jni/NativeRunnable.java
@@ -1,18 +1,14 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.jni;
-import com.facebook.jni.HybridData;
import com.facebook.proguard.annotations.DoNotStrip;
-/**
- * A Runnable that has a native run implementation.
- */
+/** A Runnable that has a native run implementation. */
@DoNotStrip
public class NativeRunnable implements Runnable {
diff --git a/ReactAndroid/src/main/java/com/facebook/perftest/PerfTestConfig.java b/ReactAndroid/src/main/java/com/facebook/perftest/PerfTestConfig.java
index 7420ab0dce9..8b71fc67449 100644
--- a/ReactAndroid/src/main/java/com/facebook/perftest/PerfTestConfig.java
+++ b/ReactAndroid/src/main/java/com/facebook/perftest/PerfTestConfig.java
@@ -1,19 +1,15 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.perftest;
-/**
- * PerfTestConfig stub.
- */
+/** PerfTestConfig stub. */
public class PerfTestConfig {
public boolean isRunningInPerfTest() {
return false;
}
-
}
diff --git a/ReactAndroid/src/main/java/com/facebook/proguard/annotations/DoNotStrip.java b/ReactAndroid/src/main/java/com/facebook/proguard/annotations/DoNotStrip.java
index e73cd266897..0af1b790f13 100644
--- a/ReactAndroid/src/main/java/com/facebook/proguard/annotations/DoNotStrip.java
+++ b/ReactAndroid/src/main/java/com/facebook/proguard/annotations/DoNotStrip.java
@@ -1,24 +1,22 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.proguard.annotations;
+import static java.lang.annotation.RetentionPolicy.CLASS;
+
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
-import static java.lang.annotation.RetentionPolicy.CLASS;
-
/**
* Add this annotation to a class, method, or field to instruct Proguard to not strip it out.
*
- * This is useful for methods called via reflection that could appear as unused to Proguard.
+ * This is useful for methods called via reflection that could appear as unused to Proguard.
*/
-@Target({ ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR })
+@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
@Retention(CLASS)
-public @interface DoNotStrip {
-}
+public @interface DoNotStrip {}
diff --git a/ReactAndroid/src/main/java/com/facebook/proguard/annotations/KeepGettersAndSetters.java b/ReactAndroid/src/main/java/com/facebook/proguard/annotations/KeepGettersAndSetters.java
index 127dd91ba6c..59b75f000cb 100644
--- a/ReactAndroid/src/main/java/com/facebook/proguard/annotations/KeepGettersAndSetters.java
+++ b/ReactAndroid/src/main/java/com/facebook/proguard/annotations/KeepGettersAndSetters.java
@@ -1,28 +1,26 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.proguard.annotations;
+import static java.lang.annotation.RetentionPolicy.CLASS;
+
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
-import static java.lang.annotation.RetentionPolicy.CLASS;
-
/**
* Add this annotation to a class, to keep all "void set*(***)" and get* methods.
*
- * This is useful for classes that are controlled by animator-like classes that control
- * various properties with reflection.
+ * This is useful for classes that are controlled by animator-like classes that control various
+ * properties with reflection.
*
- * NOTE: This is not needed for Views because their getters and setters
- * are automatically kept by the default Android SDK ProGuard config.
+ * NOTE: This is not needed for Views because their getters and setters are
+ * automatically kept by the default Android SDK ProGuard config.
*/
@Target({ElementType.TYPE})
@Retention(CLASS)
-public @interface KeepGettersAndSetters {
-}
+public @interface KeepGettersAndSetters {}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/CompositeReactPackage.java b/ReactAndroid/src/main/java/com/facebook/react/CompositeReactPackage.java
index 9450719098e..f033aed7e82 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/CompositeReactPackage.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/CompositeReactPackage.java
@@ -20,7 +20,6 @@ import java.util.ListIterator;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nullable;
-import com.facebook.react.TurboReactPackage;
/**
* {@code CompositeReactPackage} allows to create a single package composed of views and modules
@@ -50,14 +49,14 @@ public class CompositeReactPackage implements ViewManagerOnDemandReactPackage, R
final Map TODO: T45627020
*/
if (reactPackage instanceof TurboReactPackage) {
- TurboReactPackage turboReactPackage = (TurboReactPackage)reactPackage;
+ TurboReactPackage turboReactPackage = (TurboReactPackage) reactPackage;
ReactModuleInfoProvider moduleInfoProvider = turboReactPackage.getReactModuleInfoProvider();
Map This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react;
import com.facebook.react.bridge.ModuleSpec;
@@ -24,15 +23,13 @@ import javax.inject.Provider;
* view managers from).
*/
@ReactModuleList(
- nativeModules = {
- JSCHeapCapture.class,
- JSDevSupport.class,
- }
-)
+ nativeModules = {
+ JSCHeapCapture.class,
+ JSDevSupport.class,
+ })
/* package */ class DebugCorePackage extends LazyReactPackage {
- DebugCorePackage() {
- }
+ DebugCorePackage() {}
@Override
public List This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react;
-import javax.annotation.Nullable;
-
-import java.util.Set;
-import java.util.concurrent.CopyOnWriteArraySet;
-
import android.annotation.SuppressLint;
import android.app.Service;
import android.content.BroadcastReceiver;
@@ -19,23 +13,25 @@ import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.os.PowerManager;
-
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.UiThreadUtil;
-import com.facebook.react.jstasks.HeadlessJsTaskEventListener;
import com.facebook.react.jstasks.HeadlessJsTaskConfig;
import com.facebook.react.jstasks.HeadlessJsTaskContext;
+import com.facebook.react.jstasks.HeadlessJsTaskEventListener;
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArraySet;
+import javax.annotation.Nullable;
/**
- * Base class for running JS without a UI. Generally, you only need to override
- * {@link #getTaskConfig}, which is called for every {@link #onStartCommand}. The
- * result, if not {@code null}, is used to run a JS task.
+ * Base class for running JS without a UI. Generally, you only need to override {@link
+ * #getTaskConfig}, which is called for every {@link #onStartCommand}. The result, if not {@code
+ * null}, is used to run a JS task.
*
- * If you need more fine-grained control over how tasks are run, you can override
- * {@link #onStartCommand} and call {@link #startTask} depending on your custom logic.
+ * If you need more fine-grained control over how tasks are run, you can override {@link
+ * #onStartCommand} and call {@link #startTask} depending on your custom logic.
*
- * If you're starting a {@code HeadlessJsTaskService} from a {@code BroadcastReceiver} (e.g.
+ * If you're starting a {@code HeadlessJsTaskService} from a {@code BroadcastReceiver} (e.g.
* handling push notifications), make sure to call {@link #acquireWakeLockNow} before returning from
* {@link BroadcastReceiver#onReceive}, to make sure the device doesn't go to sleep before the
* service is started.
@@ -57,9 +53,10 @@ public abstract class HeadlessJsTaskService extends Service implements HeadlessJ
/**
* Called from {@link #onStartCommand} to create a {@link HeadlessJsTaskConfig} for this intent.
+ *
* @param intent the {@link Intent} received in {@link #onStartCommand}.
- * @return a {@link HeadlessJsTaskConfig} to be used with {@link #startTask}, or
- * {@code null} to ignore this command.
+ * @return a {@link HeadlessJsTaskConfig} to be used with {@link #startTask}, or {@code null} to
+ * ignore this command.
*/
protected @Nullable HeadlessJsTaskConfig getTaskConfig(Intent intent) {
return null;
@@ -72,10 +69,10 @@ public abstract class HeadlessJsTaskService extends Service implements HeadlessJ
public static void acquireWakeLockNow(Context context) {
if (sWakeLock == null || !sWakeLock.isHeld()) {
PowerManager powerManager =
- Assertions.assertNotNull((PowerManager) context.getSystemService(POWER_SERVICE));
- sWakeLock = powerManager.newWakeLock(
- PowerManager.PARTIAL_WAKE_LOCK,
- HeadlessJsTaskService.class.getCanonicalName());
+ Assertions.assertNotNull((PowerManager) context.getSystemService(POWER_SERVICE));
+ sWakeLock =
+ powerManager.newWakeLock(
+ PowerManager.PARTIAL_WAKE_LOCK, HeadlessJsTaskService.class.getCanonicalName());
sWakeLock.setReferenceCounted(false);
sWakeLock.acquire();
}
@@ -89,7 +86,7 @@ public abstract class HeadlessJsTaskService extends Service implements HeadlessJ
/**
* Start a task. This method handles starting a new React instance if required.
*
- * Has to be called on the UI thread.
+ * Has to be called on the UI thread.
*
* @param taskConfig describes what task to start and the parameters to pass to it
*/
@@ -97,17 +94,17 @@ public abstract class HeadlessJsTaskService extends Service implements HeadlessJ
UiThreadUtil.assertOnUiThread();
acquireWakeLockNow(this);
final ReactInstanceManager reactInstanceManager =
- getReactNativeHost().getReactInstanceManager();
+ getReactNativeHost().getReactInstanceManager();
ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
if (reactContext == null) {
- reactInstanceManager
- .addReactInstanceEventListener(new ReactInstanceManager.ReactInstanceEventListener() {
- @Override
- public void onReactContextInitialized(ReactContext reactContext) {
- invokeStartTask(reactContext, taskConfig);
- reactInstanceManager.removeReactInstanceEventListener(this);
- }
- });
+ reactInstanceManager.addReactInstanceEventListener(
+ new ReactInstanceManager.ReactInstanceEventListener() {
+ @Override
+ public void onReactContextInitialized(ReactContext reactContext) {
+ invokeStartTask(reactContext, taskConfig);
+ reactInstanceManager.removeReactInstanceEventListener(this);
+ }
+ });
reactInstanceManager.createReactContextInBackground();
} else {
invokeStartTask(reactContext, taskConfig);
@@ -115,18 +112,18 @@ public abstract class HeadlessJsTaskService extends Service implements HeadlessJ
}
private void invokeStartTask(ReactContext reactContext, final HeadlessJsTaskConfig taskConfig) {
- final HeadlessJsTaskContext headlessJsTaskContext = HeadlessJsTaskContext.getInstance(reactContext);
+ final HeadlessJsTaskContext headlessJsTaskContext =
+ HeadlessJsTaskContext.getInstance(reactContext);
headlessJsTaskContext.addTaskEventListener(this);
UiThreadUtil.runOnUiThread(
- new Runnable() {
- @Override
- public void run() {
- int taskId = headlessJsTaskContext.startTask(taskConfig);
- mActiveTasks.add(taskId);
- }
- }
- );
+ new Runnable() {
+ @Override
+ public void run() {
+ int taskId = headlessJsTaskContext.startTask(taskConfig);
+ mActiveTasks.add(taskId);
+ }
+ });
}
@Override
@@ -138,7 +135,7 @@ public abstract class HeadlessJsTaskService extends Service implements HeadlessJ
ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
if (reactContext != null) {
HeadlessJsTaskContext headlessJsTaskContext =
- HeadlessJsTaskContext.getInstance(reactContext);
+ HeadlessJsTaskContext.getInstance(reactContext);
headlessJsTaskContext.removeTaskEventListener(this);
}
}
@@ -148,7 +145,7 @@ public abstract class HeadlessJsTaskService extends Service implements HeadlessJ
}
@Override
- public void onHeadlessJsTaskStart(int taskId) { }
+ public void onHeadlessJsTaskStart(int taskId) {}
@Override
public void onHeadlessJsTaskFinish(int taskId) {
@@ -160,10 +157,10 @@ public abstract class HeadlessJsTaskService extends Service implements HeadlessJ
/**
* Get the {@link ReactNativeHost} used by this app. By default, assumes {@link #getApplication()}
- * is an instance of {@link ReactApplication} and calls
- * {@link ReactApplication#getReactNativeHost()}. Override this method if your application class
- * does not implement {@code ReactApplication} or you simply have a different mechanism for
- * storing a {@code ReactNativeHost}, e.g. as a static field somewhere.
+ * is an instance of {@link ReactApplication} and calls {@link
+ * ReactApplication#getReactNativeHost()}. Override this method if your application class does not
+ * implement {@code ReactApplication} or you simply have a different mechanism for storing a
+ * {@code ReactNativeHost}, e.g. as a static field somewhere.
*/
protected ReactNativeHost getReactNativeHost() {
return ((ReactApplication) getApplication()).getReactNativeHost();
diff --git a/ReactAndroid/src/main/java/com/facebook/react/LazyReactPackage.java b/ReactAndroid/src/main/java/com/facebook/react/LazyReactPackage.java
index 5c8217b1b93..7e07760f639 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/LazyReactPackage.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/LazyReactPackage.java
@@ -76,7 +76,8 @@ public abstract class LazyReactPackage implements ReactPackage {
* @param reactContext
* @return
*/
- public Iterable This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react;
-import javax.annotation.Nullable;
-
import android.content.Intent;
import android.os.Bundle;
-import androidx.appcompat.app.AppCompatActivity;
import android.view.KeyEvent;
-
+import androidx.appcompat.app.AppCompatActivity;
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
import com.facebook.react.modules.core.PermissionAwareActivity;
import com.facebook.react.modules.core.PermissionListener;
+import javax.annotation.Nullable;
-/**
- * Base Activity for React Native applications.
- */
+/** Base Activity for React Native applications. */
public abstract class ReactActivity extends AppCompatActivity
implements DefaultHardwareBackBtnHandler, PermissionAwareActivity {
@@ -31,17 +26,14 @@ public abstract class ReactActivity extends AppCompatActivity
}
/**
- * Returns the name of the main component registered from JavaScript.
- * This is used to schedule rendering of the component.
- * e.g. "MoviesApp"
+ * Returns the name of the main component registered from JavaScript. This is used to schedule
+ * rendering of the component. e.g. "MoviesApp"
*/
protected @Nullable String getMainComponentName() {
return null;
}
- /**
- * Called at construction time, override if you have a custom delegate implementation.
- */
+ /** Called at construction time, override if you have a custom delegate implementation. */
protected ReactActivityDelegate createReactActivityDelegate() {
return new ReactActivityDelegate(this, getMainComponentName());
}
@@ -111,17 +103,13 @@ public abstract class ReactActivity extends AppCompatActivity
@Override
public void requestPermissions(
- String[] permissions,
- int requestCode,
- PermissionListener listener) {
+ String[] permissions, int requestCode, PermissionListener listener) {
mDelegate.requestPermissions(permissions, requestCode, listener);
}
@Override
public void onRequestPermissionsResult(
- int requestCode,
- String[] permissions,
- int[] grantResults) {
+ int requestCode, String[] permissions, int[] grantResults) {
mDelegate.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java
index fcfbea9b4d3..199d9bf6a41 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java
@@ -12,12 +12,9 @@ import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.KeyEvent;
-
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.Callback;
-import com.facebook.react.uimanager.RootView;
import com.facebook.react.modules.core.PermissionListener;
-
import javax.annotation.Nullable;
/**
@@ -54,11 +51,11 @@ public class ReactActivityDelegate {
}
/**
- * Get the {@link ReactNativeHost} used by this app. By default, assumes
- * {@link Activity#getApplication()} is an instance of {@link ReactApplication} and calls
- * {@link ReactApplication#getReactNativeHost()}. Override this method if your application class
- * does not implement {@code ReactApplication} or you simply have a different mechanism for
- * storing a {@code ReactNativeHost}, e.g. as a static field somewhere.
+ * Get the {@link ReactNativeHost} used by this app. By default, assumes {@link
+ * Activity#getApplication()} is an instance of {@link ReactApplication} and calls {@link
+ * ReactApplication#getReactNativeHost()}. Override this method if your application class does not
+ * implement {@code ReactApplication} or you simply have a different mechanism for storing a
+ * {@code ReactNativeHost}, e.g. as a static field somewhere.
*/
protected ReactNativeHost getReactNativeHost() {
return ((ReactApplication) getPlainActivity().getApplication()).getReactNativeHost();
@@ -74,7 +71,9 @@ public class ReactActivityDelegate {
protected void onCreate(Bundle savedInstanceState) {
String mainComponentName = getMainComponentName();
- mReactDelegate = new ReactDelegate(getPlainActivity(), getReactNativeHost(), mainComponentName, getLaunchOptions());
+ mReactDelegate =
+ new ReactDelegate(
+ getPlainActivity(), getReactNativeHost(), mainComponentName, getLaunchOptions());
if (mMainComponentName != null) {
loadApp(mainComponentName);
}
@@ -108,8 +107,8 @@ public class ReactActivityDelegate {
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (getReactNativeHost().hasInstance()
- && getReactNativeHost().getUseDeveloperSupport()
- && keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD) {
+ && getReactNativeHost().getUseDeveloperSupport()
+ && keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD) {
event.startTracking();
return true;
}
@@ -150,25 +149,24 @@ public class ReactActivityDelegate {
@TargetApi(Build.VERSION_CODES.M)
public void requestPermissions(
- String[] permissions,
- int requestCode,
- PermissionListener listener) {
+ String[] permissions, int requestCode, PermissionListener listener) {
mPermissionListener = listener;
getPlainActivity().requestPermissions(permissions, requestCode);
}
public void onRequestPermissionsResult(
- final int requestCode,
- final String[] permissions,
- final int[] grantResults) {
- mPermissionsCallback = new Callback() {
- @Override
- public void invoke(Object... args) {
- if (mPermissionListener != null && mPermissionListener.onRequestPermissionsResult(requestCode, permissions, grantResults)) {
- mPermissionListener = null;
- }
- }
- };
+ final int requestCode, final String[] permissions, final int[] grantResults) {
+ mPermissionsCallback =
+ new Callback() {
+ @Override
+ public void invoke(Object... args) {
+ if (mPermissionListener != null
+ && mPermissionListener.onRequestPermissionsResult(
+ requestCode, permissions, grantResults)) {
+ mPermissionListener = null;
+ }
+ }
+ };
}
protected Context getContext() {
diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactAndroidHWInputDeviceHelper.java b/ReactAndroid/src/main/java/com/facebook/react/ReactAndroidHWInputDeviceHelper.java
index de1df519d37..7168f89f1ce 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/ReactAndroidHWInputDeviceHelper.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/ReactAndroidHWInputDeviceHelper.java
@@ -1,47 +1,42 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react;
import android.view.KeyEvent;
import android.view.View;
-
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeMap;
import com.facebook.react.common.MapBuilder;
-
import java.util.Map;
-/**
- * Responsible for dispatching events specific for hardware inputs.
- */
+/** Responsible for dispatching events specific for hardware inputs. */
public class ReactAndroidHWInputDeviceHelper {
/**
- * Contains a mapping between handled KeyEvents and the corresponding navigation event
- * that should be fired when the KeyEvent is received.
+ * Contains a mapping between handled KeyEvents and the corresponding navigation event that should
+ * be fired when the KeyEvent is received.
*/
- private static final Map This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react;
public interface ReactApplication {
- /**
- * Get the default {@link ReactNativeHost} for this app.
- */
+ /** Get the default {@link ReactNativeHost} for this app. */
ReactNativeHost getReactNativeHost();
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/ReactDelegate.java
index e219c8be3c6..99aef296725 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/ReactDelegate.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/ReactDelegate.java
@@ -1,21 +1,18 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
-
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.devsupport.DoubleTapReloadRecognizer;
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
-
import javax.annotation.Nullable;
/**
@@ -27,19 +24,19 @@ public class ReactDelegate {
private final Activity mActivity;
private ReactRootView mReactRootView;
- @Nullable
- private final String mMainComponentName;
+ @Nullable private final String mMainComponentName;
- @Nullable
- private Bundle mLaunchOptions;
+ @Nullable private Bundle mLaunchOptions;
- @Nullable
- private DoubleTapReloadRecognizer mDoubleTapReloadRecognizer;
+ @Nullable private DoubleTapReloadRecognizer mDoubleTapReloadRecognizer;
private ReactNativeHost mReactNativeHost;
-
- public ReactDelegate(Activity activity, ReactNativeHost reactNativeHost, @Nullable String appKey, @Nullable Bundle launchOptions) {
+ public ReactDelegate(
+ Activity activity,
+ ReactNativeHost reactNativeHost,
+ @Nullable String appKey,
+ @Nullable Bundle launchOptions) {
mActivity = activity;
mMainComponentName = appKey;
mLaunchOptions = launchOptions;
@@ -50,9 +47,12 @@ public class ReactDelegate {
public void onHostResume() {
if (getReactNativeHost().hasInstance()) {
if (mActivity instanceof DefaultHardwareBackBtnHandler) {
- getReactNativeHost().getReactInstanceManager().onHostResume(mActivity, (DefaultHardwareBackBtnHandler) mActivity);
+ getReactNativeHost()
+ .getReactInstanceManager()
+ .onHostResume(mActivity, (DefaultHardwareBackBtnHandler) mActivity);
} else {
- throw new ClassCastException("Host Activity does not implement DefaultHardwareBackBtnHandler");
+ throw new ClassCastException(
+ "Host Activity does not implement DefaultHardwareBackBtnHandler");
}
}
}
@@ -81,9 +81,12 @@ public class ReactDelegate {
return false;
}
- public void onActivityResult(int requestCode, int resultCode, Intent data, boolean shouldForwardToReactInstance) {
+ public void onActivityResult(
+ int requestCode, int resultCode, Intent data, boolean shouldForwardToReactInstance) {
if (getReactNativeHost().hasInstance() && shouldForwardToReactInstance) {
- getReactNativeHost().getReactInstanceManager().onActivityResult(mActivity, requestCode, resultCode, data);
+ getReactNativeHost()
+ .getReactInstanceManager()
+ .onActivityResult(mActivity, requestCode, resultCode, data);
}
}
@@ -97,26 +100,23 @@ public class ReactDelegate {
}
mReactRootView = createRootView();
mReactRootView.startReactApplication(
- getReactNativeHost().getReactInstanceManager(),
- appKey,
- mLaunchOptions);
-
+ getReactNativeHost().getReactInstanceManager(), appKey, mLaunchOptions);
}
public ReactRootView getReactRootView() {
return mReactRootView;
}
-
protected ReactRootView createRootView() {
return new ReactRootView(mActivity);
}
/**
- * Handles delegating the {@link Activity#onKeyUp(int, KeyEvent)} method to determine whether
- * the application should show the developer menu or should reload the React Application.
+ * Handles delegating the {@link Activity#onKeyUp(int, KeyEvent)} method to determine whether the
+ * application should show the developer menu or should reload the React Application.
*
- * @return true if we consume the event and either shoed the develop menu or reloaded the application.
+ * @return true if we consume the event and either shoed the develop menu or reloaded the
+ * application.
*/
public boolean shouldShowDevMenuOrReload(int keyCode, KeyEvent event) {
if (getReactNativeHost().hasInstance() && getReactNativeHost().getUseDeveloperSupport()) {
@@ -124,7 +124,9 @@ public class ReactDelegate {
getReactNativeHost().getReactInstanceManager().showDevOptionsDialog();
return true;
}
- boolean didDoubleTapR = Assertions.assertNotNull(mDoubleTapReloadRecognizer).didDoubleTapR(keyCode, mActivity.getCurrentFocus());
+ boolean didDoubleTapR =
+ Assertions.assertNotNull(mDoubleTapReloadRecognizer)
+ .didDoubleTapR(keyCode, mActivity.getCurrentFocus());
if (didDoubleTapR) {
getReactNativeHost().getReactInstanceManager().getDevSupportManager().handleReloadJS();
return true;
@@ -133,9 +135,7 @@ public class ReactDelegate {
return false;
}
- /**
- * Get the {@link ReactNativeHost} used by this app.
- */
+ /** Get the {@link ReactNativeHost} used by this app. */
private ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@@ -143,5 +143,4 @@ public class ReactDelegate {
public ReactInstanceManager getReactInstanceManager() {
return getReactNativeHost().getReactInstanceManager();
}
-
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactFragment.java b/ReactAndroid/src/main/java/com/facebook/react/ReactFragment.java
index 6673c895527..34ed7aa3452 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/ReactFragment.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/ReactFragment.java
@@ -1,11 +1,9 @@
-
/**
-* Copyright (c) Facebook, Inc. and its affiliates.
-*
-* This source code is licensed under the MIT license found in the
-* LICENSE file in the root directory of this source tree.
-*/
-
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
+ */
package com.facebook.react;
import android.annotation.TargetApi;
@@ -17,194 +15,188 @@ import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-
+import androidx.fragment.app.Fragment;
import com.facebook.react.modules.core.PermissionAwareActivity;
import com.facebook.react.modules.core.PermissionListener;
-
import javax.annotation.Nullable;
-import androidx.fragment.app.Fragment;
-
/**
-* Fragment for creating a React View. This allows the developer to "embed" a React Application
-* inside native components such as a Drawer, ViewPager, etc.
-*/
+ * Fragment for creating a React View. This allows the developer to "embed" a React Application
+ * inside native components such as a Drawer, ViewPager, etc.
+ */
public class ReactFragment extends Fragment implements PermissionAwareActivity {
-private static final String ARG_COMPONENT_NAME = "arg_component_name";
-private static final String ARG_LAUNCH_OPTIONS = "arg_launch_options";
+ private static final String ARG_COMPONENT_NAME = "arg_component_name";
+ private static final String ARG_LAUNCH_OPTIONS = "arg_launch_options";
-private ReactDelegate mReactDelegate;
+ private ReactDelegate mReactDelegate;
-@Nullable
-private PermissionListener mPermissionListener;
+ @Nullable private PermissionListener mPermissionListener;
-
-public ReactFragment() {
- // Required empty public constructor
-}
-
-/**
- * @param componentName The name of the react native component
- * @return A new instance of fragment ReactFragment.
- */
-private static ReactFragment newInstance(String componentName, Bundle launchOptions) {
- ReactFragment fragment = new ReactFragment();
- Bundle args = new Bundle();
- args.putString(ARG_COMPONENT_NAME, componentName);
- args.putBundle(ARG_LAUNCH_OPTIONS, launchOptions);
- fragment.setArguments(args);
- return fragment;
-}
-
-// region Lifecycle
-@Override
-public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- String mainComponentName = null;
- Bundle launchOptions = null;
- if (getArguments() != null) {
- mainComponentName = getArguments().getString(ARG_COMPONENT_NAME);
- launchOptions = getArguments().getBundle(ARG_LAUNCH_OPTIONS);
- }
- if (mainComponentName == null) {
- throw new IllegalStateException("Cannot loadApp if component name is null");
- }
- mReactDelegate = new ReactDelegate(getActivity(), getReactNativeHost(), mainComponentName, launchOptions);
-}
-
-/**
- * Get the {@link ReactNativeHost} used by this app. By default, assumes
- * {@link Activity#getApplication()} is an instance of {@link ReactApplication} and calls
- * {@link ReactApplication#getReactNativeHost()}. Override this method if your application class
- * does not implement {@code ReactApplication} or you simply have a different mechanism for
- * storing a {@code ReactNativeHost}, e.g. as a static field somewhere.
- */
-protected ReactNativeHost getReactNativeHost() {
- return ((ReactApplication) getActivity().getApplication()).getReactNativeHost();
-}
-
-@Override
-public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- mReactDelegate.loadApp();
- return mReactDelegate.getReactRootView();
-}
-
-@Override
-public void onResume() {
- super.onResume();
- mReactDelegate.onHostResume();
-}
-
-@Override
-public void onPause() {
- super.onPause();
- mReactDelegate.onHostPause();
-}
-
-@Override
-public void onDestroy() {
- super.onDestroy();
- mReactDelegate.onHostDestroy();
-}
-// endregion
-
-@Override
-public void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- mReactDelegate.onActivityResult(requestCode, resultCode, data, false);
-}
-
-/**
- * Helper to forward hardware back presses to our React Native Host
- *
- * This must be called via a forward from your host Activity
- *
- */
-public boolean onBackPressed() {
- return mReactDelegate.onBackPressed();
-}
-
-/**
- * Helper to forward onKeyUp commands from our host Activity.
- * This allows ReactFragment to handle double tap reloads and dev menus
- *
- * This must be called via a forward from your host Activity
- *
- * @param keyCode keyCode
- * @param event event
- * @return true if we handled onKeyUp
- */
-public boolean onKeyUp(int keyCode, KeyEvent event) {
- return mReactDelegate.shouldShowDevMenuOrReload(keyCode, event);
-}
-
-@Override
-public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
- super.onRequestPermissionsResult(requestCode, permissions, grantResults);
- if (mPermissionListener != null &&
- mPermissionListener.onRequestPermissionsResult(requestCode, permissions, grantResults)) {
- mPermissionListener = null;
- }
-}
-
-@Override
-public int checkPermission(String permission, int pid, int uid) {
- return getActivity().checkPermission(permission, pid, uid);
-}
-
-@TargetApi(Build.VERSION_CODES.M)
-@Override
-public int checkSelfPermission(String permission) {
- return getActivity().checkSelfPermission(permission);
-}
-
-@TargetApi(Build.VERSION_CODES.M)
-@Override
-public void requestPermissions(String[] permissions, int requestCode, PermissionListener listener) {
- mPermissionListener = listener;
- requestPermissions(permissions, requestCode);
-}
-
-/**
- * Builder class to help instantiate a ReactFragment
- */
-public static class Builder {
-
- String mComponentName;
- Bundle mLaunchOptions;
-
- public Builder() {
- mComponentName = null;
- mLaunchOptions = null;
+ public ReactFragment() {
+ // Required empty public constructor
}
/**
- * Set the Component name for our React Native instance.
- *
- * @param componentName The name of the component
- * @return Builder
+ * @param componentName The name of the react native component
+ * @return A new instance of fragment ReactFragment.
*/
- public Builder setComponentName(String componentName) {
- mComponentName = componentName;
- return this;
+ private static ReactFragment newInstance(String componentName, Bundle launchOptions) {
+ ReactFragment fragment = new ReactFragment();
+ Bundle args = new Bundle();
+ args.putString(ARG_COMPONENT_NAME, componentName);
+ args.putBundle(ARG_LAUNCH_OPTIONS, launchOptions);
+ fragment.setArguments(args);
+ return fragment;
+ }
+
+ // region Lifecycle
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ String mainComponentName = null;
+ Bundle launchOptions = null;
+ if (getArguments() != null) {
+ mainComponentName = getArguments().getString(ARG_COMPONENT_NAME);
+ launchOptions = getArguments().getBundle(ARG_LAUNCH_OPTIONS);
+ }
+ if (mainComponentName == null) {
+ throw new IllegalStateException("Cannot loadApp if component name is null");
+ }
+ mReactDelegate =
+ new ReactDelegate(getActivity(), getReactNativeHost(), mainComponentName, launchOptions);
}
/**
- * Set the Launch Options for our React Native instance.
- *
- * @param launchOptions launchOptions
- * @return Builder
+ * Get the {@link ReactNativeHost} used by this app. By default, assumes {@link
+ * Activity#getApplication()} is an instance of {@link ReactApplication} and calls {@link
+ * ReactApplication#getReactNativeHost()}. Override this method if your application class does not
+ * implement {@code ReactApplication} or you simply have a different mechanism for storing a
+ * {@code ReactNativeHost}, e.g. as a static field somewhere.
*/
- public Builder setLaunchOptions(Bundle launchOptions) {
- mLaunchOptions = launchOptions;
- return this;
+ protected ReactNativeHost getReactNativeHost() {
+ return ((ReactApplication) getActivity().getApplication()).getReactNativeHost();
}
- public ReactFragment build() {
- return ReactFragment.newInstance(mComponentName, mLaunchOptions);
+ @Override
+ public View onCreateView(
+ LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ mReactDelegate.loadApp();
+ return mReactDelegate.getReactRootView();
}
-}
+ @Override
+ public void onResume() {
+ super.onResume();
+ mReactDelegate.onHostResume();
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ mReactDelegate.onHostPause();
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ mReactDelegate.onHostDestroy();
+ }
+ // endregion
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+ mReactDelegate.onActivityResult(requestCode, resultCode, data, false);
+ }
+
+ /**
+ * Helper to forward hardware back presses to our React Native Host
+ *
+ * This must be called via a forward from your host Activity
+ */
+ public boolean onBackPressed() {
+ return mReactDelegate.onBackPressed();
+ }
+
+ /**
+ * Helper to forward onKeyUp commands from our host Activity. This allows ReactFragment to handle
+ * double tap reloads and dev menus
+ *
+ * This must be called via a forward from your host Activity
+ *
+ * @param keyCode keyCode
+ * @param event event
+ * @return true if we handled onKeyUp
+ */
+ public boolean onKeyUp(int keyCode, KeyEvent event) {
+ return mReactDelegate.shouldShowDevMenuOrReload(keyCode, event);
+ }
+
+ @Override
+ public void onRequestPermissionsResult(
+ int requestCode, String[] permissions, int[] grantResults) {
+ super.onRequestPermissionsResult(requestCode, permissions, grantResults);
+ if (mPermissionListener != null
+ && mPermissionListener.onRequestPermissionsResult(requestCode, permissions, grantResults)) {
+ mPermissionListener = null;
+ }
+ }
+
+ @Override
+ public int checkPermission(String permission, int pid, int uid) {
+ return getActivity().checkPermission(permission, pid, uid);
+ }
+
+ @TargetApi(Build.VERSION_CODES.M)
+ @Override
+ public int checkSelfPermission(String permission) {
+ return getActivity().checkSelfPermission(permission);
+ }
+
+ @TargetApi(Build.VERSION_CODES.M)
+ @Override
+ public void requestPermissions(
+ String[] permissions, int requestCode, PermissionListener listener) {
+ mPermissionListener = listener;
+ requestPermissions(permissions, requestCode);
+ }
+
+ /** Builder class to help instantiate a ReactFragment */
+ public static class Builder {
+
+ String mComponentName;
+ Bundle mLaunchOptions;
+
+ public Builder() {
+ mComponentName = null;
+ mLaunchOptions = null;
+ }
+
+ /**
+ * Set the Component name for our React Native instance.
+ *
+ * @param componentName The name of the component
+ * @return Builder
+ */
+ public Builder setComponentName(String componentName) {
+ mComponentName = componentName;
+ return this;
+ }
+
+ /**
+ * Set the Launch Options for our React Native instance.
+ *
+ * @param launchOptions launchOptions
+ * @return Builder
+ */
+ public Builder setLaunchOptions(Bundle launchOptions) {
+ mLaunchOptions = launchOptions;
+ return this;
+ }
+
+ public ReactFragment build() {
+ return ReactFragment.newInstance(mComponentName, mLaunchOptions);
+ }
+ }
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactFragmentActivity.java b/ReactAndroid/src/main/java/com/facebook/react/ReactFragmentActivity.java
index 029909d47cd..131e97c2c1c 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/ReactFragmentActivity.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/ReactFragmentActivity.java
@@ -1,17 +1,14 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react;
/**
- * @deprecated
- * ReactFragmentActivity will be removed in 0.59 release.
- * Use {@link ReactActivity} instead.
+ * @deprecated ReactFragmentActivity will be removed in 0.59 release. Use {@link ReactActivity}
+ * instead.
*/
@Deprecated
-public abstract class ReactFragmentActivity extends ReactActivity {
-}
+public abstract class ReactFragmentActivity extends ReactActivity {}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java
index 3bbe584ecf9..4c7dde79712 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java
@@ -1,10 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react;
import static com.facebook.infer.annotation.ThreadConfined.UI;
@@ -12,6 +11,7 @@ import static com.facebook.react.bridge.ReactMarkerConstants.ATTACH_MEASURED_ROO
import static com.facebook.react.bridge.ReactMarkerConstants.ATTACH_MEASURED_ROOT_VIEWS_START;
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.CHANGE_THREAD_PRIORITY;
import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_CATALYST_INSTANCE_END;
import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_CATALYST_INSTANCE_START;
import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_REACT_CONTEXT_START;
@@ -25,7 +25,6 @@ import static com.facebook.react.bridge.ReactMarkerConstants.REACT_CONTEXT_THREA
import static com.facebook.react.bridge.ReactMarkerConstants.REACT_CONTEXT_THREAD_START;
import static com.facebook.react.bridge.ReactMarkerConstants.SETUP_REACT_CONTEXT_END;
import static com.facebook.react.bridge.ReactMarkerConstants.SETUP_REACT_CONTEXT_START;
-import static com.facebook.react.bridge.ReactMarkerConstants.CHANGE_THREAD_PRIORITY;
import static com.facebook.react.bridge.ReactMarkerConstants.VM_INIT;
import static com.facebook.react.uimanager.common.UIManagerType.FABRIC;
import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_APPS;
@@ -38,9 +37,9 @@ import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Process;
-import androidx.core.view.ViewCompat;
import android.util.Log;
import android.view.View;
+import androidx.core.view.ViewCompat;
import com.facebook.common.logging.FLog;
import com.facebook.debug.holder.PrinterHolder;
import com.facebook.debug.tags.ReactDebugOverlayTags;
@@ -107,28 +106,26 @@ import javax.annotation.Nullable;
/**
* This class is managing instances of {@link CatalystInstance}. It exposes a way to configure
- * catalyst instance using {@link ReactPackage} and keeps track of the lifecycle of that
- * instance. It also sets up connection between the instance and developers support functionality
- * of the framework.
+ * catalyst instance using {@link ReactPackage} and keeps track of the lifecycle of that instance.
+ * It also sets up connection between the instance and developers support functionality of the
+ * framework.
*
- * An instance of this manager is required to start JS application in {@link ReactRootView} (see
+ * An instance of this manager is required to start JS application in {@link ReactRootView} (see
* {@link ReactRootView#startReactApplication} for more info).
*
- * The lifecycle of the instance of {@link ReactInstanceManager} should be bound to the
- * activity that owns the {@link ReactRootView} that is used to render react application using this
- * instance manager (see {@link ReactRootView#startReactApplication}). It's required to pass owning
+ * The lifecycle of the instance of {@link ReactInstanceManager} should be bound to the activity
+ * that owns the {@link ReactRootView} that is used to render react application using this instance
+ * manager (see {@link ReactRootView#startReactApplication}). It's required to pass owning
* activity's lifecycle events to the instance manager (see {@link #onHostPause}, {@link
* #onHostDestroy} and {@link #onHostResume}).
*
- * To instantiate an instance of this class use {@link #builder}.
+ * To instantiate an instance of this class use {@link #builder}.
*/
@ThreadSafe
public class ReactInstanceManager {
private static final String TAG = ReactInstanceManager.class.getSimpleName();
- /**
- * Listener interface for react instance events.
- */
+ /** Listener interface for react instance events. */
public interface ReactInstanceEventListener {
/**
@@ -138,8 +135,8 @@ public class ReactInstanceManager {
void onReactContextInitialized(ReactContext context);
}
- private final Set Called from UI thread.
*/
@ThreadConfined(UI)
public void createReactContextInBackground() {
@@ -351,8 +345,8 @@ public class ReactInstanceManager {
public void recreateReactContextInBackground() {
Assertions.assertCondition(
mHasStartedCreatingInitialContext,
- "recreateReactContextInBackground should only be called after the initial " +
- "createReactContextInBackground call.");
+ "recreateReactContextInBackground should only be called after the initial "
+ + "createReactContextInBackground call.");
recreateReactContextInBackgroundInner();
}
@@ -367,8 +361,8 @@ public class ReactInstanceManager {
final DeveloperSettings devSettings = mDevSupportManager.getDevSettings();
// If remote JS debugging is enabled, load from dev server.
- if (mDevSupportManager.hasUpToDateJSBundleInCache() &&
- !devSettings.isRemoteJSDebugEnabled()) {
+ if (mDevSupportManager.hasUpToDateJSBundleInCache()
+ && !devSettings.isRemoteJSDebugEnabled()) {
// If there is a up-to-date bundle downloaded from server,
// with remote JS debugging disabled, always use that.
onJSBundleLoadedFromServer(null);
@@ -409,8 +403,8 @@ public class ReactInstanceManager {
@ThreadConfined(UI)
private void recreateReactContextInBackgroundFromBundleLoader() {
Log.d(
- ReactConstants.TAG,
- "ReactInstanceManager.recreateReactContextInBackgroundFromBundleLoader()");
+ ReactConstants.TAG,
+ "ReactInstanceManager.recreateReactContextInBackgroundFromBundleLoader()");
PrinterHolder.getPrinter()
.logMessage(ReactDebugOverlayTags.RN_CORE, "RNCore: load from BundleLoader");
recreateReactContextInBackground(mJavaScriptExecutorFactory, mBundleLoader);
@@ -418,7 +412,7 @@ public class ReactInstanceManager {
/**
* @return whether createReactContextInBackground has been called. Will return false after
- * onDestroy until a new initial context has been created.
+ * onDestroy until a new initial context has been created.
*/
public boolean hasStartedCreatingInitialContext() {
return mHasStartedCreatingInitialContext;
@@ -437,7 +431,7 @@ public class ReactInstanceManager {
invokeDefaultOnBackPressed();
} else {
DeviceEventManagerModule deviceEventManagerModule =
- reactContext.getNativeModule(DeviceEventManagerModule.class);
+ reactContext.getNativeModule(DeviceEventManagerModule.class);
deviceEventManagerModule.emitHardwareBackPressed();
}
}
@@ -449,9 +443,7 @@ public class ReactInstanceManager {
}
}
- /**
- * This method will give JS the opportunity to receive intents via Linking.
- */
+ /** This method will give JS the opportunity to receive intents via Linking. */
@ThreadConfined(UI)
public void onNewIntent(Intent intent) {
UiThreadUtil.assertOnUiThread();
@@ -464,7 +456,7 @@ public class ReactInstanceManager {
if (Intent.ACTION_VIEW.equals(action) && uri != null) {
DeviceEventManagerModule deviceEventManagerModule =
- currentContext.getNativeModule(DeviceEventManagerModule.class);
+ currentContext.getNativeModule(DeviceEventManagerModule.class);
deviceEventManagerModule.emitNewIntentReceived(uri);
}
currentContext.onNewIntent(mCurrentActivity, intent);
@@ -501,8 +493,8 @@ public class ReactInstanceManager {
/**
* Call this from {@link Activity#onPause()}. This notifies any listening modules so they can do
* any necessary cleanup. The passed Activity is the current Activity being paused. This will
- * always be the foreground activity that would be returned by
- * {@link ReactContext#getCurrentActivity()}.
+ * always be the foreground activity that would be returned by {@link
+ * ReactContext#getCurrentActivity()}.
*
* @param activity the activity being paused
*/
@@ -510,23 +502,26 @@ public class ReactInstanceManager {
public void onHostPause(Activity activity) {
Assertions.assertNotNull(mCurrentActivity);
Assertions.assertCondition(
- activity == mCurrentActivity,
- "Pausing an activity that is not the current activity, this is incorrect! " +
- "Current activity: " + mCurrentActivity.getClass().getSimpleName() + " " +
- "Paused activity: " + activity.getClass().getSimpleName());
+ activity == mCurrentActivity,
+ "Pausing an activity that is not the current activity, this is incorrect! "
+ + "Current activity: "
+ + mCurrentActivity.getClass().getSimpleName()
+ + " "
+ + "Paused activity: "
+ + activity.getClass().getSimpleName());
onHostPause();
}
/**
* Use this method when the activity resumes to enable invoking the back button directly from JS.
*
- * This method retains an instance to provided mDefaultBackButtonImpl. Thus it's important to pass
- * from the activity instance that owns this particular instance of {@link
- * ReactInstanceManager}, so that once this instance receive {@link #onHostDestroy} event it
- * will clear the reference to that defaultBackButtonImpl.
+ * This method retains an instance to provided mDefaultBackButtonImpl. Thus it's important to
+ * pass from the activity instance that owns this particular instance of {@link
+ * ReactInstanceManager}, so that once this instance receive {@link #onHostDestroy} event it will
+ * clear the reference to that defaultBackButtonImpl.
*
* @param defaultBackButtonImpl a {@link DefaultHardwareBackBtnHandler} from an Activity that owns
- * this instance of {@link ReactInstanceManager}.
+ * this instance of {@link ReactInstanceManager}.
*/
@ThreadConfined(UI)
public void onHostResume(Activity activity, DefaultHardwareBackBtnHandler defaultBackButtonImpl) {
@@ -536,9 +531,7 @@ public class ReactInstanceManager {
onHostResume(activity);
}
- /**
- * Use this method when the activity resumes.
- */
+ /** Use this method when the activity resumes. */
@ThreadConfined(UI)
public void onHostResume(Activity activity) {
UiThreadUtil.assertOnUiThread();
@@ -558,19 +551,20 @@ public class ReactInstanceManager {
// We check if activity is attached to window by checking if decor view is attached
final View decorView = mCurrentActivity.getWindow().getDecorView();
if (!ViewCompat.isAttachedToWindow(decorView)) {
- decorView.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
- @Override
- public void onViewAttachedToWindow(View v) {
- // we can drop listener now that we know the view is attached
- decorView.removeOnAttachStateChangeListener(this);
- mDevSupportManager.setDevSupportEnabled(true);
- }
+ decorView.addOnAttachStateChangeListener(
+ new View.OnAttachStateChangeListener() {
+ @Override
+ public void onViewAttachedToWindow(View v) {
+ // we can drop listener now that we know the view is attached
+ decorView.removeOnAttachStateChangeListener(this);
+ mDevSupportManager.setDevSupportEnabled(true);
+ }
- @Override
- public void onViewDetachedFromWindow(View v) {
- // do nothing
- }
- });
+ @Override
+ public void onViewDetachedFromWindow(View v) {
+ // do nothing
+ }
+ });
} else {
// activity is attached to window, we can enable dev support immediately
mDevSupportManager.setDevSupportEnabled(true);
@@ -612,9 +606,7 @@ public class ReactInstanceManager {
}
}
- /**
- * Destroy this React instance and the attached JS context.
- */
+ /** Destroy this React instance and the attached JS context. */
@ThreadConfined(UI)
public void destroy() {
UiThreadUtil.assertOnUiThread();
@@ -655,9 +647,9 @@ public class ReactInstanceManager {
ReactContext currentContext = getCurrentReactContext();
if (currentContext != null) {
// we currently don't have an onCreate callback so we call onResume for both transitions
- if (force ||
- mLifecycleState == LifecycleState.BEFORE_RESUME ||
- mLifecycleState == LifecycleState.BEFORE_CREATE) {
+ if (force
+ || mLifecycleState == LifecycleState.BEFORE_RESUME
+ || mLifecycleState == LifecycleState.BEFORE_CREATE) {
currentContext.onHostResume(mCurrentActivity);
}
}
@@ -729,9 +721,9 @@ public class ReactInstanceManager {
* Attach given {@param reactRoot} to a catalyst instance manager and start JS application using
* JS module provided by {@link ReactRootView#getJSModuleName}. If the react context is currently
* being (re)-created, or if react context has not been created yet, the JS application associated
- * with the provided reactRoot reactRoot will be started asynchronously, i.e this method won't block.
- * This reactRoot will then be tracked by this manager and in case of catalyst instance restart it will
- * be re-attached.
+ * with the provided reactRoot reactRoot will be started asynchronously, i.e this method won't
+ * block. This reactRoot will then be tracked by this manager and in case of catalyst instance
+ * restart it will be re-attached.
*/
@ThreadConfined(UI)
public void attachRootView(ReactRoot reactRoot) {
@@ -742,7 +734,8 @@ public class ReactInstanceManager {
clearReactRoot(reactRoot);
// If react context is being created in the background, JS application will be started
- // automatically when creation completes, as reactRoot reactRoot is part of the attached reactRoot reactRoot list.
+ // automatically when creation completes, as reactRoot reactRoot is part of the attached
+ // reactRoot reactRoot list.
ReactContext currentContext = getCurrentReactContext();
if (mCreateReactContextThread == null && currentContext != null) {
attachRootViewToInstance(reactRoot);
@@ -768,9 +761,7 @@ public class ReactInstanceManager {
}
}
- /**
- * Uses configured {@link ReactPackage} instances to create all view managers.
- */
+ /** Uses configured {@link ReactPackage} instances to create all view managers. */
public List Example: {@code "assets://index.android.js" or "/sdcard/main.jsbundle"}
*/
public ReactInstanceManagerBuilder setJSBundleFile(String jsBundleFile) {
if (jsBundleFile.startsWith("assets://")) {
@@ -108,10 +100,10 @@ public class ReactInstanceManagerBuilder {
}
/**
- * Bundle loader to use when setting up JS environment. This supersedes
- * prior invocations of {@link setJSBundleFile} and {@link setBundleAssetName}.
+ * Bundle loader to use when setting up JS environment. This supersedes prior invocations of
+ * {@link setJSBundleFile} and {@link setBundleAssetName}.
*
- * Example: {@code JSBundleLoader.createFileLoader(application, bundleFile)}
+ * Example: {@code JSBundleLoader.createFileLoader(application, bundleFile)}
*/
public ReactInstanceManagerBuilder setJSBundleLoader(JSBundleLoader jsBundleLoader) {
mJSBundleLoader = jsBundleLoader;
@@ -120,12 +112,9 @@ public class ReactInstanceManagerBuilder {
}
/**
- * Path to your app's main module on the packager server. This is used when
- * reloading JS during development. All paths are relative to the root folder
- * the packager is serving files from.
- * Examples:
- * {@code "index.android"} or
- * {@code "subdirectory/index.android"}
+ * Path to your app's main module on the packager server. This is used when reloading JS during
+ * development. All paths are relative to the root folder the packager is serving files from.
+ * Examples: {@code "index.android"} or {@code "subdirectory/index.android"}
*/
public ReactInstanceManagerBuilder setJSMainModulePath(String jsMainModulePath) {
mJSMainModulePath = jsMainModulePath;
@@ -143,14 +132,12 @@ public class ReactInstanceManagerBuilder {
}
public ReactInstanceManagerBuilder setBridgeIdleDebugListener(
- NotThreadSafeBridgeIdleDebugListener bridgeIdleDebugListener) {
+ NotThreadSafeBridgeIdleDebugListener bridgeIdleDebugListener) {
mBridgeIdleDebugListener = bridgeIdleDebugListener;
return this;
}
- /**
- * Required. This must be your {@code Application} instance.
- */
+ /** Required. This must be your {@code Application} instance. */
public ReactInstanceManagerBuilder setApplication(Application application) {
mApplication = application;
return this;
@@ -162,15 +149,15 @@ public class ReactInstanceManagerBuilder {
}
public ReactInstanceManagerBuilder setDefaultHardwareBackBtnHandler(
- DefaultHardwareBackBtnHandler defaultHardwareBackBtnHandler) {
+ DefaultHardwareBackBtnHandler defaultHardwareBackBtnHandler) {
mDefaultHardwareBackBtnHandler = defaultHardwareBackBtnHandler;
return this;
}
/**
- * When {@code true}, developer options such as JS reloading and debugging are enabled.
- * Note you still have to call {@link #showDevOptionsDialog} to show the dev menu,
- * e.g. when the device Menu button is pressed.
+ * When {@code true}, developer options such as JS reloading and debugging are enabled. Note you
+ * still have to call {@link #showDevOptionsDialog} to show the dev menu, e.g. when the device
+ * Menu button is pressed.
*/
public ReactInstanceManagerBuilder setUseDeveloperSupport(boolean useDeveloperSupport) {
mUseDeveloperSupport = useDeveloperSupport;
@@ -182,18 +169,18 @@ public class ReactInstanceManagerBuilder {
* creation time, we wouldn't expect an onResume call until we get an onPause call.
*/
public ReactInstanceManagerBuilder setInitialLifecycleState(
- LifecycleState initialLifecycleState) {
+ LifecycleState initialLifecycleState) {
mInitialLifecycleState = initialLifecycleState;
return this;
}
/**
- * Set the exception handler for all native module calls. If not set, the default
- * {@link DevSupportManager} will be used, which shows a redbox in dev mode and rethrows
- * (crashes the app) in prod mode.
+ * Set the exception handler for all native module calls. If not set, the default {@link
+ * DevSupportManager} will be used, which shows a redbox in dev mode and rethrows (crashes the
+ * app) in prod mode.
*/
public ReactInstanceManagerBuilder setNativeModuleCallExceptionHandler(
- NativeModuleCallExceptionHandler handler) {
+ NativeModuleCallExceptionHandler handler) {
mNativeModuleCallExceptionHandler = handler;
return this;
}
@@ -209,7 +196,7 @@ public class ReactInstanceManagerBuilder {
}
public ReactInstanceManagerBuilder setDevBundleDownloadListener(
- @Nullable DevBundleDownloadListener listener) {
+ @Nullable DevBundleDownloadListener listener) {
mDevBundleDownloadListener = listener;
return this;
}
@@ -232,33 +219,32 @@ public class ReactInstanceManagerBuilder {
}
/**
- * Instantiates a new {@link ReactInstanceManager}.
- * Before calling {@code build}, the following must be called:
+ * Instantiates a new {@link ReactInstanceManager}. Before calling {@code build}, the following
+ * must be called:
+ *
* This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react;
-import java.util.List;
-
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
+import java.util.List;
/**
- * A simple wrapper for ReactPackage to make it aware of its {@link ReactInstanceManager}
- * when creating native modules. This is useful when the package needs to ask
- * the instance manager for more information, like {@link DevSupportManager}.
+ * A simple wrapper for ReactPackage to make it aware of its {@link ReactInstanceManager} when
+ * creating native modules. This is useful when the package needs to ask the instance manager for
+ * more information, like {@link DevSupportManager}.
*
- * TODO(t11394819): Consolidate this with LazyReactPackage
- * Use {@link ReactPackage} or {@link LazyReactPackage} and inject reactInstanceManager as a part of when plugins are initialized.
+ * TODO(t11394819): Consolidate this with LazyReactPackage Use {@link ReactPackage} or {@link
+ * LazyReactPackage} and inject reactInstanceManager as a part of when plugins are initialized.
*/
@Deprecated
public abstract class ReactInstancePackage implements ReactPackage {
public abstract List This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react;
import android.app.Application;
@@ -32,9 +31,7 @@ public abstract class ReactNativeHost {
mApplication = application;
}
- /**
- * Get the current {@link ReactInstanceManager} instance, or create one.
- */
+ /** Get the current {@link ReactInstanceManager} instance, or create one. */
public ReactInstanceManager getReactInstanceManager() {
if (mReactInstanceManager == null) {
ReactMarker.logMarker(ReactMarkerConstants.GET_REACT_INSTANCE_MANAGER_START);
@@ -65,15 +62,16 @@ public abstract class ReactNativeHost {
protected ReactInstanceManager createReactInstanceManager() {
ReactMarker.logMarker(ReactMarkerConstants.BUILD_REACT_INSTANCE_MANAGER_START);
- ReactInstanceManagerBuilder builder = ReactInstanceManager.builder()
- .setApplication(mApplication)
- .setJSMainModulePath(getJSMainModuleName())
- .setUseDeveloperSupport(getUseDeveloperSupport())
- .setRedBoxHandler(getRedBoxHandler())
- .setJavaScriptExecutorFactory(getJavaScriptExecutorFactory())
- .setUIImplementationProvider(getUIImplementationProvider())
- .setJSIModulesPackage(getJSIModulePackage())
- .setInitialLifecycleState(LifecycleState.BEFORE_CREATE);
+ ReactInstanceManagerBuilder builder =
+ ReactInstanceManager.builder()
+ .setApplication(mApplication)
+ .setJSMainModulePath(getJSMainModuleName())
+ .setUseDeveloperSupport(getUseDeveloperSupport())
+ .setRedBoxHandler(getRedBoxHandler())
+ .setJavaScriptExecutorFactory(getJavaScriptExecutorFactory())
+ .setUIImplementationProvider(getUIImplementationProvider())
+ .setJSIModulesPackage(getJSIModulePackage())
+ .setInitialLifecycleState(LifecycleState.BEFORE_CREATE);
for (ReactPackage reactPackage : getPackages()) {
builder.addPackage(reactPackage);
@@ -90,17 +88,12 @@ public abstract class ReactNativeHost {
return reactInstanceManager;
}
- /**
- * Get the {@link RedBoxHandler} to send RedBox-related callbacks to.
- */
+ /** Get the {@link RedBoxHandler} to send RedBox-related callbacks to. */
protected @Nullable RedBoxHandler getRedBoxHandler() {
return null;
}
- /**
- * Get the {@link JavaScriptExecutorFactory}. Override this to use a custom
- * Executor.
- */
+ /** Get the {@link JavaScriptExecutorFactory}. Override this to use a custom Executor. */
protected @Nullable JavaScriptExecutorFactory getJavaScriptExecutorFactory() {
return null;
}
@@ -113,22 +106,20 @@ public abstract class ReactNativeHost {
* Get the {@link UIImplementationProvider} to use. Override this method if you want to use a
* custom UI implementation.
*
- * Note: this is very advanced functionality, in 99% of cases you don't need to override this.
+ * Note: this is very advanced functionality, in 99% of cases you don't need to override this.
*/
protected UIImplementationProvider getUIImplementationProvider() {
return new UIImplementationProvider();
}
- protected @Nullable
- JSIModulePackage getJSIModulePackage() {
+ protected @Nullable JSIModulePackage getJSIModulePackage() {
return null;
}
/**
- * Returns the name of the main module. Determines the URL used to fetch the JS bundle
- * from the packager server. It is only used when dev support is enabled.
- * This is the first file to be executed once the {@link ReactInstanceManager} is created.
- * e.g. "index.android"
+ * Returns the name of the main module. Determines the URL used to fetch the JS bundle from the
+ * packager server. It is only used when dev support is enabled. This is the first file to be
+ * executed once the {@link ReactInstanceManager} is created. e.g. "index.android"
*/
protected String getJSMainModuleName() {
return "index.android";
@@ -136,9 +127,8 @@ public abstract class ReactNativeHost {
/**
* Returns a custom path of the bundle file. This is used in cases the bundle should be loaded
- * from a custom path. By default it is loaded from Android assets, from a path specified
- * by {@link getBundleAssetName}.
- * e.g. "file://sdcard/myapp_cache/index.android.bundle"
+ * from a custom path. By default it is loaded from Android assets, from a path specified by
+ * {@link getBundleAssetName}. e.g. "file://sdcard/myapp_cache/index.android.bundle"
*/
protected @Nullable String getJSBundleFile() {
return null;
@@ -146,24 +136,20 @@ public abstract class ReactNativeHost {
/**
* Returns the name of the bundle in assets. If this is null, and no file path is specified for
- * the bundle, the app will only work with {@code getUseDeveloperSupport} enabled and will
- * always try to load the JS bundle from the packager server.
- * e.g. "index.android.bundle"
+ * the bundle, the app will only work with {@code getUseDeveloperSupport} enabled and will always
+ * try to load the JS bundle from the packager server. e.g. "index.android.bundle"
*/
protected @Nullable String getBundleAssetName() {
return "index.android.bundle";
}
- /**
- * Returns whether dev mode should be enabled. This enables e.g. the dev menu.
- */
+ /** Returns whether dev mode should be enabled. This enables e.g. the dev menu. */
public abstract boolean getUseDeveloperSupport();
/**
- * Returns a list of {@link ReactPackage} used by the app.
- * You'll most likely want to return at least the {@code MainReactPackage}.
- * If your app uses additional views or modules besides the default ones,
- * you'll want to include more packages here.
+ * Returns a list of {@link ReactPackage} used by the app. You'll most likely want to return at
+ * least the {@code MainReactPackage}. If your app uses additional views or modules besides the
+ * default ones, you'll want to include more packages here.
*/
protected abstract List This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react;
import com.facebook.react.bridge.NativeModule;
@@ -12,21 +11,18 @@ import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewManager;
import java.util.List;
-
import javax.annotation.Nonnull;
/**
* Main interface for providing additional capabilities to the catalyst framework by couple of
- * different means:
- * 1) Registering new native modules
- * 2) Registering new JS modules that may be accessed from native modules or from other parts of the
- * native code (requiring JS modules from the package doesn't mean it will automatically be included
- * as a part of the JS bundle, so there should be a corresponding piece of code on JS side that will
- * require implementation of that JS module so that it gets bundled)
- * 3) Registering custom native views (view managers) and custom event types
- * 4) Registering natively packaged assets/resources (e.g. images) exposed to JS
+ * different means: 1) Registering new native modules 2) Registering new JS modules that may be
+ * accessed from native modules or from other parts of the native code (requiring JS modules from
+ * the package doesn't mean it will automatically be included as a part of the JS bundle, so there
+ * should be a corresponding piece of code on JS side that will require implementation of that JS
+ * module so that it gets bundled) 3) Registering custom native views (view managers) and custom
+ * event types 4) Registering natively packaged assets/resources (e.g. images) exposed to JS
*
- * TODO(6788500, 6788507): Implement support for adding custom views, events and resources
+ * TODO(6788500, 6788507): Implement support for adding custom views, events and resources
*/
public interface ReactPackage {
@@ -37,9 +33,7 @@ public interface ReactPackage {
@Nonnull
List This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react;
import androidx.annotation.NonNull;
diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactPackageLogger.java b/ReactAndroid/src/main/java/com/facebook/react/ReactPackageLogger.java
index 38b2f2bddb6..526e4d4739c 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/ReactPackageLogger.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/ReactPackageLogger.java
@@ -5,11 +5,10 @@
package com.facebook.react;
-/**
- * Interface for the bridge to call for TTI start and end markers.
- */
+/** Interface for the bridge to call for TTI start and end markers. */
public interface ReactPackageLogger {
void startProcessPackage();
+
void endProcessPackage();
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java
index 1a98fd22479..50703ed524e 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java
@@ -1,10 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react;
import static com.facebook.react.uimanager.common.UIManagerType.DEFAULT;
@@ -46,8 +45,8 @@ import com.facebook.react.uimanager.DisplayMetricsHolder;
import com.facebook.react.uimanager.IllegalViewOperationException;
import com.facebook.react.uimanager.JSTouchDispatcher;
import com.facebook.react.uimanager.PixelUtil;
-import com.facebook.react.uimanager.RootView;
import com.facebook.react.uimanager.ReactRoot;
+import com.facebook.react.uimanager.RootView;
import com.facebook.react.uimanager.UIManagerHelper;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.common.UIManagerType;
@@ -62,20 +61,16 @@ import javax.annotation.Nullable;
* ViewGroup#onInterceptTouchEvent} method in order to be notified about the events for all of its
* children and it's also overriding {@link ViewGroup#requestDisallowInterceptTouchEvent} to make
* sure that {@link ViewGroup#onInterceptTouchEvent} will get events even when some child view start
- * intercepting it. In case when no child view is interested in handling some particular touch event,
- * this view's {@link View#onTouchEvent} will still return true in order to be notified about all
- * subsequent touch events related to that gesture (in case when JS code wants to handle that
+ * intercepting it. In case when no child view is interested in handling some particular touch
+ * event, this view's {@link View#onTouchEvent} will still return true in order to be notified about
+ * all subsequent touch events related to that gesture (in case when JS code wants to handle that
* gesture).
*/
public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
- /**
- * Listener interface for react root view events
- */
+ /** Listener interface for react root view events */
public interface ReactRootViewEventListener {
- /**
- * Called when the react context is attached to a ReactRootView.
- */
+ /** Called when the react context is attached to a ReactRootView. */
void onAttachedToReactInstance(ReactRootView rootView);
}
@@ -89,7 +84,8 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
private boolean mIsAttachedToInstance;
private boolean mShouldLogContentAppeared;
private @Nullable JSTouchDispatcher mJSTouchDispatcher;
- private final ReactAndroidHWInputDeviceHelper mAndroidHWInputDeviceHelper = new ReactAndroidHWInputDeviceHelper(this);
+ private final ReactAndroidHWInputDeviceHelper mAndroidHWInputDeviceHelper =
+ new ReactAndroidHWInputDeviceHelper(this);
private boolean mWasMeasured = false;
private int mWidthMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
private int mHeightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
@@ -135,8 +131,8 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "ReactRootView.onMeasure");
try {
- boolean measureSpecsUpdated = widthMeasureSpec != mWidthMeasureSpec ||
- heightMeasureSpec != mHeightMeasureSpec;
+ boolean measureSpecsUpdated =
+ widthMeasureSpec != mWidthMeasureSpec || heightMeasureSpec != mHeightMeasureSpec;
mWidthMeasureSpec = widthMeasureSpec;
mHeightMeasureSpec = heightMeasureSpec;
@@ -189,21 +185,22 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
@Override
public void onChildStartedNativeGesture(MotionEvent androidEvent) {
- if (mReactInstanceManager == null || !mIsAttachedToInstance ||
- mReactInstanceManager.getCurrentReactContext() == null) {
+ if (mReactInstanceManager == null
+ || !mIsAttachedToInstance
+ || mReactInstanceManager.getCurrentReactContext() == null) {
FLog.w(
- ReactConstants.TAG,
- "Unable to dispatch touch to JS as the catalyst instance has not been attached");
+ ReactConstants.TAG,
+ "Unable to dispatch touch to JS as the catalyst instance has not been attached");
return;
}
if (mJSTouchDispatcher == null) {
FLog.w(
- ReactConstants.TAG,
- "Unable to dispatch touch to JS before the dispatcher is available");
+ ReactConstants.TAG, "Unable to dispatch touch to JS before the dispatcher is available");
return;
}
ReactContext reactContext = mReactInstanceManager.getCurrentReactContext();
- EventDispatcher eventDispatcher = reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
+ EventDispatcher eventDispatcher =
+ reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
mJSTouchDispatcher.onChildStartedNativeGesture(androidEvent, eventDispatcher);
}
@@ -235,11 +232,12 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
@Override
public boolean dispatchKeyEvent(KeyEvent ev) {
- if (mReactInstanceManager == null || !mIsAttachedToInstance ||
- mReactInstanceManager.getCurrentReactContext() == null) {
+ if (mReactInstanceManager == null
+ || !mIsAttachedToInstance
+ || mReactInstanceManager.getCurrentReactContext() == null) {
FLog.w(
- ReactConstants.TAG,
- "Unable to handle key event as the catalyst instance has not been attached");
+ ReactConstants.TAG,
+ "Unable to handle key event as the catalyst instance has not been attached");
return super.dispatchKeyEvent(ev);
}
mAndroidHWInputDeviceHelper.handleKeyEvent(ev);
@@ -248,11 +246,12 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
@Override
protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) {
- if (mReactInstanceManager == null || !mIsAttachedToInstance ||
- mReactInstanceManager.getCurrentReactContext() == null) {
+ if (mReactInstanceManager == null
+ || !mIsAttachedToInstance
+ || mReactInstanceManager.getCurrentReactContext() == null) {
FLog.w(
- ReactConstants.TAG,
- "Unable to handle focus changed event as the catalyst instance has not been attached");
+ ReactConstants.TAG,
+ "Unable to handle focus changed event as the catalyst instance has not been attached");
super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
return;
}
@@ -262,11 +261,12 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
@Override
public void requestChildFocus(View child, View focused) {
- if (mReactInstanceManager == null || !mIsAttachedToInstance ||
- mReactInstanceManager.getCurrentReactContext() == null) {
+ if (mReactInstanceManager == null
+ || !mIsAttachedToInstance
+ || mReactInstanceManager.getCurrentReactContext() == null) {
FLog.w(
- ReactConstants.TAG,
- "Unable to handle child focus changed event as the catalyst instance has not been attached");
+ ReactConstants.TAG,
+ "Unable to handle child focus changed event as the catalyst instance has not been attached");
super.requestChildFocus(child, focused);
return;
}
@@ -275,21 +275,22 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
}
private void dispatchJSTouchEvent(MotionEvent event) {
- if (mReactInstanceManager == null || !mIsAttachedToInstance ||
- mReactInstanceManager.getCurrentReactContext() == null) {
+ if (mReactInstanceManager == null
+ || !mIsAttachedToInstance
+ || mReactInstanceManager.getCurrentReactContext() == null) {
FLog.w(
- ReactConstants.TAG,
- "Unable to dispatch touch to JS as the catalyst instance has not been attached");
+ ReactConstants.TAG,
+ "Unable to dispatch touch to JS as the catalyst instance has not been attached");
return;
}
if (mJSTouchDispatcher == null) {
FLog.w(
- ReactConstants.TAG,
- "Unable to dispatch touch to JS before the dispatcher is available");
+ ReactConstants.TAG, "Unable to dispatch touch to JS before the dispatcher is available");
return;
}
ReactContext reactContext = mReactInstanceManager.getCurrentReactContext();
- EventDispatcher eventDispatcher = reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
+ EventDispatcher eventDispatcher =
+ reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
mJSTouchDispatcher.handleTouchEvent(event, eventDispatcher);
}
@@ -349,24 +350,23 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
return this;
}
- /**
- * {@see #startReactApplication(ReactInstanceManager, String, android.os.Bundle)}
- */
+ /** {@see #startReactApplication(ReactInstanceManager, String, android.os.Bundle)} */
public void startReactApplication(ReactInstanceManager reactInstanceManager, String moduleName) {
startReactApplication(reactInstanceManager, moduleName, null);
}
- /**
- * {@see #startReactApplication(ReactInstanceManager, String, android.os.Bundle, String)}
- */
- public void startReactApplication(ReactInstanceManager reactInstanceManager, String moduleName, @Nullable Bundle initialProperties) {
+ /** {@see #startReactApplication(ReactInstanceManager, String, android.os.Bundle, String)} */
+ public void startReactApplication(
+ ReactInstanceManager reactInstanceManager,
+ String moduleName,
+ @Nullable Bundle initialProperties) {
startReactApplication(reactInstanceManager, moduleName, initialProperties, null);
}
/**
* Schedule rendering of the react component rendered by the JS application from the given JS
- * module (@{param moduleName}) using provided {@param reactInstanceManager} to attach to the
- * JS context of that manager. Extra parameter {@param launchOptions} can be used to pass initial
+ * module (@{param moduleName}) using provided {@param reactInstanceManager} to attach to the JS
+ * context of that manager. Extra parameter {@param launchOptions} can be used to pass initial
* properties for the react component.
*/
public void startReactApplication(
@@ -382,8 +382,8 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
// here as it may be deallocated in native after passing via JNI bridge, but we want to reuse
// it in the case of re-creating the catalyst instance
Assertions.assertCondition(
- mReactInstanceManager == null,
- "This root view has already been attached to a catalyst instance manager");
+ mReactInstanceManager == null,
+ "This root view has already been attached to a catalyst instance manager");
mReactInstanceManager = reactInstanceManager;
mJSModuleName = moduleName;
@@ -429,7 +429,7 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
if (reactApplicationContext != null) {
UIManagerHelper.getUIManager(reactApplicationContext, getUIManagerType())
- .updateRootLayoutSpecs(getRootViewTag(), widthMeasureSpec, heightMeasureSpec);
+ .updateRootLayoutSpecs(getRootViewTag(), widthMeasureSpec, heightMeasureSpec);
}
}
@@ -450,7 +450,7 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
@Override
public void onStage(int stage) {
- switch(stage) {
+ switch (stage) {
case ReactStage.ON_ATTACH_TO_INSTANCE:
onAttachedToReactInstance();
break;
@@ -498,51 +498,51 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
}
/**
- * Calls into JS to start the React application. Can be called multiple times with the
- * same rootTag, which will re-render the application from the root.
+ * Calls into JS to start the React application. Can be called multiple times with the same
+ * rootTag, which will re-render the application from the root.
*/
@Override
public void runApplication() {
- Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "ReactRootView.runApplication");
- try {
- if (mReactInstanceManager == null || !mIsAttachedToInstance) {
- return;
- }
-
- ReactContext reactContext = mReactInstanceManager.getCurrentReactContext();
- if (reactContext == null) {
- return;
- }
-
- CatalystInstance catalystInstance = reactContext.getCatalystInstance();
- String jsAppModuleName = getJSModuleName();
-
- if (mUseSurface) {
- // TODO call surface's runApplication
- } else {
- if (mWasMeasured) {
- updateRootLayoutSpecs(mWidthMeasureSpec, mHeightMeasureSpec);
- }
-
- WritableNativeMap appParams = new WritableNativeMap();
- appParams.putDouble("rootTag", getRootViewTag());
- @Nullable Bundle appProperties = getAppProperties();
- if (appProperties != null) {
- appParams.putMap("initialProps", Arguments.fromBundle(appProperties));
- }
-
- mShouldLogContentAppeared = true;
-
- catalystInstance.getJSModule(AppRegistry.class).runApplication(jsAppModuleName, appParams);
- }
- } finally {
- Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
+ Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "ReactRootView.runApplication");
+ try {
+ if (mReactInstanceManager == null || !mIsAttachedToInstance) {
+ return;
}
+
+ ReactContext reactContext = mReactInstanceManager.getCurrentReactContext();
+ if (reactContext == null) {
+ return;
+ }
+
+ CatalystInstance catalystInstance = reactContext.getCatalystInstance();
+ String jsAppModuleName = getJSModuleName();
+
+ if (mUseSurface) {
+ // TODO call surface's runApplication
+ } else {
+ if (mWasMeasured) {
+ updateRootLayoutSpecs(mWidthMeasureSpec, mHeightMeasureSpec);
+ }
+
+ WritableNativeMap appParams = new WritableNativeMap();
+ appParams.putDouble("rootTag", getRootViewTag());
+ @Nullable Bundle appProperties = getAppProperties();
+ if (appProperties != null) {
+ appParams.putMap("initialProps", Arguments.fromBundle(appProperties));
+ }
+
+ mShouldLogContentAppeared = true;
+
+ catalystInstance.getJSModule(AppRegistry.class).runApplication(jsAppModuleName, appParams);
+ }
+ } finally {
+ Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
+ }
}
/**
- * Is used by unit test to setup mIsAttachedToWindow flags, that will let this
- * view to be properly attached to catalyst instance by startReactApplication call
+ * Is used by unit test to setup mIsAttachedToWindow flags, that will let this view to be properly
+ * attached to catalyst instance by startReactApplication call
*/
@VisibleForTesting
/* package */ void simulateAttachForTesting() {
@@ -576,12 +576,12 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
protected void finalize() throws Throwable {
super.finalize();
Assertions.assertCondition(
- !mIsAttachedToInstance,
- "The application this ReactRootView was rendering was not unmounted before the " +
- "ReactRootView was garbage collected. This usually means that your application is " +
- "leaking large amounts of memory. To solve this, make sure to call " +
- "ReactRootView#unmountReactApplication in the onDestroy() of your hosting Activity or in " +
- "the onDestroyView() of your hosting Fragment.");
+ !mIsAttachedToInstance,
+ "The application this ReactRootView was rendering was not unmounted before the "
+ + "ReactRootView was garbage collected. This usually means that your application is "
+ + "leaking large amounts of memory. To solve this, make sure to call "
+ + "ReactRootView#unmountReactApplication in the onDestroy() of your hosting Activity or in "
+ + "the onDestroyView() of your hosting Fragment.");
}
public int getRootViewTag() {
@@ -594,9 +594,8 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
@Override
public void handleException(final Throwable t) {
- if (mReactInstanceManager == null
- || mReactInstanceManager.getCurrentReactContext() == null) {
- throw new RuntimeException(t);
+ if (mReactInstanceManager == null || mReactInstanceManager.getCurrentReactContext() == null) {
+ throw new RuntimeException(t);
}
Exception e = new IllegalViewOperationException(t.getMessage(), this, t);
@@ -619,9 +618,10 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
/* package */ void sendEvent(String eventName, @Nullable WritableMap params) {
if (mReactInstanceManager != null) {
- mReactInstanceManager.getCurrentReactContext()
- .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
- .emit(eventName, params);
+ mReactInstanceManager
+ .getCurrentReactContext()
+ .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
+ .emit(eventName, params);
}
}
@@ -642,8 +642,9 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
@Override
public void onGlobalLayout() {
- if (mReactInstanceManager == null || !mIsAttachedToInstance ||
- mReactInstanceManager.getCurrentReactContext() == null) {
+ if (mReactInstanceManager == null
+ || !mIsAttachedToInstance
+ || mReactInstanceManager.getCurrentReactContext() == null) {
return;
}
checkForKeyboardEvents();
@@ -654,41 +655,40 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
private void checkForKeyboardEvents() {
getRootView().getWindowVisibleDisplayFrame(mVisibleViewArea);
final int heightDiff =
- DisplayMetricsHolder.getWindowDisplayMetrics().heightPixels - mVisibleViewArea.bottom;
+ DisplayMetricsHolder.getWindowDisplayMetrics().heightPixels - mVisibleViewArea.bottom;
boolean isKeyboardShowingOrKeyboardHeightChanged =
- mKeyboardHeight != heightDiff && heightDiff > mMinKeyboardHeightDetected;
+ mKeyboardHeight != heightDiff && heightDiff > mMinKeyboardHeightDetected;
if (isKeyboardShowingOrKeyboardHeightChanged) {
mKeyboardHeight = heightDiff;
- sendEvent("keyboardDidShow",
- createKeyboardEventPayload(
- PixelUtil.toDIPFromPixel(mVisibleViewArea.bottom),
- PixelUtil.toDIPFromPixel(mVisibleViewArea.left),
- PixelUtil.toDIPFromPixel(mVisibleViewArea.width()),
- PixelUtil.toDIPFromPixel(mKeyboardHeight))
- );
+ sendEvent(
+ "keyboardDidShow",
+ createKeyboardEventPayload(
+ PixelUtil.toDIPFromPixel(mVisibleViewArea.bottom),
+ PixelUtil.toDIPFromPixel(mVisibleViewArea.left),
+ PixelUtil.toDIPFromPixel(mVisibleViewArea.width()),
+ PixelUtil.toDIPFromPixel(mKeyboardHeight)));
return;
}
- boolean isKeyboardHidden =
- mKeyboardHeight != 0 && heightDiff <= mMinKeyboardHeightDetected;
+ boolean isKeyboardHidden = mKeyboardHeight != 0 && heightDiff <= mMinKeyboardHeightDetected;
if (isKeyboardHidden) {
mKeyboardHeight = 0;
- sendEvent("keyboardDidHide",
- createKeyboardEventPayload(
- PixelUtil.toDIPFromPixel(mVisibleViewArea.height()),
- 0,
- PixelUtil.toDIPFromPixel(mVisibleViewArea.width()),
- 0
- )
- );
+ sendEvent(
+ "keyboardDidHide",
+ createKeyboardEventPayload(
+ PixelUtil.toDIPFromPixel(mVisibleViewArea.height()),
+ 0,
+ PixelUtil.toDIPFromPixel(mVisibleViewArea.width()),
+ 0));
}
}
private void checkForDeviceOrientationChanges() {
final int rotation =
- ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE))
- .getDefaultDisplay().getRotation();
+ ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE))
+ .getDefaultDisplay()
+ .getRotation();
if (mDeviceRotation == rotation) {
return;
}
@@ -699,9 +699,10 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
private void checkForDeviceDimensionsChanges() {
// Get current display metrics.
DisplayMetricsHolder.initDisplayMetrics(getContext());
- // Check changes to both window and screen display metrics since they may not update at the same time.
- if (!areMetricsEqual(mWindowMetrics, DisplayMetricsHolder.getWindowDisplayMetrics()) ||
- !areMetricsEqual(mScreenMetrics, DisplayMetricsHolder.getScreenDisplayMetrics())) {
+ // Check changes to both window and screen display metrics since they may not update at the
+ // same time.
+ if (!areMetricsEqual(mWindowMetrics, DisplayMetricsHolder.getWindowDisplayMetrics())
+ || !areMetricsEqual(mScreenMetrics, DisplayMetricsHolder.getScreenDisplayMetrics())) {
mWindowMetrics.setTo(DisplayMetricsHolder.getWindowDisplayMetrics());
mScreenMetrics.setTo(DisplayMetricsHolder.getScreenDisplayMetrics());
emitUpdateDimensionsEvent();
@@ -714,13 +715,13 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
} else {
// DisplayMetrics didn't have an equals method before API 17.
// Check all public fields manually.
- return displayMetrics.widthPixels == otherMetrics.widthPixels &&
- displayMetrics.heightPixels == otherMetrics.heightPixels &&
- displayMetrics.density == otherMetrics.density &&
- displayMetrics.densityDpi == otherMetrics.densityDpi &&
- displayMetrics.scaledDensity == otherMetrics.scaledDensity &&
- displayMetrics.xdpi == otherMetrics.xdpi &&
- displayMetrics.ydpi == otherMetrics.ydpi;
+ return displayMetrics.widthPixels == otherMetrics.widthPixels
+ && displayMetrics.heightPixels == otherMetrics.heightPixels
+ && displayMetrics.density == otherMetrics.density
+ && displayMetrics.densityDpi == otherMetrics.densityDpi
+ && displayMetrics.scaledDensity == otherMetrics.scaledDensity
+ && displayMetrics.xdpi == otherMetrics.xdpi
+ && displayMetrics.ydpi == otherMetrics.ydpi;
}
}
@@ -766,7 +767,8 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
.emitUpdateDimensionsEvent();
}
- private WritableMap createKeyboardEventPayload(double screenY, double screenX, double width, double height) {
+ private WritableMap createKeyboardEventPayload(
+ double screenY, double screenX, double width, double height) {
WritableMap keyboardEventParams = Arguments.createMap();
WritableMap endCoordinates = Arguments.createMap();
diff --git a/ReactAndroid/src/main/java/com/facebook/react/TurboReactPackage.java b/ReactAndroid/src/main/java/com/facebook/react/TurboReactPackage.java
index dfe86a3572f..1f72da8bb3c 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/TurboReactPackage.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/TurboReactPackage.java
@@ -1,10 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react;
import androidx.annotation.NonNull;
diff --git a/ReactAndroid/src/main/java/com/facebook/react/ViewManagerOnDemandReactPackage.java b/ReactAndroid/src/main/java/com/facebook/react/ViewManagerOnDemandReactPackage.java
index c8bd730bb0c..bdb1d2cff76 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/ViewManagerOnDemandReactPackage.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/ViewManagerOnDemandReactPackage.java
@@ -1,10 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react;
import com.facebook.react.bridge.ReactApplicationContext;
@@ -17,7 +16,8 @@ public interface ViewManagerOnDemandReactPackage {
* Provides a list of names of ViewManagers with which these modules can be accessed from JS.
* Typically, this is ViewManager.getName().
*/
- @Nullable List This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.animated;
import com.facebook.react.bridge.JSApplicationCausedNativeException;
@@ -21,8 +20,7 @@ import com.facebook.react.bridge.ReadableMap;
private final int[] mInputNodes;
public AdditionAnimatedNode(
- ReadableMap config,
- NativeAnimatedNodesManager nativeAnimatedNodesManager) {
+ ReadableMap config, NativeAnimatedNodesManager nativeAnimatedNodesManager) {
mNativeAnimatedNodesManager = nativeAnimatedNodesManager;
ReadableArray inputNodes = config.getArray("input");
mInputNodes = new int[inputNodes.size()];
@@ -39,8 +37,8 @@ import com.facebook.react.bridge.ReadableMap;
if (animatedNode != null && animatedNode instanceof ValueAnimatedNode) {
mValue += ((ValueAnimatedNode) animatedNode).getValue();
} else {
- throw new JSApplicationCausedNativeException("Illegal node ID set as an input for " +
- "Animated.Add node");
+ throw new JSApplicationCausedNativeException(
+ "Illegal node ID set as an input for " + "Animated.Add node");
}
}
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/animated/AnimatedNode.java b/ReactAndroid/src/main/java/com/facebook/react/animated/AnimatedNode.java
index c4493b59b90..956c7695018 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/animated/AnimatedNode.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/animated/AnimatedNode.java
@@ -1,22 +1,17 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.animated;
import com.facebook.infer.annotation.Assertions;
-
import java.util.ArrayList;
import java.util.List;
-
import javax.annotation.Nullable;
-/**
- * Base class for all Animated.js library node types that can be created on the "native" side.
- */
+/** Base class for all Animated.js library node types that can be created on the "native" side. */
/*package*/ abstract class AnimatedNode {
public static final int INITIAL_BFS_COLOR = 0;
@@ -46,24 +41,19 @@ import javax.annotation.Nullable;
/**
* Subclasses may want to override this method in order to store a reference to the parent of a
- * given node that can then be used to calculate current node's value in {@link #update}.
- * In that case it is important to also override {@link #onDetachedFromNode} to clear that
- * reference once current node gets detached.
+ * given node that can then be used to calculate current node's value in {@link #update}. In that
+ * case it is important to also override {@link #onDetachedFromNode} to clear that reference once
+ * current node gets detached.
*/
- public void onAttachedToNode(AnimatedNode parent) {
- }
+ public void onAttachedToNode(AnimatedNode parent) {}
- /**
- * See {@link #onAttachedToNode}
- */
- public void onDetachedFromNode(AnimatedNode parent) {
- }
+ /** See {@link #onAttachedToNode} */
+ public void onDetachedFromNode(AnimatedNode parent) {}
/**
* This method will be run on each node at most once every repetition of the animation loop. It
* will be executed on a node only when all the node's parent has already been updated. Therefore
* it can be used to calculate node's value.
*/
- public void update() {
- }
+ public void update() {}
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/animated/AnimatedNodeValueListener.java b/ReactAndroid/src/main/java/com/facebook/react/animated/AnimatedNodeValueListener.java
index 6c92345f11b..39b2a43ee7a 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/animated/AnimatedNodeValueListener.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/animated/AnimatedNodeValueListener.java
@@ -1,15 +1,12 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.animated;
-/**
- * Interface used to listen to {@link ValueAnimatedNode} updates.
- */
+/** Interface used to listen to {@link ValueAnimatedNode} updates. */
public interface AnimatedNodeValueListener {
void onValueUpdate(double value);
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/animated/AnimationDriver.java b/ReactAndroid/src/main/java/com/facebook/react/animated/AnimationDriver.java
index 894a6d557f1..5900e28b28d 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/animated/AnimationDriver.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/animated/AnimationDriver.java
@@ -1,10 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.animated;
import com.facebook.react.bridge.Callback;
@@ -36,6 +35,6 @@ import com.facebook.react.bridge.ReadableMap;
*/
public void resetConfig(ReadableMap config) {
throw new JSApplicationCausedNativeException(
- "Animation config for " + getClass().getSimpleName() + " cannot be reset");
+ "Animation config for " + getClass().getSimpleName() + " cannot be reset");
}
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/animated/DecayAnimation.java b/ReactAndroid/src/main/java/com/facebook/react/animated/DecayAnimation.java
index 1781cb83875..b6e043f8240 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/animated/DecayAnimation.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/animated/DecayAnimation.java
@@ -1,10 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.animated;
import com.facebook.react.bridge.ReadableMap;
@@ -54,9 +53,10 @@ public class DecayAnimation extends AnimationDriver {
mLastValue = mAnimatedValue.mValue;
}
- final double value = mFromValue +
- (mVelocity / (1 - mDeceleration)) *
- (1 - Math.exp(-(1 - mDeceleration) * (frameTimeMillis - mStartFrameTimeMillis)));
+ final double value =
+ mFromValue
+ + (mVelocity / (1 - mDeceleration))
+ * (1 - Math.exp(-(1 - mDeceleration) * (frameTimeMillis - mStartFrameTimeMillis)));
if (Math.abs(mLastValue - value) < 0.1) {
diff --git a/ReactAndroid/src/main/java/com/facebook/react/animated/DiffClampAnimatedNode.java b/ReactAndroid/src/main/java/com/facebook/react/animated/DiffClampAnimatedNode.java
index 7f077a6610c..b40991d07f4 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/animated/DiffClampAnimatedNode.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/animated/DiffClampAnimatedNode.java
@@ -1,10 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.animated;
import com.facebook.react.bridge.JSApplicationCausedNativeException;
@@ -19,8 +18,7 @@ import com.facebook.react.bridge.ReadableMap;
private double mLastValue;
public DiffClampAnimatedNode(
- ReadableMap config,
- NativeAnimatedNodesManager nativeAnimatedNodesManager) {
+ ReadableMap config, NativeAnimatedNodesManager nativeAnimatedNodesManager) {
mNativeAnimatedNodesManager = nativeAnimatedNodesManager;
mInputNodeTag = config.getInt("input");
mMin = config.getDouble("min");
@@ -41,9 +39,8 @@ import com.facebook.react.bridge.ReadableMap;
private double getInputNodeValue() {
AnimatedNode animatedNode = mNativeAnimatedNodesManager.getNodeById(mInputNodeTag);
if (animatedNode == null || !(animatedNode instanceof ValueAnimatedNode)) {
- throw new JSApplicationCausedNativeException("Illegal node ID set as an input for " +
- "Animated.DiffClamp node");
-
+ throw new JSApplicationCausedNativeException(
+ "Illegal node ID set as an input for " + "Animated.DiffClamp node");
}
return ((ValueAnimatedNode) animatedNode).getValue();
diff --git a/ReactAndroid/src/main/java/com/facebook/react/animated/DivisionAnimatedNode.java b/ReactAndroid/src/main/java/com/facebook/react/animated/DivisionAnimatedNode.java
index 96e96059e88..7d403a0f90f 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/animated/DivisionAnimatedNode.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/animated/DivisionAnimatedNode.java
@@ -1,10 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.animated;
import com.facebook.react.bridge.JSApplicationCausedNativeException;
@@ -12,8 +11,8 @@ import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
/**
- * Animated node which takes two or more value node as an input and outputs an in-order
- * division of their values.
+ * Animated node which takes two or more value node as an input and outputs an in-order division of
+ * their values.
*/
/*package*/ class DivisionAnimatedNode extends ValueAnimatedNode {
@@ -21,8 +20,7 @@ import com.facebook.react.bridge.ReadableMap;
private final int[] mInputNodes;
public DivisionAnimatedNode(
- ReadableMap config,
- NativeAnimatedNodesManager nativeAnimatedNodesManager) {
+ ReadableMap config, NativeAnimatedNodesManager nativeAnimatedNodesManager) {
mNativeAnimatedNodesManager = nativeAnimatedNodesManager;
ReadableArray inputNodes = config.getArray("input");
mInputNodes = new int[inputNodes.size()];
@@ -42,13 +40,13 @@ import com.facebook.react.bridge.ReadableMap;
continue;
}
if (value == 0) {
- throw new JSApplicationCausedNativeException("Detected a division by zero in " +
- "Animated.divide node");
+ throw new JSApplicationCausedNativeException(
+ "Detected a division by zero in " + "Animated.divide node");
}
mValue /= value;
} else {
- throw new JSApplicationCausedNativeException("Illegal node ID set as an input for " +
- "Animated.divide node");
+ throw new JSApplicationCausedNativeException(
+ "Illegal node ID set as an input for " + "Animated.divide node");
}
}
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/animated/EventAnimationDriver.java b/ReactAndroid/src/main/java/com/facebook/react/animated/EventAnimationDriver.java
index 7e2c46eef26..169808e04c6 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/animated/EventAnimationDriver.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/animated/EventAnimationDriver.java
@@ -1,24 +1,19 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.animated;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableArray;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.uimanager.events.RCTEventEmitter;
-
import java.util.List;
-
import javax.annotation.Nullable;
-/**
- * Handles updating a {@link ValueAnimatedNode} when an event gets dispatched.
- */
+/** Handles updating a {@link ValueAnimatedNode} when an event gets dispatched. */
/* package */ class EventAnimationDriver implements RCTEventEmitter {
private List This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.animated;
import com.facebook.react.bridge.ReadableArray;
@@ -42,14 +41,14 @@ class FrameBasedAnimationDriver extends AnimationDriver {
for (int i = 0; i < numberOfFrames; i++) {
mFrames[i] = frames.getDouble(i);
}
- if(config.hasKey("toValue")) {
+ if (config.hasKey("toValue")) {
mToValue = config.getType("toValue") == ReadableType.Number ? config.getDouble("toValue") : 0;
} else {
mToValue = 0;
}
- if(config.hasKey("iterations")) {
- mIterations = config.getType("iterations") == ReadableType.Number ?
- config.getInt("iterations") : 1;
+ if (config.hasKey("iterations")) {
+ mIterations =
+ config.getType("iterations") == ReadableType.Number ? config.getInt("iterations") : 1;
} else {
mIterations = 1;
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/animated/InterpolationAnimatedNode.java b/ReactAndroid/src/main/java/com/facebook/react/animated/InterpolationAnimatedNode.java
index bc2e08c7ada..a1ce30cff29 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/animated/InterpolationAnimatedNode.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/animated/InterpolationAnimatedNode.java
@@ -1,8 +1,8 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
package com.facebook.react.animated;
@@ -10,17 +10,15 @@ import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.ReadableType;
-
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-
import javax.annotation.Nullable;
/**
* Animated node that corresponds to {@code AnimatedInterpolation} from AnimatedImplementation.js.
*
- * Currently only a linear interpolation is supported on an input range of an arbitrary size.
+ * Currently only a linear interpolation is supported on an input range of an arbitrary size.
*/
/*package*/ class InterpolationAnimatedNode extends ValueAnimatedNode {
@@ -61,7 +59,7 @@ import javax.annotation.Nullable;
break;
default:
throw new JSApplicationIllegalArgumentException(
- "Invalid extrapolation type " + extrapolateLeft + "for left extrapolation");
+ "Invalid extrapolation type " + extrapolateLeft + "for left extrapolation");
}
}
@@ -76,7 +74,7 @@ import javax.annotation.Nullable;
break;
default:
throw new JSApplicationIllegalArgumentException(
- "Invalid extrapolation type " + extrapolateRight + "for right extrapolation");
+ "Invalid extrapolation type " + extrapolateRight + "for right extrapolation");
}
}
@@ -91,8 +89,7 @@ import javax.annotation.Nullable;
return outputMax;
}
- return outputMin + (outputMax - outputMin) *
- (result - inputMin) / (inputMax - inputMin);
+ return outputMin + (outputMax - outputMin) * (result - inputMin) / (inputMax - inputMin);
}
/*package*/ static double interpolate(
@@ -100,17 +97,16 @@ import javax.annotation.Nullable;
double[] inputRange,
double[] outputRange,
String extrapolateLeft,
- String extrapolateRight
- ) {
+ String extrapolateRight) {
int rangeIndex = findRangeIndex(value, inputRange);
return interpolate(
- value,
- inputRange[rangeIndex],
- inputRange[rangeIndex + 1],
- outputRange[rangeIndex],
- outputRange[rangeIndex + 1],
- extrapolateLeft,
- extrapolateRight);
+ value,
+ inputRange[rangeIndex],
+ inputRange[rangeIndex + 1],
+ outputRange[rangeIndex],
+ outputRange[rangeIndex + 1],
+ extrapolateLeft,
+ extrapolateRight);
}
private static int findRangeIndex(double value, double[] ranges) {
@@ -228,16 +224,19 @@ import javax.annotation.Nullable;
int i = 0;
mSOutputMatcher.reset();
while (mSOutputMatcher.find()) {
- double val = interpolate(value, mInputRange, mOutputs[i++], mExtrapolateLeft, mExtrapolateRight);
+ double val =
+ interpolate(value, mInputRange, mOutputs[i++], mExtrapolateLeft, mExtrapolateRight);
if (mShouldRound) {
- // rgba requires that the r,g,b are integers.... so we want to round them, but we *dont* want to
+ // rgba requires that the r,g,b are integers.... so we want to round them, but we *dont*
+ // want to
// round the opacity (4th column).
boolean isAlpha = i == 4;
- int rounded = (int)Math.round(isAlpha ? val * 1000 : val);
- String num = isAlpha ? Double.toString((double)rounded / 1000) : Integer.toString(rounded);
+ int rounded = (int) Math.round(isAlpha ? val * 1000 : val);
+ String num =
+ isAlpha ? Double.toString((double) rounded / 1000) : Integer.toString(rounded);
mSOutputMatcher.appendReplacement(sb, num);
} else {
- int intVal = (int)val;
+ int intVal = (int) val;
String num = intVal != val ? Double.toString(val) : Integer.toString(intVal);
mSOutputMatcher.appendReplacement(sb, num);
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/animated/ModulusAnimatedNode.java b/ReactAndroid/src/main/java/com/facebook/react/animated/ModulusAnimatedNode.java
index e1e7be68535..0a1cbf47543 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/animated/ModulusAnimatedNode.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/animated/ModulusAnimatedNode.java
@@ -1,14 +1,12 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.animated;
import com.facebook.react.bridge.JSApplicationCausedNativeException;
-import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
/*package*/ class ModulusAnimatedNode extends ValueAnimatedNode {
@@ -18,8 +16,7 @@ import com.facebook.react.bridge.ReadableMap;
private final double mModulus;
public ModulusAnimatedNode(
- ReadableMap config,
- NativeAnimatedNodesManager nativeAnimatedNodesManager) {
+ ReadableMap config, NativeAnimatedNodesManager nativeAnimatedNodesManager) {
mNativeAnimatedNodesManager = nativeAnimatedNodesManager;
mInputNode = config.getInt("input");
mModulus = config.getDouble("modulus");
@@ -32,8 +29,8 @@ import com.facebook.react.bridge.ReadableMap;
final double value = ((ValueAnimatedNode) animatedNode).getValue();
mValue = (value % mModulus + mModulus) % mModulus;
} else {
- throw new JSApplicationCausedNativeException("Illegal node ID set as an input for " +
- "Animated.modulus node");
+ throw new JSApplicationCausedNativeException(
+ "Illegal node ID set as an input for " + "Animated.modulus node");
}
}
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/animated/MultiplicationAnimatedNode.java b/ReactAndroid/src/main/java/com/facebook/react/animated/MultiplicationAnimatedNode.java
index 23839c5c221..41f69b70340 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/animated/MultiplicationAnimatedNode.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/animated/MultiplicationAnimatedNode.java
@@ -1,10 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.animated;
import com.facebook.react.bridge.JSApplicationCausedNativeException;
@@ -21,8 +20,7 @@ import com.facebook.react.bridge.ReadableMap;
private final int[] mInputNodes;
public MultiplicationAnimatedNode(
- ReadableMap config,
- NativeAnimatedNodesManager nativeAnimatedNodesManager) {
+ ReadableMap config, NativeAnimatedNodesManager nativeAnimatedNodesManager) {
mNativeAnimatedNodesManager = nativeAnimatedNodesManager;
ReadableArray inputNodes = config.getArray("input");
mInputNodes = new int[inputNodes.size()];
@@ -39,8 +37,8 @@ import com.facebook.react.bridge.ReadableMap;
if (animatedNode != null && animatedNode instanceof ValueAnimatedNode) {
mValue *= ((ValueAnimatedNode) animatedNode).getValue();
} else {
- throw new JSApplicationCausedNativeException("Illegal node ID set as an input for " +
- "Animated.multiply node");
+ throw new JSApplicationCausedNativeException(
+ "Illegal node ID set as an input for " + "Animated.multiply node");
}
}
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedModule.java b/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedModule.java
index b4596f18edc..962730b06b1 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedModule.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedModule.java
@@ -1,16 +1,11 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.animated;
-import javax.annotation.Nullable;
-
-import java.util.ArrayList;
-
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.Callback;
@@ -29,51 +24,51 @@ import com.facebook.react.uimanager.NativeViewHierarchyManager;
import com.facebook.react.uimanager.UIBlock;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.UIManagerModuleListener;
+import java.util.ArrayList;
+import javax.annotation.Nullable;
/**
* Module that exposes interface for creating and managing animated nodes on the "native" side.
*
- * Animated.js library is based on a concept of a graph where nodes are values or transform
+ * Animated.js library is based on a concept of a graph where nodes are values or transform
* operations (such as interpolation, addition, etc) and connection are used to describe how change
* of the value in one node can affect other nodes.
*
- * Few examples of the nodes that can be created on the JS side:
- * - Animated.Value is a simplest type of node with a numeric value which can be driven by an
- * animation engine (spring, decay, etc) or by calling setValue on it directly from JS
- * - Animated.add is a type of node that may have two or more input nodes. It outputs the sum of
- * all the input node values
- * - interpolate - is actually a method you can call on any node and it creates a new node that
- * takes the parent node as an input and outputs its interpolated value (e.g. if you have value
- * that can animate from 0 to 1 you can create interpolated node and set output range to be 0 to
- * 100 and when the input node changes the output of interpolated node will multiply the values
- * by 100)
+ * Few examples of the nodes that can be created on the JS side: - Animated.Value is a simplest
+ * type of node with a numeric value which can be driven by an animation engine (spring, decay, etc)
+ * or by calling setValue on it directly from JS - Animated.add is a type of node that may have two
+ * or more input nodes. It outputs the sum of all the input node values - interpolate - is actually
+ * a method you can call on any node and it creates a new node that takes the parent node as an
+ * input and outputs its interpolated value (e.g. if you have value that can animate from 0 to 1 you
+ * can create interpolated node and set output range to be 0 to 100 and when the input node changes
+ * the output of interpolated node will multiply the values by 100)
*
- * You can mix and chain nodes however you like and this way create nodes graph with connections
+ * You can mix and chain nodes however you like and this way create nodes graph with connections
* between them.
*
- * To map animated node values to view properties there is a special type of a node: AnimatedProps.
- * It is created by AnimatedImplementation whenever you render Animated.View and stores a mapping
- * from the view properties to the corresponding animated values (so it's actually also a node with
- * connections to the value nodes).
+ * To map animated node values to view properties there is a special type of a node:
+ * AnimatedProps. It is created by AnimatedImplementation whenever you render Animated.View and
+ * stores a mapping from the view properties to the corresponding animated values (so it's actually
+ * also a node with connections to the value nodes).
*
- * Last "special" elements of the the graph are "animation drivers". Those are objects (represented
- * as a graph nodes too) that based on some criteria updates attached values every frame (we have
- * few types of those, e.g., spring, timing, decay). Animation objects can be "started" and
- * "stopped". Those are like "pulse generators" for the rest of the nodes graph. Those pulses then
- * propagate along the graph to the children nodes up to the special node type: AnimatedProps which
- * then can be used to calculate property update map for a view.
+ * Last "special" elements of the the graph are "animation drivers". Those are objects
+ * (represented as a graph nodes too) that based on some criteria updates attached values every
+ * frame (we have few types of those, e.g., spring, timing, decay). Animation objects can be
+ * "started" and "stopped". Those are like "pulse generators" for the rest of the nodes graph. Those
+ * pulses then propagate along the graph to the children nodes up to the special node type:
+ * AnimatedProps which then can be used to calculate property update map for a view.
*
- * This class acts as a proxy between the "native" API that can be called from JS and the main class
- * that coordinates all the action: {@link NativeAnimatedNodesManager}. Since all the methods from
- * {@link NativeAnimatedNodesManager} need to be called from the UI thread, we we create a queue of
- * animated graph operations that is then enqueued to be executed in the UI Thread at the end of the
- * batch of JS->native calls (similarly to how it's handled in {@link UIManagerModule}). This
- * isolates us from the problems that may be caused by concurrent updates of animated graph while UI
- * thread is "executing" the animation loop.
+ * This class acts as a proxy between the "native" API that can be called from JS and the main
+ * class that coordinates all the action: {@link NativeAnimatedNodesManager}. Since all the methods
+ * from {@link NativeAnimatedNodesManager} need to be called from the UI thread, we we create a
+ * queue of animated graph operations that is then enqueued to be executed in the UI Thread at the
+ * end of the batch of JS->native calls (similarly to how it's handled in {@link UIManagerModule}).
+ * This isolates us from the problems that may be caused by concurrent updates of animated graph
+ * while UI thread is "executing" the animation loop.
*/
@ReactModule(name = NativeAnimatedModule.NAME)
-public class NativeAnimatedModule extends ReactContextBaseJavaModule implements
- LifecycleEventListener, UIManagerModuleListener {
+public class NativeAnimatedModule extends ReactContextBaseJavaModule
+ implements LifecycleEventListener, UIManagerModuleListener {
public static final String NAME = "NativeAnimatedModule";
@@ -92,23 +87,25 @@ public class NativeAnimatedModule extends ReactContextBaseJavaModule implements
super(reactContext);
mReactChoreographer = ReactChoreographer.getInstance();
- mAnimatedFrameCallback = new GuardedFrameCallback(reactContext) {
- @Override
- protected void doFrameGuarded(final long frameTimeNanos) {
- NativeAnimatedNodesManager nodesManager = getNodesManager();
- if (nodesManager.hasActiveAnimations()) {
- nodesManager.runUpdates(frameTimeNanos);
- }
+ mAnimatedFrameCallback =
+ new GuardedFrameCallback(reactContext) {
+ @Override
+ protected void doFrameGuarded(final long frameTimeNanos) {
+ NativeAnimatedNodesManager nodesManager = getNodesManager();
+ if (nodesManager.hasActiveAnimations()) {
+ nodesManager.runUpdates(frameTimeNanos);
+ }
- // TODO: Would be great to avoid adding this callback in case there are no active animations
- // and no outstanding tasks on the operations queue. Apparently frame callbacks can only
- // be posted from the UI thread and therefore we cannot schedule them directly from
- // @ReactMethod methods
- Assertions.assertNotNull(mReactChoreographer).postFrameCallback(
- ReactChoreographer.CallbackType.NATIVE_ANIMATED_MODULE,
- mAnimatedFrameCallback);
- }
- };
+ // TODO: Would be great to avoid adding this callback in case there are no active
+ // animations
+ // and no outstanding tasks on the operations queue. Apparently frame callbacks can only
+ // be posted from the UI thread and therefore we cannot schedule them directly from
+ // @ReactMethod methods
+ Assertions.assertNotNull(mReactChoreographer)
+ .postFrameCallback(
+ ReactChoreographer.CallbackType.NATIVE_ANIMATED_MODULE, mAnimatedFrameCallback);
+ }
+ };
}
@Override
@@ -133,24 +130,26 @@ public class NativeAnimatedModule extends ReactContextBaseJavaModule implements
final ArrayList This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.animated;
import android.util.SparseArray;
-
import com.facebook.common.logging.FLog;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.Callback;
@@ -22,7 +20,6 @@ import com.facebook.react.uimanager.IllegalViewOperationException;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.events.Event;
import com.facebook.react.uimanager.events.EventDispatcherListener;
-
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
@@ -31,21 +28,20 @@ import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Queue;
-
import javax.annotation.Nullable;
/**
* This is the main class that coordinates how native animated JS implementation drives UI changes.
*
- * It implements a management interface for animated nodes graph as well as implements a graph
+ * It implements a management interface for animated nodes graph as well as implements a graph
* traversal algorithm that is run for each animation frame.
*
- * For each animation frame we visit animated nodes that might've been updated as well as their
+ * For each animation frame we visit animated nodes that might've been updated as well as their
* children that may use parent's values to update themselves. At the end of the traversal algorithm
* we expect to reach a special type of the node: PropsAnimatedNode that is then responsible for
* calculating property map which can be sent to native view hierarchy to update the view.
*
- * IMPORTANT: This class should be accessed only from the UI Thread
+ * IMPORTANT: This class should be accessed only from the UI Thread
*/
/*package*/ class NativeAnimatedNodesManager implements EventDispatcherListener {
@@ -67,7 +63,8 @@ import javax.annotation.Nullable;
mCustomEventNamesResolver = uiManager.getDirectEventNamesResolver();
}
- /*package*/ @Nullable AnimatedNode getNodeById(int id) {
+ /*package*/ @Nullable
+ AnimatedNode getNodeById(int id) {
return mAnimatedNodes.get(id);
}
@@ -77,8 +74,8 @@ import javax.annotation.Nullable;
public void createAnimatedNode(int tag, ReadableMap config) {
if (mAnimatedNodes.get(tag) != null) {
- throw new JSApplicationIllegalArgumentException("Animated node with tag " + tag +
- " already exists");
+ throw new JSApplicationIllegalArgumentException(
+ "Animated node with tag " + tag + " already exists");
}
String type = config.getString("type");
final AnimatedNode node;
@@ -122,8 +119,8 @@ import javax.annotation.Nullable;
public void startListeningToAnimatedNodeValue(int tag, AnimatedNodeValueListener listener) {
AnimatedNode node = mAnimatedNodes.get(tag);
if (node == null || !(node instanceof ValueAnimatedNode)) {
- throw new JSApplicationIllegalArgumentException("Animated node with tag " + tag +
- " does not exists or is not a 'value' node");
+ throw new JSApplicationIllegalArgumentException(
+ "Animated node with tag " + tag + " does not exists or is not a 'value' node");
}
((ValueAnimatedNode) node).setValueListener(listener);
}
@@ -131,8 +128,8 @@ import javax.annotation.Nullable;
public void stopListeningToAnimatedNodeValue(int tag) {
AnimatedNode node = mAnimatedNodes.get(tag);
if (node == null || !(node instanceof ValueAnimatedNode)) {
- throw new JSApplicationIllegalArgumentException("Animated node with tag " + tag +
- " does not exists or is not a 'value' node");
+ throw new JSApplicationIllegalArgumentException(
+ "Animated node with tag " + tag + " does not exists or is not a 'value' node");
}
((ValueAnimatedNode) node).setValueListener(null);
}
@@ -140,8 +137,8 @@ import javax.annotation.Nullable;
public void setAnimatedNodeValue(int tag, double value) {
AnimatedNode node = mAnimatedNodes.get(tag);
if (node == null || !(node instanceof ValueAnimatedNode)) {
- throw new JSApplicationIllegalArgumentException("Animated node with tag " + tag +
- " does not exists or is not a 'value' node");
+ throw new JSApplicationIllegalArgumentException(
+ "Animated node with tag " + tag + " does not exists or is not a 'value' node");
}
stopAnimationsForNode(node);
((ValueAnimatedNode) node).mValue = value;
@@ -151,8 +148,8 @@ import javax.annotation.Nullable;
public void setAnimatedNodeOffset(int tag, double offset) {
AnimatedNode node = mAnimatedNodes.get(tag);
if (node == null || !(node instanceof ValueAnimatedNode)) {
- throw new JSApplicationIllegalArgumentException("Animated node with tag " + tag +
- " does not exists or is not a 'value' node");
+ throw new JSApplicationIllegalArgumentException(
+ "Animated node with tag " + tag + " does not exists or is not a 'value' node");
}
((ValueAnimatedNode) node).mOffset = offset;
mUpdatedNodes.put(tag, node);
@@ -161,8 +158,8 @@ import javax.annotation.Nullable;
public void flattenAnimatedNodeOffset(int tag) {
AnimatedNode node = mAnimatedNodes.get(tag);
if (node == null || !(node instanceof ValueAnimatedNode)) {
- throw new JSApplicationIllegalArgumentException("Animated node with tag " + tag +
- " does not exists or is not a 'value' node");
+ throw new JSApplicationIllegalArgumentException(
+ "Animated node with tag " + tag + " does not exists or is not a 'value' node");
}
((ValueAnimatedNode) node).flattenOffset();
}
@@ -170,25 +167,22 @@ import javax.annotation.Nullable;
public void extractAnimatedNodeOffset(int tag) {
AnimatedNode node = mAnimatedNodes.get(tag);
if (node == null || !(node instanceof ValueAnimatedNode)) {
- throw new JSApplicationIllegalArgumentException("Animated node with tag " + tag +
- " does not exists or is not a 'value' node");
+ throw new JSApplicationIllegalArgumentException(
+ "Animated node with tag " + tag + " does not exists or is not a 'value' node");
}
((ValueAnimatedNode) node).extractOffset();
}
public void startAnimatingNode(
- int animationId,
- int animatedNodeTag,
- ReadableMap animationConfig,
- Callback endCallback) {
+ int animationId, int animatedNodeTag, ReadableMap animationConfig, Callback endCallback) {
AnimatedNode node = mAnimatedNodes.get(animatedNodeTag);
if (node == null) {
- throw new JSApplicationIllegalArgumentException("Animated node with tag " + animatedNodeTag +
- " does not exists");
+ throw new JSApplicationIllegalArgumentException(
+ "Animated node with tag " + animatedNodeTag + " does not exists");
}
if (!(node instanceof ValueAnimatedNode)) {
- throw new JSApplicationIllegalArgumentException("Animated node should be of type " +
- ValueAnimatedNode.class.getName());
+ throw new JSApplicationIllegalArgumentException(
+ "Animated node should be of type " + ValueAnimatedNode.class.getName());
}
final AnimationDriver existingDriver = mActiveAnimations.get(animationId);
@@ -263,13 +257,13 @@ import javax.annotation.Nullable;
public void connectAnimatedNodes(int parentNodeTag, int childNodeTag) {
AnimatedNode parentNode = mAnimatedNodes.get(parentNodeTag);
if (parentNode == null) {
- throw new JSApplicationIllegalArgumentException("Animated node with tag " + parentNodeTag +
- " does not exists");
+ throw new JSApplicationIllegalArgumentException(
+ "Animated node with tag " + parentNodeTag + " does not exists");
}
AnimatedNode childNode = mAnimatedNodes.get(childNodeTag);
if (childNode == null) {
- throw new JSApplicationIllegalArgumentException("Animated node with tag " + childNodeTag +
- " does not exists");
+ throw new JSApplicationIllegalArgumentException(
+ "Animated node with tag " + childNodeTag + " does not exists");
}
parentNode.addChild(childNode);
mUpdatedNodes.put(childNodeTag, childNode);
@@ -278,13 +272,13 @@ import javax.annotation.Nullable;
public void disconnectAnimatedNodes(int parentNodeTag, int childNodeTag) {
AnimatedNode parentNode = mAnimatedNodes.get(parentNodeTag);
if (parentNode == null) {
- throw new JSApplicationIllegalArgumentException("Animated node with tag " + parentNodeTag +
- " does not exists");
+ throw new JSApplicationIllegalArgumentException(
+ "Animated node with tag " + parentNodeTag + " does not exists");
}
AnimatedNode childNode = mAnimatedNodes.get(childNodeTag);
if (childNode == null) {
- throw new JSApplicationIllegalArgumentException("Animated node with tag " + childNodeTag +
- " does not exists");
+ throw new JSApplicationIllegalArgumentException(
+ "Animated node with tag " + childNodeTag + " does not exists");
}
parentNode.removeChild(childNode);
mUpdatedNodes.put(childNodeTag, childNode);
@@ -293,12 +287,14 @@ import javax.annotation.Nullable;
public void connectAnimatedNodeToView(int animatedNodeTag, int viewTag) {
AnimatedNode node = mAnimatedNodes.get(animatedNodeTag);
if (node == null) {
- throw new JSApplicationIllegalArgumentException("Animated node with tag " + animatedNodeTag +
- " does not exists");
+ throw new JSApplicationIllegalArgumentException(
+ "Animated node with tag " + animatedNodeTag + " does not exists");
}
if (!(node instanceof PropsAnimatedNode)) {
- throw new JSApplicationIllegalArgumentException("Animated node connected to view should be" +
- "of type " + PropsAnimatedNode.class.getName());
+ throw new JSApplicationIllegalArgumentException(
+ "Animated node connected to view should be"
+ + "of type "
+ + PropsAnimatedNode.class.getName());
}
PropsAnimatedNode propsAnimatedNode = (PropsAnimatedNode) node;
propsAnimatedNode.connectToView(viewTag);
@@ -308,12 +304,14 @@ import javax.annotation.Nullable;
public void disconnectAnimatedNodeFromView(int animatedNodeTag, int viewTag) {
AnimatedNode node = mAnimatedNodes.get(animatedNodeTag);
if (node == null) {
- throw new JSApplicationIllegalArgumentException("Animated node with tag " + animatedNodeTag +
- " does not exists");
+ throw new JSApplicationIllegalArgumentException(
+ "Animated node with tag " + animatedNodeTag + " does not exists");
}
if (!(node instanceof PropsAnimatedNode)) {
- throw new JSApplicationIllegalArgumentException("Animated node connected to view should be" +
- "of type " + PropsAnimatedNode.class.getName());
+ throw new JSApplicationIllegalArgumentException(
+ "Animated node connected to view should be"
+ + "of type "
+ + PropsAnimatedNode.class.getName());
}
PropsAnimatedNode propsAnimatedNode = (PropsAnimatedNode) node;
propsAnimatedNode.disconnectFromView(viewTag);
@@ -329,8 +327,10 @@ import javax.annotation.Nullable;
return;
}
if (!(node instanceof PropsAnimatedNode)) {
- throw new JSApplicationIllegalArgumentException("Animated node connected to view should be" +
- "of type " + PropsAnimatedNode.class.getName());
+ throw new JSApplicationIllegalArgumentException(
+ "Animated node connected to view should be"
+ + "of type "
+ + PropsAnimatedNode.class.getName());
}
PropsAnimatedNode propsAnimatedNode = (PropsAnimatedNode) node;
propsAnimatedNode.restoreDefaultValues();
@@ -340,12 +340,14 @@ import javax.annotation.Nullable;
int nodeTag = eventMapping.getInt("animatedValueTag");
AnimatedNode node = mAnimatedNodes.get(nodeTag);
if (node == null) {
- throw new JSApplicationIllegalArgumentException("Animated node with tag " + nodeTag +
- " does not exists");
+ throw new JSApplicationIllegalArgumentException(
+ "Animated node with tag " + nodeTag + " does not exists");
}
if (!(node instanceof ValueAnimatedNode)) {
- throw new JSApplicationIllegalArgumentException("Animated node connected to event should be" +
- "of type " + ValueAnimatedNode.class.getName());
+ throw new JSApplicationIllegalArgumentException(
+ "Animated node connected to event should be"
+ + "of type "
+ + ValueAnimatedNode.class.getName());
}
ReadableArray path = eventMapping.getArray("nativeEventPath");
@@ -390,12 +392,13 @@ import javax.annotation.Nullable;
if (UiThreadUtil.isOnUiThread()) {
handleEvent(event);
} else {
- UiThreadUtil.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- handleEvent(event);
- }
- });
+ UiThreadUtil.runOnUiThread(
+ new Runnable() {
+ @Override
+ public void run() {
+ handleEvent(event);
+ }
+ });
}
}
@@ -417,12 +420,12 @@ import javax.annotation.Nullable;
}
/**
- * Animation loop performs two BFSes over the graph of animated nodes. We use incremented
- * {@code mAnimatedGraphBFSColor} to mark nodes as visited in each of the BFSes which saves
- * additional loops for clearing "visited" states.
+ * Animation loop performs two BFSes over the graph of animated nodes. We use incremented {@code
+ * mAnimatedGraphBFSColor} to mark nodes as visited in each of the BFSes which saves additional
+ * loops for clearing "visited" states.
*
- * First BFS starts with nodes that are in {@code mUpdatedNodes} (that is, their value have been
- * modified from JS in the last batch of JS operations) or directly attached to an active
+ * First BFS starts with nodes that are in {@code mUpdatedNodes} (that is, their value have
+ * been modified from JS in the last batch of JS operations) or directly attached to an active
* animation (hence linked to objects from {@code mActiveAnimations}). In that step we calculate
* an attribute {@code mActiveIncomingNodes}. The second BFS runs in topological order over the
* sub-graph of *active* nodes. This is done by adding node to the BFS queue only if all its
@@ -543,14 +546,20 @@ import javax.annotation.Nullable;
try {
((PropsAnimatedNode) nextNode).updateView();
} catch (IllegalViewOperationException e) {
- // An exception is thrown if the view hasn't been created yet. This can happen because views are
- // created in batches. If this particular view didn't make it into a batch yet, the view won't
- // exist and an exception will be thrown when attempting to start an animation on it.
- //
- // Eat the exception rather than crashing. The impact is that we may drop one or more frames of the
- // animation.
- FLog.e(ReactConstants.TAG, "Native animation workaround, frame lost as result of race condition", e);
- }
+ // An exception is thrown if the view hasn't been created yet. This can happen because
+ // views are
+ // created in batches. If this particular view didn't make it into a batch yet, the view
+ // won't
+ // exist and an exception will be thrown when attempting to start an animation on it.
+ //
+ // Eat the exception rather than crashing. The impact is that we may drop one or more
+ // frames of the
+ // animation.
+ FLog.e(
+ ReactConstants.TAG,
+ "Native animation workaround, frame lost as result of race condition",
+ e);
+ }
}
if (nextNode instanceof ValueAnimatedNode) {
// Potentially send events to JS when the node's value is updated
@@ -574,8 +583,11 @@ import javax.annotation.Nullable;
// visited in the step above so that all the nodes properties `mActiveIncomingNodes` are set to
// zero
if (activeNodesCount != updatedNodesCount) {
- throw new IllegalStateException("Looks like animated nodes graph has cycles, there are "
- + activeNodesCount + " but toposort visited only " + updatedNodesCount);
+ throw new IllegalStateException(
+ "Looks like animated nodes graph has cycles, there are "
+ + activeNodesCount
+ + " but toposort visited only "
+ + updatedNodesCount);
}
}
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/animated/PropsAnimatedNode.java b/ReactAndroid/src/main/java/com/facebook/react/animated/PropsAnimatedNode.java
index 7bb7eaaeba2..0a56eb96e3b 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/animated/PropsAnimatedNode.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/animated/PropsAnimatedNode.java
@@ -1,27 +1,24 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.animated;
import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
import com.facebook.react.bridge.JavaOnlyMap;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.ReadableMapKeySetIterator;
-
import com.facebook.react.bridge.UIManager;
import java.util.HashMap;
import java.util.Map;
-
import javax.annotation.Nullable;
/**
* Animated node that represents view properties. There is a special handling logic implemented for
- * the nodes of this type in {@link NativeAnimatedNodesManager} that is responsible for extracting
- * a map of updated properties, which can be then passed down to the view.
+ * the nodes of this type in {@link NativeAnimatedNodesManager} that is responsible for extracting a
+ * map of updated properties, which can be then passed down to the view.
*/
/*package*/ class PropsAnimatedNode extends AnimatedNode {
@@ -31,7 +28,10 @@ import javax.annotation.Nullable;
private final Map This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.animated;
import com.facebook.react.bridge.ReadableMap;
/**
* Implementation of {@link AnimationDriver} providing support for spring animations. The
- * implementation has been copied from android implementation of Rebound library (see
- * http://facebook.github.io/rebound/)
+ * implementation has been copied from android implementation of Rebound library (see http://facebook.github.io/rebound/)
*/
/*package*/ class SpringAnimation extends AnimationDriver {
@@ -101,6 +100,7 @@ import com.facebook.react.bridge.ReadableMap;
/**
* get the displacement from rest for a given physics state
+ *
* @param state the state to measure from
* @return the distance displaced by
*/
@@ -110,22 +110,24 @@ import com.facebook.react.bridge.ReadableMap;
/**
* check if the current state is at rest
+ *
* @return is the spring at rest
*/
private boolean isAtRest() {
- return Math.abs(mCurrentState.velocity) <= mRestSpeedThreshold &&
- (getDisplacementDistanceForState(mCurrentState) <= mDisplacementFromRestThreshold ||
- mSpringStiffness == 0);
+ return Math.abs(mCurrentState.velocity) <= mRestSpeedThreshold
+ && (getDisplacementDistanceForState(mCurrentState) <= mDisplacementFromRestThreshold
+ || mSpringStiffness == 0);
}
/**
* Check if the spring is overshooting beyond its target.
+ *
* @return true if the spring is overshooting its target
*/
private boolean isOvershooting() {
- return mSpringStiffness > 0 &&
- ((mStartValue < mEndValue && mCurrentState.position > mEndValue) ||
- (mStartValue > mEndValue && mCurrentState.position < mEndValue));
+ return mSpringStiffness > 0
+ && ((mStartValue < mEndValue && mCurrentState.position > mEndValue)
+ || (mStartValue > mEndValue && mCurrentState.position < mEndValue));
}
private void advance(double realDeltaTime) {
@@ -147,7 +149,7 @@ import com.facebook.react.bridge.ReadableMap;
double k = mSpringStiffness;
double v0 = -mInitialVelocity;
- double zeta = c / (2 * Math.sqrt(k * m ));
+ double zeta = c / (2 * Math.sqrt(k * m));
double omega0 = Math.sqrt(k / m);
double omega1 = omega0 * Math.sqrt(1.0 - (zeta * zeta));
double x0 = mEndValue - mStartValue;
@@ -159,27 +161,26 @@ import com.facebook.react.bridge.ReadableMap;
// Under damped
double envelope = Math.exp(-zeta * omega0 * t);
position =
- mEndValue -
- envelope *
- ((v0 + zeta * omega0 * x0) / omega1 * Math.sin(omega1 * t) +
- x0 * Math.cos(omega1 * t));
+ mEndValue
+ - envelope
+ * ((v0 + zeta * omega0 * x0) / omega1 * Math.sin(omega1 * t)
+ + x0 * Math.cos(omega1 * t));
// This looks crazy -- it's actually just the derivative of the
// oscillation function
velocity =
- zeta *
- omega0 *
- envelope *
- (Math.sin(omega1 * t) * (v0 + zeta * omega0 * x0) / omega1 +
- x0 * Math.cos(omega1 * t)) -
- envelope *
- (Math.cos(omega1 * t) * (v0 + zeta * omega0 * x0) -
- omega1 * x0 * Math.sin(omega1 * t));
+ zeta
+ * omega0
+ * envelope
+ * (Math.sin(omega1 * t) * (v0 + zeta * omega0 * x0) / omega1
+ + x0 * Math.cos(omega1 * t))
+ - envelope
+ * (Math.cos(omega1 * t) * (v0 + zeta * omega0 * x0)
+ - omega1 * x0 * Math.sin(omega1 * t));
} else {
// Critically damped spring
double envelope = Math.exp(-omega0 * t);
position = mEndValue - envelope * (x0 + (v0 + omega0 * x0) * t);
- velocity =
- envelope * (v0 * (t * omega0 - 1) + t * x0 * (omega0 * omega0));
+ velocity = envelope * (v0 * (t * omega0 - 1) + t * x0 * (omega0 * omega0));
}
mCurrentState.position = position;
diff --git a/ReactAndroid/src/main/java/com/facebook/react/animated/StyleAnimatedNode.java b/ReactAndroid/src/main/java/com/facebook/react/animated/StyleAnimatedNode.java
index 0a46c31facd..94cff86c001 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/animated/StyleAnimatedNode.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/animated/StyleAnimatedNode.java
@@ -1,19 +1,16 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.animated;
import com.facebook.react.bridge.JavaOnlyMap;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.ReadableMapKeySetIterator;
-
import java.util.HashMap;
import java.util.Map;
-
import javax.annotation.Nullable;
/**
@@ -46,8 +43,8 @@ import javax.annotation.Nullable;
} else if (node instanceof ValueAnimatedNode) {
propsMap.putDouble(entry.getKey(), ((ValueAnimatedNode) node).getValue());
} else {
- throw new IllegalArgumentException("Unsupported type of node used in property node " +
- node.getClass());
+ throw new IllegalArgumentException(
+ "Unsupported type of node used in property node " + node.getClass());
}
}
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/animated/SubtractionAnimatedNode.java b/ReactAndroid/src/main/java/com/facebook/react/animated/SubtractionAnimatedNode.java
index ac29638a2d3..c54fbe83b7b 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/animated/SubtractionAnimatedNode.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/animated/SubtractionAnimatedNode.java
@@ -1,10 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.animated;
import com.facebook.react.bridge.JSApplicationCausedNativeException;
@@ -21,8 +20,7 @@ import com.facebook.react.bridge.ReadableMap;
private final int[] mInputNodes;
public SubtractionAnimatedNode(
- ReadableMap config,
- NativeAnimatedNodesManager nativeAnimatedNodesManager) {
+ ReadableMap config, NativeAnimatedNodesManager nativeAnimatedNodesManager) {
mNativeAnimatedNodesManager = nativeAnimatedNodesManager;
ReadableArray inputNodes = config.getArray("input");
mInputNodes = new int[inputNodes.size()];
@@ -43,8 +41,8 @@ import com.facebook.react.bridge.ReadableMap;
}
mValue -= ((ValueAnimatedNode) animatedNode).getValue();
} else {
- throw new JSApplicationCausedNativeException("Illegal node ID set as an input for " +
- "Animated.subtract node");
+ throw new JSApplicationCausedNativeException(
+ "Illegal node ID set as an input for " + "Animated.subtract node");
}
}
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/animated/TrackingAnimatedNode.java b/ReactAndroid/src/main/java/com/facebook/react/animated/TrackingAnimatedNode.java
index 76108b548a3..ea1f6685a16 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/animated/TrackingAnimatedNode.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/animated/TrackingAnimatedNode.java
@@ -1,10 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.animated;
import com.facebook.react.bridge.JavaOnlyMap;
@@ -30,6 +29,7 @@ import com.facebook.react.bridge.ReadableMap;
public void update() {
AnimatedNode toValue = mNativeAnimatedNodesManager.getNodeById(mToValueNode);
mAnimationConfig.putDouble("toValue", ((ValueAnimatedNode) toValue).getValue());
- mNativeAnimatedNodesManager.startAnimatingNode(mAnimationId, mValueNode, mAnimationConfig, null);
+ mNativeAnimatedNodesManager.startAnimatingNode(
+ mAnimationId, mValueNode, mAnimationConfig, null);
}
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/animated/TransformAnimatedNode.java b/ReactAndroid/src/main/java/com/facebook/react/animated/TransformAnimatedNode.java
index 9288c25d6bf..466cf28ef56 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/animated/TransformAnimatedNode.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/animated/TransformAnimatedNode.java
@@ -1,22 +1,21 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.animated;
import com.facebook.react.bridge.JavaOnlyArray;
import com.facebook.react.bridge.JavaOnlyMap;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
-
import java.util.ArrayList;
import java.util.List;
/**
- * Native counterpart of transform animated node (see AnimatedTransform class in AnimatedImplementation.js)
+ * Native counterpart of transform animated node (see AnimatedTransform class in
+ * AnimatedImplementation.js)
*/
/* package */ class TransformAnimatedNode extends AnimatedNode {
@@ -70,8 +69,8 @@ import java.util.List;
} else if (node instanceof ValueAnimatedNode) {
value = ((ValueAnimatedNode) node).getValue();
} else {
- throw new IllegalArgumentException("Unsupported type of node used as a transform child " +
- "node " + node.getClass());
+ throw new IllegalArgumentException(
+ "Unsupported type of node used as a transform child " + "node " + node.getClass());
}
} else {
value = ((StaticTransformConfig) transformConfig).mValue;
diff --git a/ReactAndroid/src/main/java/com/facebook/react/animated/ValueAnimatedNode.java b/ReactAndroid/src/main/java/com/facebook/react/animated/ValueAnimatedNode.java
index 0c92f11f899..5ecec926f8b 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/animated/ValueAnimatedNode.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/animated/ValueAnimatedNode.java
@@ -1,14 +1,12 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.animated;
import com.facebook.react.bridge.ReadableMap;
-
import javax.annotation.Nullable;
/**
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/ActivityEventListener.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/ActivityEventListener.java
index f4b6f51f933..4cd950409f5 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/ActivityEventListener.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ActivityEventListener.java
@@ -14,13 +14,9 @@ import android.content.Intent;
*/
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(Activity activity, int requestCode, int resultCode, Intent data);
- /**
- * Called when a new intent is passed to the activity
- */
+ /** Called when a new intent is passed to the activity */
void onNewIntent(Intent intent);
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/Arguments.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/Arguments.java
index deffbe52655..2fee9d3b1c0 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/Arguments.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/Arguments.java
@@ -1,30 +1,27 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
package com.facebook.react.bridge;
+import android.os.Bundle;
import java.lang.reflect.Array;
-
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-
import javax.annotation.Nullable;
-import android.os.Bundle;
-
public class Arguments {
private static Object makeNativeObject(Object object) {
if (object == null) {
return null;
- } else if (object instanceof Float ||
- object instanceof Long ||
- object instanceof Byte ||
- object instanceof Short) {
+ } else if (object instanceof Float
+ || object instanceof Long
+ || object instanceof Byte
+ || object instanceof Short) {
return ((Number) object).doubleValue();
} else if (object.getClass().isArray()) {
return makeNativeArray(object);
@@ -41,12 +38,11 @@ public class Arguments {
}
/**
- * This method converts a List into a NativeArray. The data types supported
- * are boolean, int, float, double, and String. List, Map, and Bundle
- * objects, as well as arrays, containing values of the above types and/or
- * null, or any recursive arrangement of these, are also supported. The best
- * way to think of this is a way to generate a Java representation of a json
- * list, from Java types which have a natural representation in json.
+ * This method converts a List into a NativeArray. The data types supported are boolean, int,
+ * float, double, and String. List, Map, and Bundle objects, as well as arrays, containing values
+ * of the above types and/or null, or any recursive arrangement of these, are also supported. The
+ * best way to think of this is a way to generate a Java representation of a json list, from Java
+ * types which have a natural representation in json.
*/
public static WritableNativeArray makeNativeArray(List objects) {
WritableNativeArray nativeArray = new WritableNativeArray();
@@ -77,8 +73,8 @@ public class Arguments {
}
/**
- * This overload is like the above, but uses reflection to operate on any
- * primitive or object type.
+ * This overload is like the above, but uses reflection to operate on any primitive or object
+ * type.
*/
public static
+ *
* This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
/**
- * Like {@link AssertionError} but extends RuntimeException so that it may be caught by a
- * {@link NativeModuleCallExceptionHandler}. See that class for more details. Used in
- * conjunction with {@link SoftAssertions}.
+ * Like {@link AssertionError} but extends RuntimeException so that it may be caught by a {@link
+ * NativeModuleCallExceptionHandler}. See that class for more details. Used in conjunction with
+ * {@link SoftAssertions}.
*/
public class AssertionException extends RuntimeException {
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/BaseActivityEventListener.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/BaseActivityEventListener.java
index d7369ad1932..98d67b86b22 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/BaseActivityEventListener.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/BaseActivityEventListener.java
@@ -8,20 +8,16 @@ package com.facebook.react.bridge;
import android.app.Activity;
import android.content.Intent;
-/**
- * An empty implementation of {@link ActivityEventListener}
- */
+/** An empty implementation of {@link ActivityEventListener} */
public class BaseActivityEventListener implements ActivityEventListener {
- /**
- * @deprecated use {@link #onActivityResult(Activity, int, int, Intent)} instead.
- */
+ /** @deprecated use {@link #onActivityResult(Activity, int, int, Intent)} instead. */
@Deprecated
- public void onActivityResult(int requestCode, int resultCode, Intent data) { }
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {}
@Override
- public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) { }
+ public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {}
@Override
- public void onNewIntent(Intent intent) { }
+ public void onNewIntent(Intent intent) {}
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/BaseJavaModule.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/BaseJavaModule.java
index 086b939355f..51ac27100f0 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/BaseJavaModule.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/BaseJavaModule.java
@@ -1,49 +1,44 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
-import javax.annotation.Nullable;
-
import java.util.Map;
+import javax.annotation.Nullable;
/**
* Base class for Catalyst native modules whose implementations are written in Java. Default
* implementations for {@link #initialize} and {@link #onCatalystInstanceDestroy} are provided for
- * convenience. Subclasses which override these don't need to call {@code super} in case of
+ * convenience. Subclasses which override these don't need to call {@code super} in case of
* overriding those methods as implementation of those methods is empty.
*
- * BaseJavaModules can be linked to Fragments' lifecycle events, {@link CatalystInstance} creation
- * and destruction, by being called on the appropriate method when a life cycle event occurs.
+ * BaseJavaModules can be linked to Fragments' lifecycle events, {@link CatalystInstance}
+ * creation and destruction, by being called on the appropriate method when a life cycle event
+ * occurs.
*
- * Native methods can be exposed to JS with {@link ReactMethod} annotation. Those methods may
- * only use limited number of types for their arguments:
- * 1/ primitives (boolean, int, float, double
- * 2/ {@link String} mapped from JS string
- * 3/ {@link ReadableArray} mapped from JS Array
- * 4/ {@link ReadableMap} mapped from JS Object
- * 5/ {@link Callback} mapped from js function and can be used only as a last parameter or in the
- * case when it express success & error callback pair as two last arguments respectively.
+ * Native methods can be exposed to JS with {@link ReactMethod} annotation. Those methods may
+ * only use limited number of types for their arguments: 1/ primitives (boolean, int, float, double
+ * 2/ {@link String} mapped from JS string 3/ {@link ReadableArray} mapped from JS Array 4/ {@link
+ * ReadableMap} mapped from JS Object 5/ {@link Callback} mapped from js function and can be used
+ * only as a last parameter or in the case when it express success & error callback pair as two last
+ * arguments respectively.
*
- * All methods exposed as native to JS with {@link ReactMethod} annotation must return
- * {@code void}.
+ * All methods exposed as native to JS with {@link ReactMethod} annotation must return {@code
+ * void}.
*
- * Please note that it is not allowed to have multiple methods annotated with {@link ReactMethod}
+ * Please note that it is not allowed to have multiple methods annotated with {@link ReactMethod}
* with the same name.
*/
public abstract class BaseJavaModule implements NativeModule {
// taken from Libraries/Utilities/MessageQueue.js
- static final public String METHOD_TYPE_ASYNC = "async";
- static final public String METHOD_TYPE_PROMISE= "promise";
- static final public String METHOD_TYPE_SYNC = "sync";
+ public static final String METHOD_TYPE_ASYNC = "async";
+ public static final String METHOD_TYPE_PROMISE = "promise";
+ public static final String METHOD_TYPE_SYNC = "sync";
- /**
- * @return a map of constants this module exports to JS. Supports JSON types.
- */
+ /** @return a map of constants this module exports to JS. Supports JSON types. */
public @Nullable Map This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
/**
- * Interface that represent javascript callback function which can be passed to the native module
- * as a method parameter.
+ * Interface that represent javascript callback function which can be passed to the native module as
+ * a method parameter.
*/
public interface Callback {
@@ -19,5 +18,4 @@ public interface Callback {
* @param args arguments passed to javascript callback method via bridge
*/
public void invoke(Object... args);
-
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/CallbackImpl.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/CallbackImpl.java
index 9bef1b06189..09de03d4e4b 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/CallbackImpl.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/CallbackImpl.java
@@ -1,15 +1,12 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
-/**
- * Implementation of javascript callback function that use Bridge to schedule method execution
- */
+/** Implementation of javascript callback function that use Bridge to schedule method execution */
public final class CallbackImpl implements Callback {
private final JSInstance mJSInstance;
@@ -25,9 +22,10 @@ public final class CallbackImpl implements Callback {
@Override
public void invoke(Object... args) {
if (mInvoked) {
- throw new RuntimeException("Illegal callback invocation from native "+
- "module. This callback type only permits a single invocation from "+
- "native code.");
+ throw new RuntimeException(
+ "Illegal callback invocation from native "
+ + "module. This callback type only permits a single invocation from "
+ + "native code.");
}
mJSInstance.invokeCallback(mCallbackId, Arguments.fromJavaArgs(args));
mInvoked = true;
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstance.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstance.java
index 97048de46d8..703386ff0a3 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstance.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstance.java
@@ -1,25 +1,23 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.bridge.queue.ReactQueueConfiguration;
import com.facebook.react.common.annotations.VisibleForTesting;
import com.facebook.react.turbomodule.core.interfaces.JSCallInvokerHolder;
-import com.facebook.react.turbomodule.core.interfaces.TurboModuleRegistry;
import java.util.Collection;
import java.util.List;
import javax.annotation.Nullable;
/**
- * A higher level API on top of the asynchronous JSC bridge. This provides an
- * environment allowing the invocation of JavaScript methods and lets a set of
- * Java APIs be invokable from JavaScript as well.
+ * A higher level API on top of the asynchronous JSC bridge. This provides an environment allowing
+ * the invocation of JavaScript methods and lets a set of Java APIs be invokable from JavaScript as
+ * well.
*/
@DoNotStrip
public interface CatalystInstance
@@ -30,48 +28,50 @@ public interface CatalystInstance
boolean hasRunJSBundle();
/**
- * Return the source URL of the JS Bundle that was run, or {@code null} if no JS
- * bundle has been run yet.
+ * Return the source URL of the JS Bundle that was run, or {@code null} if no JS bundle has been
+ * run yet.
*/
- @Nullable String getSourceURL();
+ @Nullable
+ String getSourceURL();
// This is called from java code, so it won't be stripped anyway, but proguard will rename it,
// which this prevents.
- @Override @DoNotStrip
- void invokeCallback(
- int callbackID,
- NativeArrayInterface arguments);
+ @Override
@DoNotStrip
- void callFunction(
- String module,
- String method,
- NativeArray arguments);
+ void invokeCallback(int callbackID, NativeArrayInterface arguments);
+
+ @DoNotStrip
+ void callFunction(String module, String method, NativeArray arguments);
/**
* Destroys this catalyst instance, waiting for any other threads in ReactQueueConfiguration
* (besides the UI thread) to finish running. Must be called from the UI thread so that we can
* fully shut down other threads.
*/
void destroy();
+
boolean isDestroyed();
- /**
- * Initialize all the native modules
- */
+ /** Initialize all the native modules */
@VisibleForTesting
void initialize();
ReactQueueConfiguration getReactQueueConfiguration();
This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE;
@@ -38,8 +37,8 @@ import java.util.concurrent.atomic.AtomicInteger;
import javax.annotation.Nullable;
/**
- * This provides an implementation of the public CatalystInstance instance. It is public because
- * it is built by XReactInstanceManager which is in a different package.
+ * This provides an implementation of the public CatalystInstance instance. It is public because it
+ * is built by XReactInstanceManager which is in a different package.
*/
@DoNotStrip
public class CatalystInstanceImpl implements CatalystInstance {
@@ -67,8 +66,12 @@ public class CatalystInstanceImpl implements CatalystInstance {
}
public String toString() {
- return mModule + "." + mMethod + "("
- + (mArguments == null ? "" : mArguments.toString()) + ")";
+ return mModule
+ + "."
+ + mMethod
+ + "("
+ + (mArguments == null ? "" : mArguments.toString())
+ + ")";
}
}
@@ -100,7 +103,9 @@ public class CatalystInstanceImpl implements CatalystInstance {
// C++ parts
private final HybridData mHybridData;
- private native static HybridData initHybrid();
+
+ private static native HybridData initHybrid();
+
public native JSCallInvokerHolderImpl getJSCallInvokerHolder();
private CatalystInstanceImpl(
@@ -114,9 +119,9 @@ public class CatalystInstanceImpl implements CatalystInstance {
mHybridData = initHybrid();
- mReactQueueConfiguration = ReactQueueConfigurationImpl.create(
- reactQueueConfigurationSpec,
- new NativeExceptionHandler());
+ mReactQueueConfiguration =
+ ReactQueueConfigurationImpl.create(
+ reactQueueConfigurationSpec, new NativeExceptionHandler());
mBridgeIdleListeners = new CopyOnWriteArrayList<>();
mNativeModuleRegistry = nativeModuleRegistry;
mJSModuleRegistry = new JavaScriptModuleRegistry();
@@ -129,12 +134,12 @@ public class CatalystInstanceImpl implements CatalystInstance {
Log.d(ReactConstants.TAG, "Initializing React Xplat Bridge before initializeBridge");
Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "initializeCxxBridge");
initializeBridge(
- new BridgeCallback(this),
- jsExecutor,
- mReactQueueConfiguration.getJSQueueThread(),
- mNativeModulesQueueThread,
- mNativeModuleRegistry.getJavaModules(this),
- mNativeModuleRegistry.getCxxModules());
+ new BridgeCallback(this),
+ jsExecutor,
+ mReactQueueConfiguration.getJSQueueThread(),
+ mNativeModulesQueueThread,
+ mNativeModuleRegistry.getJavaModules(this),
+ mNativeModuleRegistry.getCxxModules());
Log.d(ReactConstants.TAG, "Initializing React Xplat Bridge after initializeBridge");
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
@@ -177,24 +182,23 @@ public class CatalystInstanceImpl implements CatalystInstance {
}
/**
- * This method and the native below permits a CatalystInstance to extend the known
- * Native modules. This registry contains only the new modules to load. The
- * registry {@code mNativeModuleRegistry} updates internally to contain all the new modules, and generates
- * the new registry for extracting just the new collections.
+ * This method and the native below permits a CatalystInstance to extend the known Native modules.
+ * This registry contains only the new modules to load. The registry {@code mNativeModuleRegistry}
+ * updates internally to contain all the new modules, and generates the new registry for
+ * extracting just the new collections.
*/
@Override
public void extendNativeModules(NativeModuleRegistry modules) {
- //Extend the Java-visible registry of modules
+ // Extend the Java-visible registry of modules
mNativeModuleRegistry.registerModules(modules);
Collection This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
import android.content.Context;
/**
- * Base class for React native modules that require access to an Android
- * {@link Context} instance.
+ * Base class for React native modules that require access to an Android {@link Context} instance.
*/
public abstract class ContextBaseJavaModule extends BaseJavaModule {
@@ -21,9 +19,7 @@ public abstract class ContextBaseJavaModule extends BaseJavaModule {
mContext = context;
}
- /**
- * Subclasses can use this method to access Android context passed as a constructor
- */
+ /** Subclasses can use this method to access Android context passed as a constructor */
protected final Context getContext() {
return mContext;
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/CxxCallbackImpl.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/CxxCallbackImpl.java
index 839da9a704b..ba20cd72014 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/CxxCallbackImpl.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/CxxCallbackImpl.java
@@ -5,20 +5,15 @@
package com.facebook.react.bridge;
-import com.facebook.jni.HybridData;
-import com.facebook.proguard.annotations.DoNotStrip;
-import com.facebook.react.bridge.Callback;
-import com.facebook.react.bridge.NativeArray;
-
import static com.facebook.react.bridge.Arguments.*;
-/**
- * Callback impl that calls directly into the cxx bridge. Created from C++.
- */
+import com.facebook.jni.HybridData;
+import com.facebook.proguard.annotations.DoNotStrip;
+
+/** Callback impl that calls directly into the cxx bridge. Created from C++. */
@DoNotStrip
public class CxxCallbackImpl implements Callback {
- @DoNotStrip
- private final HybridData mHybridData;
+ @DoNotStrip private final HybridData mHybridData;
@DoNotStrip
private CxxCallbackImpl(HybridData hybridData) {
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/CxxModuleWrapper.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/CxxModuleWrapper.java
index a60704ecb42..cb9f15d41e3 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/CxxModuleWrapper.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/CxxModuleWrapper.java
@@ -9,12 +9,9 @@ import com.facebook.jni.HybridData;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.soloader.SoLoader;
-/**
- * This does nothing interesting, except avoid breaking existing code.
- */
+/** This does nothing interesting, except avoid breaking existing code. */
@DoNotStrip
-public class CxxModuleWrapper extends CxxModuleWrapperBase
-{
+public class CxxModuleWrapper extends CxxModuleWrapperBase {
protected CxxModuleWrapper(HybridData hd) {
super(hd);
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/CxxModuleWrapperBase.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/CxxModuleWrapperBase.java
index 1fa8e97019f..7c7284ffd49 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/CxxModuleWrapperBase.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/CxxModuleWrapperBase.java
@@ -11,18 +11,16 @@ import com.facebook.proguard.annotations.DoNotStrip;
/**
* A Java Object which represents a cross-platform C++ module
*
- * This module implements the NativeModule interface but will never be invoked from Java,
- * instead the underlying Cxx module will be extracted by the bridge and called directly.
+ * This module implements the NativeModule interface but will never be invoked from Java, instead
+ * the underlying Cxx module will be extracted by the bridge and called directly.
*/
@DoNotStrip
-public class CxxModuleWrapperBase implements NativeModule
-{
+public class CxxModuleWrapperBase implements NativeModule {
static {
ReactBridge.staticInit();
}
- @DoNotStrip
- private HybridData mHybridData;
+ @DoNotStrip private HybridData mHybridData;
@Override
public native String getName();
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/DefaultNativeModuleCallExceptionHandler.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/DefaultNativeModuleCallExceptionHandler.java
index 0204a14e873..a8866d0b16e 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/DefaultNativeModuleCallExceptionHandler.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/DefaultNativeModuleCallExceptionHandler.java
@@ -1,15 +1,12 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
-/**
- * Crashy crashy exception handler.
- */
+/** Crashy crashy exception handler. */
public class DefaultNativeModuleCallExceptionHandler implements NativeModuleCallExceptionHandler {
@Override
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/Dynamic.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/Dynamic.java
index 67f414ddff6..bddf4fddaed 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/Dynamic.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/Dynamic.java
@@ -1,10 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
/**
@@ -13,12 +12,20 @@ package com.facebook.react.bridge;
*/
public interface Dynamic {
boolean isNull();
+
boolean asBoolean();
+
double asDouble();
+
int asInt();
+
String asString();
+
ReadableArray asArray();
+
ReadableMap asMap();
+
ReadableType getType();
+
void recycle();
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/DynamicFromArray.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/DynamicFromArray.java
index d05a80d295c..39e310d278c 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/DynamicFromArray.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/DynamicFromArray.java
@@ -1,19 +1,15 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
+import androidx.core.util.Pools;
import javax.annotation.Nullable;
-import androidx.core.util.Pools;
-
-/**
- * Implementation of Dynamic wrapping a ReadableArray.
- */
+/** Implementation of Dynamic wrapping a ReadableArray. */
public class DynamicFromArray implements Dynamic {
private static final Pools.SimplePool This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
+import androidx.core.util.Pools.SimplePool;
import javax.annotation.Nullable;
-import androidx.core.util.Pools.SimplePool;
-
-/**
- * Implementation of Dynamic wrapping a ReadableMap.
- */
+/** Implementation of Dynamic wrapping a ReadableMap. */
public class DynamicFromMap implements Dynamic {
- private static final ThreadLocal This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
import com.facebook.common.logging.FLog;
import com.facebook.react.common.ReactConstants;
import javax.annotation.Nullable;
-/**
- * Implementation of Dynamic wrapping a ReadableArray.
- */
+/** Implementation of Dynamic wrapping a ReadableArray. */
public class DynamicFromObject implements Dynamic {
private @Nullable Object mObject;
@@ -33,33 +30,33 @@ public class DynamicFromObject implements Dynamic {
@Override
public boolean asBoolean() {
- return (boolean)mObject;
+ return (boolean) mObject;
}
@Override
public double asDouble() {
- return (double)mObject;
+ return (double) mObject;
}
@Override
public int asInt() {
// Numbers from JS are always Doubles
- return ((Double)mObject).intValue();
+ return ((Double) mObject).intValue();
}
@Override
public String asString() {
- return (String)mObject;
+ return (String) mObject;
}
@Override
public ReadableArray asArray() {
- return (ReadableArray)mObject;
+ return (ReadableArray) mObject;
}
@Override
public ReadableMap asMap() {
- return (ReadableMap)mObject;
+ return (ReadableMap) mObject;
}
@Override
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/FallbackJSBundleLoader.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/FallbackJSBundleLoader.java
index 50c47aa8a18..d66802a7707 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/FallbackJSBundleLoader.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/FallbackJSBundleLoader.java
@@ -1,25 +1,23 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
+import com.facebook.common.logging.FLog;
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
import java.util.Stack;
-import com.facebook.common.logging.FLog;
-
/**
* FallbackJSBundleLoader
*
- * An implementation of {@link JSBundleLoader} that will try to load from
- * multiple sources, falling back from one source to the next at load time
- * when an exception is thrown for a recoverable error.
+ * An implementation of {@link JSBundleLoader} that will try to load from multiple sources,
+ * falling back from one source to the next at load time when an exception is thrown for a
+ * recoverable error.
*/
public final class FallbackJSBundleLoader extends JSBundleLoader {
@@ -32,10 +30,7 @@ public final class FallbackJSBundleLoader extends JSBundleLoader {
// Reasons why we fell-back on previous loaders, in order of occurrence.
private final ArrayList This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
import android.os.AsyncTask;
/**
- * Abstract base for a AsyncTask that should have any RuntimeExceptions it throws
- * handled by the {@link com.facebook.react.bridge.NativeModuleCallExceptionHandler} registered if
- * the app is in dev mode.
+ * Abstract base for a AsyncTask that should have any RuntimeExceptions it throws handled by the
+ * {@link com.facebook.react.bridge.NativeModuleCallExceptionHandler} registered if the app is in
+ * dev mode.
*
- * This class doesn't allow doInBackground to return a results. If you need this
- * use GuardedResultAsyncTask instead.
+ * This class doesn't allow doInBackground to return a results. If you need this use
+ * GuardedResultAsyncTask instead.
*/
-public abstract class GuardedAsyncTask This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
import com.facebook.proguard.annotations.DoNotStrip;
/**
- * Exception thrown by {@link ReadableMapKeySetIterator#nextKey()} when the iterator tries
- * to iterate over elements after the end of the key set.
+ * Exception thrown by {@link ReadableMapKeySetIterator#nextKey()} when the iterator tries to
+ * iterate over elements after the end of the key set.
*/
@DoNotStrip
public class InvalidIteratorException extends RuntimeException {
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/JSApplicationCausedNativeException.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/JSApplicationCausedNativeException.java
index 078b042e7b6..6adb752a629 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/JSApplicationCausedNativeException.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/JSApplicationCausedNativeException.java
@@ -1,10 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
import javax.annotation.Nullable;
@@ -13,19 +12,18 @@ import javax.annotation.Nullable;
* A special RuntimeException that should be thrown by native code if it has reached an exceptional
* state due to a, or a sequence of, bad commands.
*
- * A good rule of thumb for whether a native Exception should extend this interface is 1) Can a
+ * A good rule of thumb for whether a native Exception should extend this interface is 1) Can a
* developer make a change or correction in JS to keep this Exception from being thrown? 2) Is the
* app outside of this catalyst instance still in a good state to allow reloading and restarting
* this catalyst instance?
*
- * Examples where this class is appropriate to throw:
- * - JS tries to update a view with a tag that hasn't been created yet
- * - JS tries to show a static image that isn't in resources
- * - JS tries to use an unsupported view class
+ * Examples where this class is appropriate to throw: - JS tries to update a view with a tag that
+ * hasn't been created yet - JS tries to show a static image that isn't in resources - JS tries to
+ * use an unsupported view class
*
- * Examples where this class **isn't** appropriate to throw:
- * - Failed to write to localStorage because disk is full
- * - Assertions about internal state (e.g. that child.getParent().indexOf(child) != -1)
+ * Examples where this class **isn't** appropriate to throw: - Failed to write to localStorage
+ * because disk is full - Assertions about internal state (e.g. that
+ * child.getParent().indexOf(child) != -1)
*/
public class JSApplicationCausedNativeException extends RuntimeException {
@@ -34,8 +32,7 @@ public class JSApplicationCausedNativeException extends RuntimeException {
}
public JSApplicationCausedNativeException(
- @Nullable String detailMessage,
- @Nullable Throwable throwable) {
+ @Nullable String detailMessage, @Nullable Throwable throwable) {
super(detailMessage, throwable);
}
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/JSApplicationIllegalArgumentException.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/JSApplicationIllegalArgumentException.java
index 365ac08bd19..887480dcdc0 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/JSApplicationIllegalArgumentException.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/JSApplicationIllegalArgumentException.java
@@ -1,15 +1,12 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
-/**
- * An illegal argument Exception caused by an argument passed from JS.
- */
+/** An illegal argument Exception caused by an argument passed from JS. */
public class JSApplicationIllegalArgumentException extends JSApplicationCausedNativeException {
public JSApplicationIllegalArgumentException(String detailMessage) {
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/JSBundleLoader.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/JSBundleLoader.java
index 9a67632c5c3..12b35eb17a8 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/JSBundleLoader.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/JSBundleLoader.java
@@ -1,18 +1,17 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
import android.content.Context;
import com.facebook.react.common.DebugServerException;
/**
- * A class that stores JS bundle information and allows a {@link JSBundleLoaderDelegate}
- * (e.g. {@link CatalystInstance}) to load a correct bundle through {@link ReactBridge}.
+ * A class that stores JS bundle information and allows a {@link JSBundleLoaderDelegate} (e.g.
+ * {@link CatalystInstance}) to load a correct bundle through {@link ReactBridge}.
*/
public abstract class JSBundleLoader {
@@ -22,9 +21,7 @@ public abstract class JSBundleLoader {
* strings from java to native memory.
*/
public static JSBundleLoader createAssetLoader(
- final Context context,
- final String assetUrl,
- final boolean loadSynchronously) {
+ final Context context, final String assetUrl, final boolean loadSynchronously) {
return new JSBundleLoader() {
@Override
public String loadScript(JSBundleLoaderDelegate delegate) {
@@ -43,9 +40,7 @@ public abstract class JSBundleLoader {
}
public static JSBundleLoader createFileLoader(
- final String fileName,
- final String assetUrl,
- final boolean loadSynchronously) {
+ final String fileName, final String assetUrl, final boolean loadSynchronously) {
return new JSBundleLoader() {
@Override
public String loadScript(JSBundleLoaderDelegate delegate) {
@@ -63,8 +58,7 @@ public abstract class JSBundleLoader {
* work correctly and allows for source maps to correctly symbolize those.
*/
public static JSBundleLoader createCachedBundleFromNetworkLoader(
- final String sourceURL,
- final String cachedFileLocation) {
+ final String sourceURL, final String cachedFileLocation) {
return new JSBundleLoader() {
@Override
public String loadScript(JSBundleLoaderDelegate delegate) {
@@ -82,11 +76,11 @@ public abstract class JSBundleLoader {
* This loader is used to load delta bundles from the dev server. We pass each delta message to
* the loader and process it in C++. Passing it as a string leads to inefficiencies due to memory
* copies, which will have to be addressed in a follow-up.
+ *
* @param nativeDeltaClient
*/
public static JSBundleLoader createDeltaFromNetworkLoader(
- final String sourceURL,
- final NativeDeltaClient nativeDeltaClient) {
+ final String sourceURL, final NativeDeltaClient nativeDeltaClient) {
return new JSBundleLoader() {
@Override
public String loadScript(JSBundleLoaderDelegate delegate) {
@@ -105,8 +99,7 @@ public abstract class JSBundleLoader {
* the bundle from device as remote executor will have to do it anyway.
*/
public static JSBundleLoader createRemoteDebuggerBundleLoader(
- final String proxySourceURL,
- final String realSourceURL) {
+ final String proxySourceURL, final String realSourceURL) {
return new JSBundleLoader() {
@Override
public String loadScript(JSBundleLoaderDelegate delegate) {
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/JSBundleLoaderDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/JSBundleLoaderDelegate.java
index 29c3af69d59..b21c5b6887d 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/JSBundleLoaderDelegate.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/JSBundleLoaderDelegate.java
@@ -1,22 +1,21 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
import android.content.Context;
import android.content.res.AssetManager;
-/**
- * An interface for classes that initialize JavaScript using {@link JSBundleLoader}
- */
+/** An interface for classes that initialize JavaScript using {@link JSBundleLoader} */
public interface JSBundleLoaderDelegate {
/**
- * Load a JS bundle from Android assets. See {@link JSBundleLoader#createAssetLoader(Context, String, boolean)}
+ * Load a JS bundle from Android assets. See {@link JSBundleLoader#createAssetLoader(Context,
+ * String, boolean)}
+ *
* @param assetManager
* @param assetURL
* @param loadSynchronously
@@ -24,8 +23,9 @@ public interface JSBundleLoaderDelegate {
void loadScriptFromAssets(AssetManager assetManager, String assetURL, boolean loadSynchronously);
/**
- * Load a JS bundle from the filesystem.
- * See {@link JSBundleLoader#createFileLoader(String)} and {@link JSBundleLoader#createCachedBundleFromNetworkLoader(String, String)}
+ * Load a JS bundle from the filesystem. See {@link JSBundleLoader#createFileLoader(String)} and
+ * {@link JSBundleLoader#createCachedBundleFromNetworkLoader(String, String)}
+ *
* @param fileName
* @param sourceURL
* @param loadSynchronously
@@ -33,26 +33,23 @@ public interface JSBundleLoaderDelegate {
void loadScriptFromFile(String fileName, String sourceURL, boolean loadSynchronously);
/**
- * Load a delta bundle from Metro.
- * See {@link JSBundleLoader#createDeltaFromNetworkLoader(String, NativeDeltaClient)}
+ * Load a delta bundle from Metro. See {@link JSBundleLoader#createDeltaFromNetworkLoader(String,
+ * NativeDeltaClient)}
+ *
* @param sourceURL
* @param deltaClient
* @param loadSynchronously
*/
void loadScriptFromDeltaBundle(
- String sourceURL,
- NativeDeltaClient deltaClient,
- boolean loadSynchronously);
+ String sourceURL, NativeDeltaClient deltaClient, boolean loadSynchronously);
/**
- * This API is used in situations where the JS bundle is being executed not on
- * the device, but on a host machine. In that case, we must provide two source
- * URLs for the JS bundle: One to be used on the device, and one to be used on
- * the remote debugging machine.
+ * This API is used in situations where the JS bundle is being executed not on the device, but on
+ * a host machine. In that case, we must provide two source URLs for the JS bundle: One to be used
+ * on the device, and one to be used on the remote debugging machine.
*
* @param deviceURL A source URL that is accessible from this device.
- * @param remoteURL A source URL that is accessible from the remote machine
- * executing the JS.
+ * @param remoteURL A source URL that is accessible from the remote machine executing the JS.
*/
void setSourceURLs(String deviceURL, String remoteURL);
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/JSCJavaScriptExecutor.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/JSCJavaScriptExecutor.java
index 08e6ca3ad44..b7090caaf0a 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/JSCJavaScriptExecutor.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/JSCJavaScriptExecutor.java
@@ -1,10 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
import com.facebook.jni.HybridData;
@@ -25,6 +24,5 @@ import com.facebook.proguard.annotations.DoNotStrip;
return "JSCJavaScriptExecutor";
}
-
- private native static HybridData initHybrid(ReadableNativeMap jscConfig);
+ private static native HybridData initHybrid(ReadableNativeMap jscConfig);
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/JSCJavaScriptExecutorFactory.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/JSCJavaScriptExecutorFactory.java
index 7fe2f16403c..ed60de01710 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/JSCJavaScriptExecutorFactory.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/JSCJavaScriptExecutorFactory.java
@@ -1,10 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
public class JSCJavaScriptExecutorFactory implements JavaScriptExecutorFactory {
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/JSIModule.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/JSIModule.java
index 43b1d3349b5..54c232ac490 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/JSIModule.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/JSIModule.java
@@ -1,26 +1,21 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
-/**
- * Marker interface used to represent a JSI Module.
- */
+/** Marker interface used to represent a JSI Module. */
public interface JSIModule {
/**
- * This is called at the end of {@link CatalystApplicationFragment#createCatalystInstance()}
- * after the CatalystInstance has been created, in order to initialize NativeModules that require
- * the CatalystInstance or JS modules.
+ * This is called at the end of {@link CatalystApplicationFragment#createCatalystInstance()} after
+ * the CatalystInstance has been created, in order to initialize NativeModules that require the
+ * CatalystInstance or JS modules.
*/
void initialize();
- /**
- * Called before {CatalystInstance#onHostDestroy}
- */
+ /** Called before {CatalystInstance#onHostDestroy} */
void onCatalystInstanceDestroy();
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/JSIModuleHolder.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/JSIModuleHolder.java
index 7e7f4b0914c..c8ec6687dac 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/JSIModuleHolder.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/JSIModuleHolder.java
@@ -1,10 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
public class JSIModuleHolder {
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/JSIModulePackage.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/JSIModulePackage.java
index e5c28700b83..430cd9b61ed 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/JSIModulePackage.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/JSIModulePackage.java
@@ -1,22 +1,17 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
import java.util.List;
-/**
- * Interface used to initialize JSI Modules into the JSI Bridge.
- */
+/** Interface used to initialize JSI Modules into the JSI Bridge. */
public interface JSIModulePackage {
- /**
- * @return a {@link List< JSIModuleSpec >} that contain the list of JSI Modules.
- */
- List This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
public interface JSIModuleProvider This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
import com.facebook.infer.annotation.Assertions;
@@ -16,7 +15,7 @@ public class JSIModuleRegistry {
private final Map This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
-/**
- * Holder class used to register {@link JSIModule} into JSI Bridge.
- */
+/** Holder class used to register {@link JSIModule} into JSI Bridge. */
public interface JSIModuleSpec This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
/**
- * A list of support JSIModules. These are usually core infra pieces, so there
- * should be an explicit list.
+ * A list of support JSIModules. These are usually core infra pieces, so there should be an explicit
+ * list.
*/
public enum JSIModuleType {
TurboModuleManager,
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/JSInstance.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/JSInstance.java
index a20ee7089b2..75d101335a9 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/JSInstance.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/JSInstance.java
@@ -1,21 +1,17 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
/**
- * This interface includes the methods needed to use a running JS
- * instance, without specifying any of the bridge-specific
- * initialization or lifecycle management.
+ * This interface includes the methods needed to use a running JS instance, without specifying any
+ * of the bridge-specific initialization or lifecycle management.
*/
public interface JSInstance {
- void invokeCallback(
- int callbackID,
- NativeArrayInterface arguments);
+ void invokeCallback(int callbackID, NativeArrayInterface arguments);
// TODO if this interface survives refactoring, think about adding
// callFunction.
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaJSExecutor.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaJSExecutor.java
index 4f6c057631e..577b7098a09 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaJSExecutor.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaJSExecutor.java
@@ -1,18 +1,17 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
import com.facebook.proguard.annotations.DoNotStrip;
/**
- * This is class represents java version of native js executor interface. When set through
- * {@link ProxyJavaScriptExecutor} as a {@link CatalystInstance} executor, native code will
- * delegate js calls to the given implementation of this interface.
+ * This is class represents java version of native js executor interface. When set through {@link
+ * ProxyJavaScriptExecutor} as a {@link CatalystInstance} executor, native code will delegate js
+ * calls to the given implementation of this interface.
*/
@DoNotStrip
public interface JavaJSExecutor {
@@ -27,13 +26,14 @@ public interface JavaJSExecutor {
}
/**
- * Close this executor and cleanup any resources that it was using. No further calls are
- * expected after this.
+ * Close this executor and cleanup any resources that it was using. No further calls are expected
+ * after this.
*/
void close();
/**
* Load javascript into the js context
+ *
* @param sourceURL url or file location from which script content was loaded
*/
@DoNotStrip
@@ -41,13 +41,13 @@ public interface JavaJSExecutor {
/**
* Execute javascript method within js context
+ *
* @param methodName name of the method to be executed
* @param jsonArgsArray json encoded array of arguments provided for the method call
* @return json encoded value returned from the method call
*/
@DoNotStrip
- String executeJSCall(String methodName, String jsonArgsArray)
- throws ProxyExecutorException;
+ String executeJSCall(String methodName, String jsonArgsArray) throws ProxyExecutorException;
@DoNotStrip
void setGlobalVariable(String propertyName, String jsonEncodedValue);
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaMethodWrapper.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaMethodWrapper.java
index 3a8bfcda2ee..edf5cfbf96d 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaMethodWrapper.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaMethodWrapper.java
@@ -1,10 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
import static com.facebook.infer.annotation.Assertions.assertNotNull;
@@ -20,118 +19,118 @@ import javax.annotation.Nullable;
public class JavaMethodWrapper implements NativeModule.NativeMethod {
- private static abstract class ArgumentExtractor This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
-import javax.annotation.Nullable;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import com.facebook.proguard.annotations.DoNotStrip;
-import com.facebook.systrace.Systrace;
-import com.facebook.systrace.SystraceMessage;
-
import static com.facebook.react.bridge.ReactMarkerConstants.CONVERT_CONSTANTS_END;
import static com.facebook.react.bridge.ReactMarkerConstants.CONVERT_CONSTANTS_START;
import static com.facebook.react.bridge.ReactMarkerConstants.GET_CONSTANTS_END;
import static com.facebook.react.bridge.ReactMarkerConstants.GET_CONSTANTS_START;
import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE;
-/**
- * This is part of the glue which wraps a java BaseJavaModule in a C++
- * NativeModule. This could all be in C++, but it's android-specific
- * initialization code, and writing it this way is easier to read and means
- * fewer JNI calls.
- */
+import com.facebook.proguard.annotations.DoNotStrip;
+import com.facebook.systrace.Systrace;
+import com.facebook.systrace.SystraceMessage;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.annotation.Nullable;
+/**
+ * This is part of the glue which wraps a java BaseJavaModule in a C++ NativeModule. This could all
+ * be in C++, but it's android-specific initialization code, and writing it this way is easier to
+ * read and means fewer JNI calls.
+ */
@DoNotStrip
public class JavaModuleWrapper {
@DoNotStrip
public class MethodDescriptor {
- @DoNotStrip
- Method method;
- @DoNotStrip
- String signature;
- @DoNotStrip
- String name;
- @DoNotStrip
- String type;
+ @DoNotStrip Method method;
+ @DoNotStrip String signature;
+ @DoNotStrip String name;
+ @DoNotStrip String type;
}
private final JSInstance mJSInstance;
@@ -93,10 +84,11 @@ public class JavaModuleWrapper {
// We do not support method overloading since js sees a function as an object regardless
// of number of params.
throw new IllegalArgumentException(
- "Java Module " + getName() + " method name already registered: " + methodName);
+ "Java Module " + getName() + " method name already registered: " + methodName);
}
MethodDescriptor md = new MethodDescriptor();
- JavaMethodWrapper method = new JavaMethodWrapper(this, targetMethod, annotation.isBlockingSynchronousMethod());
+ JavaMethodWrapper method =
+ new JavaMethodWrapper(this, targetMethod, annotation.isBlockingSynchronousMethod());
md.name = methodName;
md.type = method.getType();
if (md.type == BaseJavaModule.METHOD_TYPE_SYNC) {
@@ -126,8 +118,8 @@ public class JavaModuleWrapper {
final String moduleName = getName();
SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "JavaModuleWrapper.getConstants")
- .arg("moduleName", moduleName)
- .flush();
+ .arg("moduleName", moduleName)
+ .flush();
ReactMarker.logMarker(GET_CONSTANTS_START, moduleName);
BaseJavaModule baseJavaModule = getModule();
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaOnlyArray.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaOnlyArray.java
index 1b3774d7f87..fcc022220e4 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaOnlyArray.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaOnlyArray.java
@@ -1,29 +1,27 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* Java {@link ArrayList} backed implementation of {@link ReadableArray} and {@link WritableArray}
* Instances of this class SHOULD NOT be used for communication between java and JS, use instances
- * of {@link WritableNativeArray} created via {@link Arguments#createArray} or just
- * {@link ReadableArray} interface if you want your "native" module method to take an array from JS
- * as an argument.
+ * of {@link WritableNativeArray} created via {@link Arguments#createArray} or just {@link
+ * ReadableArray} interface if you want your "native" module method to take an array from JS as an
+ * argument.
*
- * Main purpose for this class is to be used in java-only unit tests, but could also be used outside
- * of tests in the code that operates only in java and needs to communicate with RN modules via
- * their JS-exposed API.
+ * Main purpose for this class is to be used in java-only unit tests, but could also be used
+ * outside of tests in the code that operates only in java and needs to communicate with RN modules
+ * via their JS-exposed API.
*/
public class JavaOnlyArray implements ReadableArray, WritableArray {
@@ -130,9 +128,7 @@ public class JavaOnlyArray implements ReadableArray, WritableArray {
return ReadableType.Null;
} else if (object instanceof Boolean) {
return ReadableType.Boolean;
- } else if (object instanceof Double ||
- object instanceof Float ||
- object instanceof Integer) {
+ } else if (object instanceof Double || object instanceof Float || object instanceof Integer) {
return ReadableType.Number;
} else if (object instanceof String) {
return ReadableType.String;
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaOnlyMap.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaOnlyMap.java
index ddf450f814c..6ce959b9a3b 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaOnlyMap.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaOnlyMap.java
@@ -9,7 +9,6 @@ package com.facebook.react.bridge;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
-
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -71,7 +70,7 @@ public class JavaOnlyMap implements ReadableMap, WritableMap {
Object val = keysAndValues[i + 1];
if (val instanceof Number) {
// all values from JS are doubles, so emulate that here for tests.
- val = ((Number)val).doubleValue();
+ val = ((Number) val).doubleValue();
}
mBackingMap.put(keysAndValues[i], val);
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaScriptContextHolder.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaScriptContextHolder.java
index 13c767afc6c..20e0a907a1e 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaScriptContextHolder.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaScriptContextHolder.java
@@ -9,8 +9,8 @@ import javax.annotation.concurrent.GuardedBy;
/**
* Wrapper for JavaScriptContext native pointer. CatalystInstanceImpl creates this on demand, and
- * will call clear() before destroying the VM. People who need the raw JavaScriptContext pointer
- * can synchronize on this wrapper object to guarantee that it will not be destroyed.
+ * will call clear() before destroying the VM. People who need the raw JavaScriptContext pointer can
+ * synchronize on this wrapper object to guarantee that it will not be destroyed.
*/
public class JavaScriptContextHolder {
@GuardedBy("this")
@@ -28,5 +28,4 @@ public class JavaScriptContextHolder {
public synchronized void clear() {
mContext = 0;
}
-
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaScriptExecutor.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaScriptExecutor.java
index 4333cfbbda7..70e4e7e75fd 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaScriptExecutor.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaScriptExecutor.java
@@ -1,10 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
import com.facebook.jni.HybridData;
@@ -19,16 +18,13 @@ public abstract class JavaScriptExecutor {
}
/**
- * Close this executor and cleanup any resources that it was using. No further calls are
- * expected after this.
- * TODO mhorowitz: This may no longer be used; check and delete if possible.
+ * Close this executor and cleanup any resources that it was using. No further calls are expected
+ * after this. TODO mhorowitz: This may no longer be used; check and delete if possible.
*/
public void close() {
mHybridData.resetNative();
}
- /**
- * Returns the name of the executor, identifying the underlying runtime.
- */
- abstract public String getName();
+ /** Returns the name of the executor, identifying the underlying runtime. */
+ public abstract String getName();
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaScriptExecutorFactory.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaScriptExecutorFactory.java
index 1530755ca58..6aee7949a71 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaScriptExecutorFactory.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaScriptExecutorFactory.java
@@ -1,10 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
public interface JavaScriptExecutorFactory {
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaScriptModule.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaScriptModule.java
index e3b5f568135..895f8de45f9 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaScriptModule.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaScriptModule.java
@@ -1,10 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
import com.facebook.proguard.annotations.DoNotStrip;
@@ -13,15 +12,13 @@ import com.facebook.proguard.annotations.DoNotStrip;
* Interface denoting that a class is the interface to a module with the same name in JS. Calling
* functions on this interface will result in corresponding methods in JS being called.
*
- * When extending JavaScriptModule and registering it with a CatalystInstance, all public methods
- * are assumed to be implemented on a JS module with the same name as this class. Calling methods
- * on the object returned from {@link ReactContext#getJSModule} or
- * {@link CatalystInstance#getJSModule} will result in the methods with those names exported by
- * that module being called in JS.
+ * When extending JavaScriptModule and registering it with a CatalystInstance, all public methods
+ * are assumed to be implemented on a JS module with the same name as this class. Calling methods on
+ * the object returned from {@link ReactContext#getJSModule} or {@link CatalystInstance#getJSModule}
+ * will result in the methods with those names exported by that module being called in JS.
*
- * NB: JavaScriptModule does not allow method name overloading because JS does not allow method name
- * overloading.
+ * NB: JavaScriptModule does not allow method name overloading because JS does not allow method
+ * name overloading.
*/
@DoNotStrip
-public interface JavaScriptModule {
-}
+public interface JavaScriptModule {}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaScriptModuleRegistry.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaScriptModuleRegistry.java
index 5bb25881ca4..4d03060cf51 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaScriptModuleRegistry.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaScriptModuleRegistry.java
@@ -1,27 +1,24 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
-import javax.annotation.Nullable;
-
+import com.facebook.react.common.build.ReactBuildConfig;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
-
-import com.facebook.react.common.build.ReactBuildConfig;
+import javax.annotation.Nullable;
/**
- * Class responsible for holding all the {@link JavaScriptModule}s. Uses Java proxy objects
- * to dispatch method calls on JavaScriptModules to the bridge using the corresponding
- * module and method ids so the proper function is executed in JavaScript.
+ * Class responsible for holding all the {@link JavaScriptModule}s. Uses Java proxy objects to
+ * dispatch method calls on JavaScriptModules to the bridge using the corresponding module and
+ * method ids so the proper function is executed in JavaScript.
*/
public final class JavaScriptModuleRegistry {
private final HashMap This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
import java.io.Closeable;
@@ -13,9 +12,7 @@ import java.io.Writer;
import java.util.ArrayDeque;
import java.util.Deque;
-/**
- * Simple Json generator that does no validation.
- */
+/** Simple Json generator that does no validation. */
public class JsonWriter implements Closeable {
private final Writer mWriter;
private final Deque This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
import java.io.IOException;
import java.util.List;
import java.util.Map;
-/**
- * Helper for generating JSON for lists and maps.
- */
+/** Helper for generating JSON for lists and maps. */
class JsonWriterHelper {
public static void value(JsonWriter writer, Object value) throws IOException {
if (value instanceof Map) {
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/LifecycleEventListener.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/LifecycleEventListener.java
index 908e13db416..32c4b015546 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/LifecycleEventListener.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/LifecycleEventListener.java
@@ -1,28 +1,25 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
/**
* Listener for receiving activity lifecycle events.
*
- * When multiple activities share a react instance, only the most recent one's lifecycle events get
- * forwarded to listeners. Consider the following scenarios:
+ * When multiple activities share a react instance, only the most recent one's lifecycle events
+ * get forwarded to listeners. Consider the following scenarios:
*
- * 1. Navigating from Activity A to B will trigger two events: A#onHostPause and B#onHostResume. Any
- * subsequent lifecycle events coming from Activity A, such as onHostDestroy, will be ignored.
+ * 1. Navigating from Activity A to B will trigger two events: A#onHostPause and B#onHostResume.
+ * Any subsequent lifecycle events coming from Activity A, such as onHostDestroy, will be ignored.
* 2. Navigating back from Activity B to Activity A will trigger the same events: B#onHostPause and
- * A#onHostResume. Any subsequent events coming from Activity B, such as onHostDestroy, are
- * ignored.
+ * A#onHostResume. Any subsequent events coming from Activity B, such as onHostDestroy, are ignored.
* 3. Navigating back from Activity A to a non-React Activity or to the home screen will trigger two
- * events: onHostPause and onHostDestroy.
- * 4. Navigating from Activity A to a non-React Activity B will trigger one event: onHostPause.
- * Later, if Activity A is destroyed (e.g. because of resource contention), onHostDestroy is
- * triggered.
+ * events: onHostPause and onHostDestroy. 4. Navigating from Activity A to a non-React Activity B
+ * will trigger one event: onHostPause. Later, if Activity A is destroyed (e.g. because of resource
+ * contention), onHostDestroy is triggered.
*/
public interface LifecycleEventListener {
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/MemoryPressureListener.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/MemoryPressureListener.java
index 972f17aa397..ac7ea034dcc 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/MemoryPressureListener.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/MemoryPressureListener.java
@@ -5,14 +5,9 @@
package com.facebook.react.bridge;
-/**
- * Listener interface for memory pressure events.
- */
+/** Listener interface for memory pressure events. */
public interface MemoryPressureListener {
- /**
- * Called when the system generates a memory warning.
- */
+ /** Called when the system generates a memory warning. */
void handleMemoryPressure(int level);
-
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/ModuleHolder.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/ModuleHolder.java
index e1299d525ae..f36bf258fe0 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/ModuleHolder.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ModuleHolder.java
@@ -70,8 +70,7 @@ public class ModuleHolder {
true,
true,
CxxModuleWrapper.class.isAssignableFrom(nativeModule.getClass()),
- TurboModule.class.isAssignableFrom(nativeModule.getClass())
- );
+ TurboModule.class.isAssignableFrom(nativeModule.getClass()));
mModule = nativeModule;
PrinterHolder.getPrinter()
@@ -199,7 +198,7 @@ public class ModuleHolder {
doInitialize(module);
}
} finally {
- ReactMarker.logMarker(CREATE_MODULE_END, mName ,mInstanceKey);
+ ReactMarker.logMarker(CREATE_MODULE_END, mName, mInstanceKey);
SystraceMessage.endSection(TRACE_TAG_REACT_JAVA_BRIDGE).flush();
}
return module;
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeArgumentsParseException.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeArgumentsParseException.java
index 3dd3617293e..b292b669de6 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeArgumentsParseException.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeArgumentsParseException.java
@@ -1,17 +1,14 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
import javax.annotation.Nullable;
-/**
- * Exception thrown when a native module method call receives unexpected arguments from JS.
- */
+/** Exception thrown when a native module method call receives unexpected arguments from JS. */
public class NativeArgumentsParseException extends JSApplicationCausedNativeException {
public NativeArgumentsParseException(String detailMessage) {
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeArray.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeArray.java
index 9ae9251f23e..101c6b99fa3 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeArray.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeArray.java
@@ -1,20 +1,17 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
import com.facebook.jni.HybridData;
import com.facebook.proguard.annotations.DoNotStrip;
-/**
- * Base class for an array whose members are stored in native code (C++).
- */
+/** Base class for an array whose members are stored in native code (C++). */
@DoNotStrip
-public abstract class NativeArray implements NativeArrayInterface{
+public abstract class NativeArray implements NativeArrayInterface {
static {
ReactBridge.staticInit();
}
@@ -26,6 +23,5 @@ public abstract class NativeArray implements NativeArrayInterface{
@Override
public native String toString();
- @DoNotStrip
- private HybridData mHybridData;
+ @DoNotStrip private HybridData mHybridData;
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeArrayInterface.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeArrayInterface.java
index 989208814f2..c31bde01d8a 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeArrayInterface.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeArrayInterface.java
@@ -1,10 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
public interface NativeArrayInterface {
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeDeltaClient.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeDeltaClient.java
index 97eb4337284..39ebf53b636 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeDeltaClient.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeDeltaClient.java
@@ -1,15 +1,13 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
-import java.nio.channels.ReadableByteChannel;
-
import com.facebook.jni.HybridData;
+import java.nio.channels.ReadableByteChannel;
public class NativeDeltaClient {
static {
@@ -18,8 +16,10 @@ public class NativeDeltaClient {
// C++ parts
private final HybridData mHybridData = initHybrid();
- private native static HybridData initHybrid();
+
+ private static native HybridData initHybrid();
public native void reset();
+
public native void processDelta(ReadableByteChannel deltaMessage);
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeMap.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeMap.java
index d1dbf145ef1..731638105ec 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeMap.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeMap.java
@@ -1,18 +1,15 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
import com.facebook.jni.HybridData;
import com.facebook.proguard.annotations.DoNotStrip;
-/**
- * Base class for a Map whose keys and values are stored in native code (C++).
- */
+/** Base class for a Map whose keys and values are stored in native code (C++). */
@DoNotStrip
public abstract class NativeMap {
static {
@@ -26,6 +23,5 @@ public abstract class NativeMap {
@Override
public native String toString();
- @DoNotStrip
- private HybridData mHybridData;
+ @DoNotStrip private HybridData mHybridData;
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeModule.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeModule.java
index 14224ca10a2..8d0b6251a0d 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeModule.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeModule.java
@@ -1,41 +1,40 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
import com.facebook.proguard.annotations.DoNotStrip;
-
import javax.annotation.Nonnull;
-
/**
- * A native module whose API can be provided to JS catalyst instances. {@link NativeModule}s whose
+ * A native module whose API can be provided to JS catalyst instances. {@link NativeModule}s whose
* implementation is written in Java should extend {@link BaseJavaModule} or {@link
- * ReactContextBaseJavaModule}. {@link NativeModule}s whose implementation is written in C++
- * must not provide any Java code (so they can be reused on other platforms), and instead should
- * register themselves using {@link CxxModuleWrapper}.
+ * ReactContextBaseJavaModule}. {@link NativeModule}s whose implementation is written in C++ must
+ * not provide any Java code (so they can be reused on other platforms), and instead should register
+ * themselves using {@link CxxModuleWrapper}.
*/
@DoNotStrip
public interface NativeModule {
interface NativeMethod {
void invoke(JSInstance jsInstance, ReadableArray parameters);
+
String getType();
}
/**
* @return the name of this module. This will be the name used to {@code require()} this module
- * from javascript.
+ * from javascript.
*/
- @Nonnull String getName();
+ @Nonnull
+ String getName();
/**
- * This is called at the end of {@link CatalystApplicationFragment#createCatalystInstance()}
- * after the CatalystInstance has been created, in order to initialize NativeModules that require
- * the CatalystInstance or JS modules.
+ * This is called at the end of {@link CatalystApplicationFragment#createCatalystInstance()} after
+ * the CatalystInstance has been created, in order to initialize NativeModules that require the
+ * CatalystInstance or JS modules.
*/
void initialize();
@@ -47,8 +46,6 @@ public interface NativeModule {
*/
boolean canOverrideExistingModule();
- /**
- * Called before {CatalystInstance#onHostDestroy}
- */
+ /** Called before {CatalystInstance#onHostDestroy} */
void onCatalystInstanceDestroy();
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeModuleCallExceptionHandler.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeModuleCallExceptionHandler.java
index ada610f1f06..d9b31a59673 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeModuleCallExceptionHandler.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeModuleCallExceptionHandler.java
@@ -1,26 +1,22 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
/**
* Interface for a class that knows how to handle an Exception thrown by a native module invoked
- * from JS. Since these Exceptions are triggered by JS calls (and can be fixed in JS), a
- * common way to handle one is to show a error dialog and allow the developer to change and reload
- * JS.
+ * from JS. Since these Exceptions are triggered by JS calls (and can be fixed in JS), a common way
+ * to handle one is to show a error dialog and allow the developer to change and reload JS.
*
- * We should also note that we have a unique stance on what 'caused' means: even if there's a bug in
- * the framework/native code, it was triggered by JS and theoretically since we were able to set up
- * the bridge, JS could change its logic, reload, and not trigger that crash.
+ * We should also note that we have a unique stance on what 'caused' means: even if there's a bug
+ * in the framework/native code, it was triggered by JS and theoretically since we were able to set
+ * up the bridge, JS could change its logic, reload, and not trigger that crash.
*/
public interface NativeModuleCallExceptionHandler {
- /**
- * Do something to display or log the exception.
- */
+ /** Do something to display or log the exception. */
void handleException(Exception e);
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeModuleRegistry.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeModuleRegistry.java
index 126e7fb7576..8c82e88e615 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeModuleRegistry.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeModuleRegistry.java
@@ -144,8 +144,8 @@ public class NativeModuleRegistry {
}
public NativeModule getModule(String name) {
- return Assertions.assertNotNull(
- mModules.get(name), "Could not find module with name " + name).getModule();
+ return Assertions.assertNotNull(mModules.get(name), "Could not find module with name " + name)
+ .getModule();
}
public List This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
import com.facebook.proguard.annotations.DoNotStrip;
-/**
- * Exception thrown by {@link ReadableNativeMap} when a key that does not exist is requested.
- */
+/** Exception thrown by {@link ReadableNativeMap} when a key that does not exist is requested. */
@DoNotStrip
public class NoSuchKeyException extends RuntimeException {
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/NotThreadSafeBridgeIdleDebugListener.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/NotThreadSafeBridgeIdleDebugListener.java
index 680702561a5..da854c76092 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/NotThreadSafeBridgeIdleDebugListener.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/NotThreadSafeBridgeIdleDebugListener.java
@@ -1,36 +1,32 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
/**
* Interface for receiving notification for bridge idle/busy events. Should not affect application
- * logic and should only be used for debug/monitoring/testing purposes. Call
- * {@link CatalystInstance#addBridgeIdleDebugListener} to start monitoring.
+ * logic and should only be used for debug/monitoring/testing purposes. Call {@link
+ * CatalystInstance#addBridgeIdleDebugListener} to start monitoring.
*
- * NB: onTransitionToBridgeIdle and onTransitionToBridgeBusy may be called from different threads,
- * and those threads may not be the same thread on which the listener was originally registered.
+ * NB: onTransitionToBridgeIdle and onTransitionToBridgeBusy may be called from different
+ * threads, and those threads may not be the same thread on which the listener was originally
+ * registered.
*/
public interface NotThreadSafeBridgeIdleDebugListener {
/**
* Called once all pending JS calls have resolved via an onBatchComplete call in the bridge and
- * the requested native module calls have also run. The bridge will not become busy again until
- * a timer, touch event, etc. causes a Java->JS call to be enqueued again.
+ * the requested native module calls have also run. The bridge will not become busy again until a
+ * timer, touch event, etc. causes a Java->JS call to be enqueued again.
*/
void onTransitionToBridgeIdle();
- /**
- * Called when the bridge was in an idle state and executes a JS call or callback.
- */
+ /** Called when the bridge was in an idle state and executes a JS call or callback. */
void onTransitionToBridgeBusy();
- /**
- * Called when the bridge is destroyed
- */
+ /** Called when the bridge is destroyed */
void onBridgeDestroyed();
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/ObjectAlreadyConsumedException.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/ObjectAlreadyConsumedException.java
index 720cc2ac9fe..d83f579c6d5 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/ObjectAlreadyConsumedException.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ObjectAlreadyConsumedException.java
@@ -1,18 +1,17 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
import com.facebook.proguard.annotations.DoNotStrip;
/**
- * Exception thrown when a caller attempts to modify or use a {@link WritableNativeArray} or
- * {@link WritableNativeMap} after it has already been added to a parent array or map. This is
- * unsafe since we reuse the native memory so the underlying array/map is no longer valid.
+ * Exception thrown when a caller attempts to modify or use a {@link WritableNativeArray} or {@link
+ * WritableNativeMap} after it has already been added to a parent array or map. This is unsafe since
+ * we reuse the native memory so the underlying array/map is no longer valid.
*/
@DoNotStrip
public class ObjectAlreadyConsumedException extends RuntimeException {
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/OnBatchCompleteListener.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/OnBatchCompleteListener.java
index e785ab843e0..52e726bb5fc 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/OnBatchCompleteListener.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/OnBatchCompleteListener.java
@@ -1,15 +1,12 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
-/**
- * Interface for a module that will be notified when a batch of JS->Java calls has finished.
- */
+/** Interface for a module that will be notified when a batch of JS->Java calls has finished. */
public interface OnBatchCompleteListener {
void onBatchComplete();
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/PerformanceCounter.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/PerformanceCounter.java
index 645851c9316..e34889635d8 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/PerformanceCounter.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/PerformanceCounter.java
@@ -1,8 +1,8 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
package com.facebook.react.bridge;
@@ -13,5 +13,4 @@ public interface PerformanceCounter {
void profileNextBatch();
Map This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
import javax.annotation.Nonnull;
@@ -29,7 +28,7 @@ public interface Promise {
/**
* Report an error without an exception using a custom code and error message.
*
- * @param code String
+ * @param code String
* @param message String
*/
void reject(String code, String message);
@@ -37,7 +36,7 @@ public interface Promise {
/**
* Report an exception with a custom code.
*
- * @param code String
+ * @param code String
* @param throwable Throwable
*/
void reject(String code, Throwable throwable);
@@ -45,16 +44,15 @@ public interface Promise {
/**
* Report an exception with a custom code and error message.
*
- * @param code String
- * @param message String
+ * @param code String
+ * @param message String
* @param throwable Throwable
*/
void reject(String code, String message, Throwable throwable);
-
/**
- * Report an exception, with default error code.
- * Useful in catch-all scenarios where it's unclear why the error occurred.
+ * Report an exception, with default error code. Useful in catch-all scenarios where it's unclear
+ * why the error occurred.
*
* @param throwable Throwable
*/
@@ -65,18 +63,18 @@ public interface Promise {
* --------------------------- */
/**
- * Report an exception, with default error code, with userInfo.
- * Useful in catch-all scenarios where it's unclear why the error occurred.
+ * Report an exception, with default error code, with userInfo. Useful in catch-all scenarios
+ * where it's unclear why the error occurred.
*
* @param throwable Throwable
- * @param userInfo WritableMap
+ * @param userInfo WritableMap
*/
void reject(Throwable throwable, WritableMap userInfo);
/**
* Reject with a code and userInfo WritableMap.
*
- * @param code String
+ * @param code String
* @param userInfo WritableMap
*/
void reject(String code, @Nonnull WritableMap userInfo);
@@ -84,18 +82,18 @@ public interface Promise {
/**
* Report an exception with a custom code and userInfo.
*
- * @param code String
+ * @param code String
* @param throwable Throwable
- * @param userInfo WritableMap
+ * @param userInfo WritableMap
*/
void reject(String code, Throwable throwable, WritableMap userInfo);
/**
- * Report an error with a custom code, error message and userInfo,
- * an error not caused by an exception.
+ * Report an error with a custom code, error message and userInfo, an error not caused by an
+ * exception.
*
- * @param code String
- * @param message String
+ * @param code String
+ * @param message String
* @param userInfo WritableMap
*/
void reject(String code, String message, @Nonnull WritableMap userInfo);
@@ -103,10 +101,10 @@ public interface Promise {
/**
* Report an exception with a custom code, error message and userInfo.
*
- * @param code String
- * @param message String
+ * @param code String
+ * @param message String
* @param throwable Throwable
- * @param userInfo WritableMap
+ * @param userInfo WritableMap
*/
void reject(String code, String message, Throwable throwable, WritableMap userInfo);
@@ -117,8 +115,8 @@ public interface Promise {
/**
* Report an error which wasn't caused by an exception.
*
- * @deprecated Prefer passing a module-specific error code to JS.
- * Using this method will pass the error code "EUNSPECIFIED".
+ * @deprecated Prefer passing a module-specific error code to JS. Using this method will pass the
+ * error code "EUNSPECIFIED".
*/
@Deprecated
void reject(String message);
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/PromiseImpl.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/PromiseImpl.java
index fb3cceaa644..ccc1204bc27 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/PromiseImpl.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/PromiseImpl.java
@@ -1,10 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
import javax.annotation.Nonnull;
@@ -37,10 +36,8 @@ public class PromiseImpl implements Promise {
private static final String STACK_FRAME_KEY_LINE_NUMBER = "lineNumber";
private static final String STACK_FRAME_KEY_METHOD_NAME = "methodName";
- private @Nullable
- Callback mResolve;
- private @Nullable
- Callback mReject;
+ private @Nullable Callback mResolve;
+ private @Nullable Callback mReject;
public PromiseImpl(@Nullable Callback resolve, @Nullable Callback reject) {
mResolve = resolve;
@@ -64,46 +61,46 @@ public class PromiseImpl implements Promise {
/**
* Report an error without an exception using a custom code and error message.
*
- * @param code String
+ * @param code String
* @param message String
*/
@Override
public void reject(String code, String message) {
- reject(code, message, /*Throwable*/null, /*WritableMap*/null);
+ reject(code, message, /*Throwable*/ null, /*WritableMap*/ null);
}
/**
* Report an exception with a custom code.
*
- * @param code String
+ * @param code String
* @param throwable Throwable
*/
@Override
public void reject(String code, Throwable throwable) {
- reject(code, /*Message*/null, throwable, /*WritableMap*/null);
+ reject(code, /*Message*/ null, throwable, /*WritableMap*/ null);
}
/**
* Report an exception with a custom code and error message.
*
- * @param code String
- * @param message String
+ * @param code String
+ * @param message String
* @param throwable Throwable
*/
@Override
public void reject(String code, String message, Throwable throwable) {
- reject(code, message, throwable, /*WritableMap*/null);
+ reject(code, message, throwable, /*WritableMap*/ null);
}
/**
- * Report an exception, with default error code.
- * Useful in catch-all scenarios where it's unclear why the error occurred.
+ * Report an exception, with default error code. Useful in catch-all scenarios where it's unclear
+ * why the error occurred.
*
* @param throwable Throwable
*/
@Override
public void reject(Throwable throwable) {
- reject(/*Code*/null, /*Message*/null, throwable, /*WritableMap*/null);
+ reject(/*Code*/ null, /*Message*/ null, throwable, /*WritableMap*/ null);
}
/* ---------------------------
@@ -111,68 +108,67 @@ public class PromiseImpl implements Promise {
* --------------------------- */
/**
- * Report an exception, with default error code, with userInfo.
- * Useful in catch-all scenarios where it's unclear why the error occurred.
+ * Report an exception, with default error code, with userInfo. Useful in catch-all scenarios
+ * where it's unclear why the error occurred.
*
* @param throwable Throwable
- * @param userInfo WritableMap
+ * @param userInfo WritableMap
*/
@Override
public void reject(Throwable throwable, WritableMap userInfo) {
- reject(/*Code*/null, /*Message*/null, throwable, userInfo);
+ reject(/*Code*/ null, /*Message*/ null, throwable, userInfo);
}
/**
* Reject with a code and userInfo WritableMap.
*
- * @param code String
+ * @param code String
* @param userInfo WritableMap
*/
@Override
public void reject(String code, @Nonnull WritableMap userInfo) {
- reject(code, /*Message*/null, /*Throwable*/null, userInfo);
+ reject(code, /*Message*/ null, /*Throwable*/ null, userInfo);
}
/**
* Report an exception with a custom code and userInfo.
*
- * @param code String
+ * @param code String
* @param throwable Throwable
- * @param userInfo WritableMap
+ * @param userInfo WritableMap
*/
@Override
public void reject(String code, Throwable throwable, WritableMap userInfo) {
- reject(code, /*Message*/null, throwable, userInfo);
+ reject(code, /*Message*/ null, throwable, userInfo);
}
/**
- * Report an error with a custom code, error message and userInfo,
- * an error not caused by an exception.
+ * Report an error with a custom code, error message and userInfo, an error not caused by an
+ * exception.
*
- * @param code String
- * @param message String
+ * @param code String
+ * @param message String
* @param userInfo WritableMap
*/
@Override
public void reject(String code, String message, @Nonnull WritableMap userInfo) {
- reject(code, message, /*Throwable*/null, userInfo);
+ reject(code, message, /*Throwable*/ null, userInfo);
}
/**
* Report an exception with a custom code, error message and userInfo.
*
- * @param code String
- * @param message String
+ * @param code String
+ * @param message String
* @param throwable Throwable
- * @param userInfo WritableMap
+ * @param userInfo WritableMap
*/
@Override
public void reject(
@Nullable String code,
@Nullable String message,
@Nullable Throwable throwable,
- @Nullable WritableMap userInfo
- ) {
+ @Nullable WritableMap userInfo) {
if (mReject == null) {
mResolve = null;
return;
@@ -243,6 +239,6 @@ public class PromiseImpl implements Promise {
@Override
@Deprecated
public void reject(String message) {
- reject(/*Code*/null, message, /*Throwable*/null, /*WritableMap*/null);
+ reject(/*Code*/ null, message, /*Throwable*/ null, /*WritableMap*/ null);
}
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/ProxyJavaScriptExecutor.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/ProxyJavaScriptExecutor.java
index ea5d126f799..7a556096937 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/ProxyJavaScriptExecutor.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ProxyJavaScriptExecutor.java
@@ -1,10 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
import com.facebook.jni.HybridData;
@@ -12,12 +11,12 @@ import com.facebook.proguard.annotations.DoNotStrip;
import javax.annotation.Nullable;
/**
- * JavaScript executor that delegates JS calls processed by native code back to a java version
- * of the native executor interface.
+ * JavaScript executor that delegates JS calls processed by native code back to a java version of
+ * the native executor interface.
*
- * When set as a executor with {@link CatalystInstance.Builder}, catalyst native code will delegate
- * low level javascript calls to the implementation of {@link JavaJSExecutor} interface provided
- * with the constructor of this class.
+ * When set as a executor with {@link CatalystInstance.Builder}, catalyst native code will
+ * delegate low level javascript calls to the implementation of {@link JavaJSExecutor} interface
+ * provided with the constructor of this class.
*/
@DoNotStrip
public class ProxyJavaScriptExecutor extends JavaScriptExecutor {
@@ -42,8 +41,9 @@ public class ProxyJavaScriptExecutor extends JavaScriptExecutor {
/**
* Create {@link ProxyJavaScriptExecutor} instance
+ *
* @param executor implementation of {@link JavaJSExecutor} which will be responsible for handling
- * javascript calls
+ * javascript calls
*/
public ProxyJavaScriptExecutor(JavaJSExecutor executor) {
super(initHybrid(executor));
@@ -63,5 +63,5 @@ public class ProxyJavaScriptExecutor extends JavaScriptExecutor {
return "ProxyJavaScriptExecutor";
}
- private native static HybridData initHybrid(JavaJSExecutor executor);
+ private static native HybridData initHybrid(JavaJSExecutor executor);
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactApplicationContext.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactApplicationContext.java
index f94c2382751..245f8c21b9d 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactApplicationContext.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactApplicationContext.java
@@ -1,17 +1,16 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
import android.content.Context;
/**
- * A context wrapper that always wraps Android Application {@link Context} and
- * {@link CatalystInstance} by extending {@link ReactContext}
+ * A context wrapper that always wraps Android Application {@link Context} and {@link
+ * CatalystInstance} by extending {@link ReactContext}
*/
public class ReactApplicationContext extends ReactContext {
// We want to wrap ApplicationContext, since there is no easy way to verify that application
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactBridge.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactBridge.java
index db7edacb75a..36acb022167 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactBridge.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactBridge.java
@@ -1,10 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE;
@@ -19,14 +18,15 @@ public class ReactBridge {
private static boolean sDidInit = false;
- public synchronized static void staticInit() {
+ public static synchronized void staticInit() {
if (sDidInit) {
return;
}
sDidInit = true;
sLoadStartTime = SystemClock.uptimeMillis();
- Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "ReactBridge.staticInit::load:reactnativejni");
+ Systrace.beginSection(
+ TRACE_TAG_REACT_JAVA_BRIDGE, "ReactBridge.staticInit::load:reactnativejni");
ReactMarker.logMarker(ReactMarkerConstants.LOAD_REACT_NATIVE_SO_FILE_START);
SoLoader.loadLibrary("reactnativejni");
ReactMarker.logMarker(ReactMarkerConstants.LOAD_REACT_NATIVE_SO_FILE_END);
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactCallback.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactCallback.java
index bc690b52a7e..8ddc0a95be2 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactCallback.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactCallback.java
@@ -1,10 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
import com.facebook.proguard.annotations.DoNotStrip;
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java
index c2e74c0b897..eaed58cdb3c 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java
@@ -1,10 +1,9 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
import android.app.Activity;
@@ -22,22 +21,22 @@ import java.util.concurrent.CopyOnWriteArraySet;
import javax.annotation.Nullable;
/**
- * Abstract ContextWrapper for Android application or activity {@link Context} and
- * {@link CatalystInstance}
+ * Abstract ContextWrapper for Android application or activity {@link Context} and {@link
+ * CatalystInstance}
*/
public class ReactContext extends ContextWrapper {
private static final String EARLY_JS_ACCESS_EXCEPTION_MESSAGE =
- "Tried to access a JS module before the React instance was fully set up. Calls to " +
- "ReactContext#getJSModule should only happen once initialize() has been called on your " +
- "native module.";
+ "Tried to access a JS module before the React instance was fully set up. Calls to "
+ + "ReactContext#getJSModule should only happen once initialize() has been called on your "
+ + "native module.";
private final CopyOnWriteArraySet This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
+import android.app.Activity;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import android.app.Activity;
-
/**
- * Base class for Catalyst native modules that require access to the {@link ReactContext}
- * instance.
+ * Base class for Catalyst native modules that require access to the {@link ReactContext} instance.
*/
public abstract class ReactContextBaseJavaModule extends BaseJavaModule {
@@ -24,9 +21,7 @@ public abstract class ReactContextBaseJavaModule extends BaseJavaModule {
mReactApplicationContext = reactContext;
}
- /**
- * Subclasses can use this method to access catalyst context passed as a constructor
- */
+ /** Subclasses can use this method to access catalyst context passed as a constructor */
protected final ReactApplicationContext getReactApplicationContext() {
return mReactApplicationContext;
}
@@ -34,11 +29,12 @@ public abstract class ReactContextBaseJavaModule extends BaseJavaModule {
/**
* Get the activity to which this context is currently attached, or {@code null} if not attached.
*
- * DO NOT HOLD LONG-LIVED REFERENCES TO THE OBJECT RETURNED BY THIS METHOD, AS THIS WILL CAUSE
+ * DO NOT HOLD LONG-LIVED REFERENCES TO THE OBJECT RETURNED BY THIS METHOD, AS THIS WILL CAUSE
* MEMORY LEAKS.
*
- * For example, never store the value returned by this method in a member variable. Instead, call
- * this method whenever you actually need the Activity and make sure to check for {@code null}.
+ * For example, never store the value returned by this method in a member variable. Instead,
+ * call this method whenever you actually need the Activity and make sure to check for {@code
+ * null}.
*/
protected @Nullable final Activity getCurrentActivity() {
return mReactApplicationContext.getCurrentActivity();
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactMarker.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactMarker.java
index d3f3e9f2250..9e444140e75 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactMarker.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactMarker.java
@@ -5,16 +5,14 @@
package com.facebook.react.bridge;
-import java.util.List;
+import com.facebook.proguard.annotations.DoNotStrip;
import java.util.ArrayList;
-
+import java.util.List;
import javax.annotation.Nullable;
-import com.facebook.proguard.annotations.DoNotStrip;
-
/**
- * Static class that allows markers to be placed in React code and responded to in a
- * configurable way
+ * Static class that allows markers to be placed in React code and responded to in a configurable
+ * way
*/
@DoNotStrip
public class ReactMarker {
@@ -30,7 +28,7 @@ public class ReactMarker {
@DoNotStrip
public static void addListener(MarkerListener listener) {
- synchronized(sListeners) {
+ synchronized (sListeners) {
if (!sListeners.contains(listener)) {
sListeners.add(listener);
}
@@ -39,14 +37,14 @@ public class ReactMarker {
@DoNotStrip
public static void removeListener(MarkerListener listener) {
- synchronized(sListeners) {
+ synchronized (sListeners) {
sListeners.remove(listener);
}
}
@DoNotStrip
public static void clearMarkerListeners() {
- synchronized(sListeners) {
+ synchronized (sListeners) {
sListeners.clear();
}
}
@@ -89,7 +87,7 @@ public class ReactMarker {
@DoNotStrip
public static void logMarker(ReactMarkerConstants name, @Nullable String tag, int instanceKey) {
- synchronized(sListeners) {
+ synchronized (sListeners) {
for (MarkerListener listener : sListeners) {
listener.logMarker(name, tag, instanceKey);
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactMarkerConstants.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactMarkerConstants.java
index b8292828803..89193a392e3 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactMarkerConstants.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactMarkerConstants.java
@@ -5,9 +5,7 @@
package com.facebook.react.bridge;
-/**
- * Constants used by ReactMarker.
- */
+/** Constants used by ReactMarker. */
public enum ReactMarkerConstants {
CREATE_REACT_CONTEXT_START,
CREATE_REACT_CONTEXT_END,
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactMethod.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactMethod.java
index 2f52f534db9..b51a5196caa 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactMethod.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactMethod.java
@@ -1,39 +1,37 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
-import java.lang.annotation.Retention;
-
import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Retention;
+
/**
* Annotation which is used to mark methods that are exposed to React Native.
*
- * This applies to derived classes of {@link BaseJavaModule}, which will generate a list
- * of exported methods by searching for those which are annotated with this annotation
- * and adding a JS callback for each.
+ * This applies to derived classes of {@link BaseJavaModule}, which will generate a list of
+ * exported methods by searching for those which are annotated with this annotation and adding a JS
+ * callback for each.
*/
@Retention(RUNTIME)
public @interface ReactMethod {
/**
- * Whether the method can be called from JS synchronously **on the JS thread**,
- * possibly returning a result.
+ * Whether the method can be called from JS synchronously **on the JS thread**, possibly returning
+ * a result.
*
- * WARNING: in the vast majority of cases, you should leave this to false which allows
- * your native module methods to be called asynchronously: calling methods
- * synchronously can have strong performance penalties and introduce threading-related
- * bugs to your native modules.
+ * WARNING: in the vast majority of cases, you should leave this to false which allows your
+ * native module methods to be called asynchronously: calling methods synchronously can have
+ * strong performance penalties and introduce threading-related bugs to your native modules.
*
- * In order to support remote debugging, both the method args and return type must be
- * serializable to JSON: this means that we only support the same args as
- * {@link ReactMethod}, and the hook can only be void or return JSON values (e.g. bool,
- * number, String, {@link WritableMap}, or {@link WritableArray}). Calling these
- * methods when running under the websocket executor is currently not supported.
+ * In order to support remote debugging, both the method args and return type must be
+ * serializable to JSON: this means that we only support the same args as {@link ReactMethod}, and
+ * the hook can only be void or return JSON values (e.g. bool, number, String, {@link
+ * WritableMap}, or {@link WritableArray}). Calling these methods when running under the websocket
+ * executor is currently not supported.
*/
boolean isBlockingSynchronousMethod() default false;
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactModuleWithSpec.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactModuleWithSpec.java
index 716b2a3f6f5..44ea8301d9c 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactModuleWithSpec.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactModuleWithSpec.java
@@ -1,19 +1,16 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
import com.facebook.proguard.annotations.DoNotStrip;
/**
- * An interface to be implemented by react modules that extends from the
- * generated spec class.
- * This is experimental.
+ * An interface to be implemented by react modules that extends from the generated spec class. This
+ * is experimental.
*/
@DoNotStrip
-public interface ReactModuleWithSpec {
-}
+public interface ReactModuleWithSpec {}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableArray.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableArray.java
index 79b3bb63985..042121349b3 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableArray.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableArray.java
@@ -1,14 +1,12 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ * This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
*/
-
package com.facebook.react.bridge;
import java.util.ArrayList;
-
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -19,15 +17,30 @@ import javax.annotation.Nullable;
public interface ReadableArray {
int size();
- boolean isNull(int index);
- boolean getBoolean(int index);
- double getDouble(int index);
- int getInt(int index);
- @Nullable String getString(int index);
- @Nullable ReadableArray getArray(int index);
- @Nullable ReadableMap getMap(int index);
- @Nonnull Dynamic getDynamic(int index);
- @Nonnull ReadableType getType(int index);
- @Nonnull ArrayList
* synchronized(hybrid) {
* if (hybrid.isValid) {
@@ -61,8 +56,7 @@ public class HybridData {
public static class Destructor extends DestructorThread.Destructor {
// Private C++ instance
- @DoNotStrip
- private long mNativePointer;
+ @DoNotStrip private long mNativePointer;
Destructor(Object referent) {
super(referent);
diff --git a/ReactAndroid/src/main/java/com/facebook/jni/IteratorHelper.java b/ReactAndroid/src/main/java/com/facebook/jni/IteratorHelper.java
index 88e2de6353d..26e00aed135 100644
--- a/ReactAndroid/src/main/java/com/facebook/jni/IteratorHelper.java
+++ b/ReactAndroid/src/main/java/com/facebook/jni/IteratorHelper.java
@@ -1,31 +1,26 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ *
- *
*/
public ReactInstanceManager build() {
Assertions.assertNotNull(
- mApplication,
- "Application property has not been set with this builder");
+ mApplication, "Application property has not been set with this builder");
if (mInitialLifecycleState == LifecycleState.RESUMED) {
Assertions.assertNotNull(
- mCurrentActivity,
- "Activity needs to be set if initial lifecycle state is resumed");
+ mCurrentActivity, "Activity needs to be set if initial lifecycle state is resumed");
}
Assertions.assertCondition(
- mUseDeveloperSupport || mJSBundleAssetUrl != null || mJSBundleLoader != null,
- "JS Bundle File or Asset URL has to be provided when dev support is disabled");
+ mUseDeveloperSupport || mJSBundleAssetUrl != null || mJSBundleLoader != null,
+ "JS Bundle File or Asset URL has to be provided when dev support is disabled");
Assertions.assertCondition(
- mJSMainModulePath != null || mJSBundleAssetUrl != null || mJSBundleLoader != null,
- "Either MainModulePath or JS Bundle File needs to be provided");
+ mJSMainModulePath != null || mJSBundleAssetUrl != null || mJSBundleLoader != null,
+ "Either MainModulePath or JS Bundle File needs to be provided");
if (mUIImplementationProvider == null) {
// create default UIImplementationProvider if the provided one is null.
diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactInstancePackage.java b/ReactAndroid/src/main/java/com/facebook/react/ReactInstancePackage.java
index 3095ff155bf..63f86e4d6b3 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/ReactInstancePackage.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/ReactInstancePackage.java
@@ -1,31 +1,28 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ *
- *
*
* @param bundle the {@link Bundle} to convert
@@ -362,8 +355,8 @@ public class Arguments {
}
/**
- * Convert a {@link WritableMap} to a {@link Bundle}.
- * Note: Each array is converted to an {@link ArrayList}.
+ * Convert a {@link WritableMap} to a {@link Bundle}. Note: Each array is converted to an {@link
+ * ArrayList}.
*
* @param readableMap the {@link WritableMap} to convert.
* @return the converted {@link Bundle}.
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/AssertionException.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/AssertionException.java
index e225b718dd3..424bc716f60 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/bridge/AssertionException.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/AssertionException.java
@@ -1,16 +1,15 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
+ *