mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-02-06 22:44:22 +08:00
LayoutAnimation support for Android RN
Reviewed By: dernienl Differential Revision: D2710141 fb-gh-sync-id: 28d6af84441b7c2dbc423b73eb05e71f62f7cdea
This commit is contained in:
committed by
facebook-github-bot-4
parent
cf892a96d6
commit
098fcb3a27
@@ -29,9 +29,11 @@ import com.facebook.react.bridge.Callback;
|
||||
import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
|
||||
import com.facebook.react.bridge.ReactContext;
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.bridge.SoftAssertions;
|
||||
import com.facebook.react.bridge.UiThreadUtil;
|
||||
import com.facebook.react.touch.JSResponderHandler;
|
||||
import com.facebook.react.uimanager.layoutanimation.LayoutAnimationController;
|
||||
|
||||
/**
|
||||
* Delegate of {@link UIManagerModule} that owns the native view hierarchy and mapping between
|
||||
@@ -65,6 +67,9 @@ public class NativeViewHierarchyManager {
|
||||
private final ViewManagerRegistry mViewManagers;
|
||||
private final JSResponderHandler mJSResponderHandler = new JSResponderHandler();
|
||||
private final RootViewManager mRootViewManager = new RootViewManager();
|
||||
private final LayoutAnimationController mLayoutAnimator = new LayoutAnimationController();
|
||||
|
||||
private boolean mLayoutAnimationEnabled;
|
||||
|
||||
public NativeViewHierarchyManager(ViewManagerRegistry viewManagers) {
|
||||
mAnimationRegistry = new AnimationRegistry();
|
||||
@@ -95,6 +100,10 @@ public class NativeViewHierarchyManager {
|
||||
return mAnimationRegistry;
|
||||
}
|
||||
|
||||
public void setLayoutAnimationEnabled(boolean enabled) {
|
||||
mLayoutAnimationEnabled = enabled;
|
||||
}
|
||||
|
||||
public void updateProperties(int tag, CatalystStylesDiffMap props) {
|
||||
UiThreadUtil.assertOnUiThread();
|
||||
|
||||
@@ -149,8 +158,17 @@ public class NativeViewHierarchyManager {
|
||||
}
|
||||
if (parentViewGroupManager != null
|
||||
&& !parentViewGroupManager.needsCustomLayoutForChildren()) {
|
||||
viewToUpdate.layout(x, y, x + width, y + height);
|
||||
updateLayout(viewToUpdate, x, y, width, height);
|
||||
}
|
||||
} else {
|
||||
updateLayout(viewToUpdate, x, y, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateLayout(View viewToUpdate, int x, int y, int width, int height) {
|
||||
if (mLayoutAnimationEnabled &&
|
||||
mLayoutAnimator.shouldAnimateLayout(viewToUpdate)) {
|
||||
mLayoutAnimator.applyLayoutUpdate(viewToUpdate, x, y, width, height);
|
||||
} else {
|
||||
viewToUpdate.layout(x, y, x + width, y + height);
|
||||
}
|
||||
@@ -466,6 +484,14 @@ public class NativeViewHierarchyManager {
|
||||
mJSResponderHandler.clearJSResponder();
|
||||
}
|
||||
|
||||
void configureLayoutAnimation(final ReadableMap config) {
|
||||
mLayoutAnimator.initializeFromConfig(config);
|
||||
}
|
||||
|
||||
void clearLayoutAnimation() {
|
||||
mLayoutAnimator.reset();
|
||||
}
|
||||
|
||||
/* package */ void startAnimationForNativeView(
|
||||
int reactTag,
|
||||
Animation animation,
|
||||
|
||||
Reference in New Issue
Block a user