Fix updating a view z-index on Android

Summary:
If the z-index was updated after the initial mount, changes would not be reflected because we did not recalculate the z-index mapped child views and redraw the view. This adds code to do that and call it whenever we update z-index.

**Test plan**
Tested by reproducing the bug with 2 overlapping views that change z-index every second. Made sure it now works properly and z-index changes are reflected.
Closes https://github.com/facebook/react-native/pull/15203

Differential Revision: D5564832

Pulled By: achen1

fbshipit-source-id: 5b6c20147211ce0b7e8954d60f8614eafe128fb4
This commit is contained in:
Janic Duplessis authored and Facebook Github Bot committed 2017-08-09 20:52:11 -07:00
1 parent 460c5dbdf9
commit b103903ec8
4 files changed
+31

No files matched your search

@@ -5,6 +5,7 @@ package com.facebook.react.uimanager;
import android.graphics.Color;
import android.os.Build;
import android.view.View;
import android.view.ViewParent;
import com.facebook.react.R;
import com.facebook.react.bridge.ReadableArray;
@@ -80,6 +81,10 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
public void setZIndex(T view, float zIndex) {
int integerZIndex = Math.round(zIndex);
ViewGroupManager.setViewZIndex(view, integerZIndex);
ViewParent parent = view.getParent();
if (parent != null && parent instanceof ReactZIndexedViewGroup) {
((ReactZIndexedViewGroup) parent).updateDrawingOrder();
}
}
@ReactProp(name = PROP_RENDER_TO_HARDWARE_TEXTURE)