mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Format Java code in xplat/js/react-native-github
Summary: This diff formats the Java class files inside xplat/js/react-native-github. Since google-java-format was enabled in D16071401 we want to codemode the existing code so that users don't have to deal with formatter lint noise at diff-time. ```arc f --paths-cmd 'hg files -I "**/*.java"'``` drop-conflicts Reviewed By: cpojer Differential Revision: D16071725 fbshipit-source-id: fc6e3852e45742c109f0c5ac4065d64201c74204
This commit is contained in:
1 parent
61e95e5cbf
commit
6c0f73b322
681 files changed
+14082
-16365
No files matched your search
@@ -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.
|
||||
* <p>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.uimanager;
|
||||
|
||||
import android.content.Context;
|
||||
@@ -20,22 +19,21 @@ import com.facebook.react.uimanager.annotations.ReactPropGroup;
|
||||
import com.facebook.react.uimanager.annotations.ReactPropertyHolder;
|
||||
import com.facebook.yoga.YogaMeasureMode;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Class responsible for knowing how to create and update catalyst Views of a given type. It is also
|
||||
* responsible for creating and updating CSSNodeDEPRECATED subclasses used for calculating position and size
|
||||
* for the corresponding native view.
|
||||
* responsible for creating and updating CSSNodeDEPRECATED subclasses used for calculating position
|
||||
* and size for the corresponding native view.
|
||||
*/
|
||||
@ReactPropertyHolder
|
||||
public abstract class ViewManager<T extends View, C extends ReactShadowNode>
|
||||
extends BaseJavaModule {
|
||||
extends BaseJavaModule {
|
||||
|
||||
/**
|
||||
* For the vast majority of ViewManagers, you will not need to override this. Only
|
||||
* override this if you really know what you're doing and have a very unique use-case.
|
||||
* For the vast majority of ViewManagers, you will not need to override this. Only override this
|
||||
* if you really know what you're doing and have a very unique use-case.
|
||||
*
|
||||
* @param viewToUpdate
|
||||
* @param props
|
||||
@@ -46,23 +44,18 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode>
|
||||
onAfterUpdateTransaction(viewToUpdate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a view and installs event emitters on it.
|
||||
*/
|
||||
/** Creates a view and installs event emitters on it. */
|
||||
private final @Nonnull T createView(
|
||||
@Nonnull ThemedReactContext reactContext,
|
||||
JSResponderHandler jsResponderHandler) {
|
||||
@Nonnull ThemedReactContext reactContext, JSResponderHandler jsResponderHandler) {
|
||||
return createView(reactContext, null, null, jsResponderHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a view with knowledge of props.
|
||||
*/
|
||||
/** Creates a view with knowledge of props. */
|
||||
public @Nonnull T createView(
|
||||
@Nonnull ThemedReactContext reactContext,
|
||||
@Nullable ReactStylesDiffMap props,
|
||||
@Nullable StateWrapper stateWrapper,
|
||||
JSResponderHandler jsResponderHandler) {
|
||||
@Nonnull ThemedReactContext reactContext,
|
||||
@Nullable ReactStylesDiffMap props,
|
||||
@Nullable StateWrapper stateWrapper,
|
||||
JSResponderHandler jsResponderHandler) {
|
||||
T view = createViewInstance(reactContext, props, stateWrapper);
|
||||
addEventEmitters(reactContext, view);
|
||||
if (view instanceof ReactInterceptingViewGroup) {
|
||||
@@ -71,10 +64,9 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode>
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the name of this view manager. This will be the name used to reference this view
|
||||
* manager from JavaScript in createReactNativeComponentClass.
|
||||
* manager from JavaScript in createReactNativeComponentClass.
|
||||
*/
|
||||
public abstract @Nonnull String getName();
|
||||
|
||||
@@ -95,8 +87,8 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode>
|
||||
* This method should return {@link Class} instance that represent type of shadow node that this
|
||||
* manager will return from {@link #createShadowNodeInstance}.
|
||||
*
|
||||
* This method will be used in the bridge initialization phase to collect properties exposed using
|
||||
* {@link ReactProp} (or {@link ReactPropGroup}) annotation from the {@link ReactShadowNode}
|
||||
* <p>This method will be used in the bridge initialization phase to collect properties exposed
|
||||
* using {@link ReactProp} (or {@link ReactPropGroup}) annotation from the {@link ReactShadowNode}
|
||||
* subclass specific for native view this manager provides.
|
||||
*
|
||||
* @return {@link Class} object that represents type of shadow node used by this view manager.
|
||||
@@ -105,17 +97,22 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode>
|
||||
|
||||
/**
|
||||
* Subclasses should return a new View instance of the proper type.
|
||||
*
|
||||
* @param reactContext
|
||||
*/
|
||||
protected abstract @Nonnull T createViewInstance(@Nonnull ThemedReactContext reactContext);
|
||||
|
||||
/**
|
||||
* Subclasses should return a new View instance of the proper type.
|
||||
* This is an optional method that will call createViewInstance for you.
|
||||
* Override it if you need props upon creation of the view.
|
||||
* Subclasses should return a new View instance of the proper type. This is an optional method
|
||||
* that will call createViewInstance for you. Override it if you need props upon creation of the
|
||||
* view.
|
||||
*
|
||||
* @param reactContext
|
||||
*/
|
||||
protected @Nonnull T createViewInstance(@Nonnull ThemedReactContext reactContext, @Nullable ReactStylesDiffMap initialProps, @Nullable StateWrapper stateWrapper) {
|
||||
protected @Nonnull T createViewInstance(
|
||||
@Nonnull ThemedReactContext reactContext,
|
||||
@Nullable ReactStylesDiffMap initialProps,
|
||||
@Nullable StateWrapper stateWrapper) {
|
||||
T view = createViewInstance(reactContext);
|
||||
if (initialProps != null) {
|
||||
updateProperties(view, initialProps);
|
||||
@@ -124,70 +121,65 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode>
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when view is detached from view hierarchy and allows for some additional cleanup by
|
||||
* the {@link ViewManager} subclass.
|
||||
* Called when view is detached from view hierarchy and allows for some additional cleanup by the
|
||||
* {@link ViewManager} subclass.
|
||||
*/
|
||||
public void onDropViewInstance(@Nonnull T view) {
|
||||
}
|
||||
public void onDropViewInstance(@Nonnull T view) {}
|
||||
|
||||
/**
|
||||
* Subclasses can override this method to install custom event emitters on the given View. You
|
||||
* might want to override this method if your view needs to emit events besides basic touch events
|
||||
* to JS (e.g. scroll events).
|
||||
*/
|
||||
protected void addEventEmitters(@Nonnull ThemedReactContext reactContext, @Nonnull T view) {
|
||||
}
|
||||
protected void addEventEmitters(@Nonnull ThemedReactContext reactContext, @Nonnull T view) {}
|
||||
|
||||
/**
|
||||
* Callback that will be triggered after all properties are updated in current update transaction
|
||||
* (all @ReactProp handlers for properties updated in current transaction have been called). If
|
||||
* you want to override this method you should call super.onAfterUpdateTransaction from it as
|
||||
* the parent class of the ViewManager may rely on callback being executed.
|
||||
* you want to override this method you should call super.onAfterUpdateTransaction from it as the
|
||||
* parent class of the ViewManager may rely on callback being executed.
|
||||
*/
|
||||
protected void onAfterUpdateTransaction(@Nonnull T view) {
|
||||
}
|
||||
protected void onAfterUpdateTransaction(@Nonnull T view) {}
|
||||
|
||||
/**
|
||||
* Subclasses can implement this method to receive an optional extra data enqueued from the
|
||||
* corresponding instance of {@link ReactShadowNode} in
|
||||
* {@link ReactShadowNode#onCollectExtraUpdates}.
|
||||
* corresponding instance of {@link ReactShadowNode} in {@link
|
||||
* ReactShadowNode#onCollectExtraUpdates}.
|
||||
*
|
||||
* Since css layout step and ui updates can be executed in separate thread apart of setting
|
||||
* <p>Since css layout step and ui updates can be executed in separate thread apart of setting
|
||||
* x/y/width/height this is the recommended and thread-safe way of passing extra data from css
|
||||
* node to the native view counterpart.
|
||||
*
|
||||
* TODO(7247021): Replace updateExtraData with generic update props mechanism after D2086999
|
||||
* <p>TODO(7247021): Replace updateExtraData with generic update props mechanism after D2086999
|
||||
*/
|
||||
public abstract void updateExtraData(@Nonnull T root, Object extraData);
|
||||
|
||||
/**
|
||||
* Subclasses may use this method to receive events/commands directly from JS through the
|
||||
* {@link UIManager}. Good example of such a command would be {@code scrollTo} request with
|
||||
* coordinates for a {@link ScrollView} instance.
|
||||
* Subclasses may use this method to receive events/commands directly from JS through the {@link
|
||||
* UIManager}. Good example of such a command would be {@code scrollTo} request with coordinates
|
||||
* for a {@link ScrollView} instance.
|
||||
*
|
||||
* @param root View instance that should receive the command
|
||||
* @param commandId code of the command
|
||||
* @param args optional arguments for the command
|
||||
*/
|
||||
public void receiveCommand(@Nonnull T root, int commandId, @Nullable ReadableArray args) {
|
||||
}
|
||||
public void receiveCommand(@Nonnull T root, int commandId, @Nullable ReadableArray args) {}
|
||||
|
||||
/**
|
||||
* Subclasses may use this method to receive events/commands directly from JS through the
|
||||
* {@link UIManager}. Good example of such a command would be {@code scrollTo} request with
|
||||
* coordinates for a {@link ScrollView} instance.
|
||||
* Subclasses may use this method to receive events/commands directly from JS through the {@link
|
||||
* UIManager}. Good example of such a command would be {@code scrollTo} request with coordinates
|
||||
* for a {@link ScrollView} instance.
|
||||
*
|
||||
* @param root View instance that should receive the command
|
||||
* @param commandId code of the command
|
||||
* @param args optional arguments for the command
|
||||
*/
|
||||
public void receiveCommand(@Nonnull T root, String commandId, @Nullable ReadableArray args) {
|
||||
}
|
||||
public void receiveCommand(@Nonnull T root, String commandId, @Nullable ReadableArray args) {}
|
||||
|
||||
/**
|
||||
* Subclasses of {@link ViewManager} that expect to receive commands through
|
||||
* {@link UIManagerModule#dispatchViewManagerCommand} should override this method returning the
|
||||
* map between names of the commands and IDs that are then used in {@link #receiveCommand} method
|
||||
* Subclasses of {@link ViewManager} that expect to receive commands through {@link
|
||||
* UIManagerModule#dispatchViewManagerCommand} should override this method returning the map
|
||||
* between names of the commands and IDs that are then used in {@link #receiveCommand} method
|
||||
* whenever the command is dispatched for this particular {@link ViewManager}.
|
||||
*
|
||||
* @return map of string to int mapping of the expected commands
|
||||
@@ -201,15 +193,8 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode>
|
||||
* native views. This should return bubbling directly-dispatched event types and specify what
|
||||
* names should be used to subscribe to either form (bubbling/capturing).
|
||||
*
|
||||
* Returned map should be of the form:
|
||||
* {
|
||||
* "onTwirl": {
|
||||
* "phasedRegistrationNames": {
|
||||
* "bubbled": "onTwirl",
|
||||
* "captured": "onTwirlCaptured"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* <p>Returned map should be of the form: { "onTwirl": { "phasedRegistrationNames": { "bubbled":
|
||||
* "onTwirl", "captured": "onTwirlCaptured" } } }
|
||||
*/
|
||||
public @Nullable Map<String, Object> getExportedCustomBubblingEventTypeConstants() {
|
||||
return null;
|
||||
@@ -219,12 +204,7 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode>
|
||||
* Returns a map of config data passed to JS that defines eligible events that can be placed on
|
||||
* native views. This should return non-bubbling directly-dispatched event types.
|
||||
*
|
||||
* Returned map should be of the form:
|
||||
* {
|
||||
* "onTwirl": {
|
||||
* "registrationName": "onTwirl"
|
||||
* }
|
||||
* }
|
||||
* <p>Returned map should be of the form: { "onTwirl": { "registrationName": "onTwirl" } }
|
||||
*/
|
||||
public @Nullable Map<String, Object> getExportedCustomDirectEventTypeConstants() {
|
||||
return null;
|
||||
@@ -242,16 +222,16 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode>
|
||||
return ViewManagerPropertyUpdater.getNativeProps(getClass(), getShadowNodeClass());
|
||||
}
|
||||
|
||||
public @Nullable Object updateLocalData( @Nonnull T view, ReactStylesDiffMap props, ReactStylesDiffMap localData) {
|
||||
public @Nullable Object updateLocalData(
|
||||
@Nonnull T view, ReactStylesDiffMap props, ReactStylesDiffMap localData) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subclasses can implement this method to receive state updates shared between all instances
|
||||
* of this component type.
|
||||
* Subclasses can implement this method to receive state updates shared between all instances of
|
||||
* this component type.
|
||||
*/
|
||||
public void updateState(@Nonnull T view, StateWrapper stateWrapper) {
|
||||
}
|
||||
public void updateState(@Nonnull T view, StateWrapper stateWrapper) {}
|
||||
|
||||
public long measure(
|
||||
Context context,
|
||||
|
||||
Reference in new issue
Block a user