Fix buggy behavior of setBackgroundColor in react View.

Differential Revision: D2582549

fb-gh-sync-id: 8856eb27d46df37e201cd1169fcec3b5b68dac97
This commit is contained in:
Krzysztof Magiera 2015-10-26 14:21:12 -07:00 committed by facebook-github-bot-3
parent 05c9a1f91a
commit 3a92f2017f
1 changed files with 2 additions and 12 deletions

View File

@ -118,18 +118,8 @@ public class ReactViewGroup extends ViewGroup implements
@Override
public void setBackgroundColor(int color) {
if (color == Color.TRANSPARENT) {
Drawable backgroundDrawble = getBackground();
if (mReactBackgroundDrawable != null && (backgroundDrawble instanceof LayerDrawable)) {
// extract translucent background portion from layerdrawable
super.setBackground(null);
LayerDrawable layerDrawable = (LayerDrawable) backgroundDrawble;
super.setBackground(layerDrawable.getDrawable(1));
} else if (backgroundDrawble instanceof ReactViewBackgroundDrawable) {
// mReactBackground is set for background
mReactBackgroundDrawable = null;
super.setBackground(null);
}
if (color == Color.TRANSPARENT && mReactBackgroundDrawable == null) {
// don't do anything, no need to allocate ReactBackgroundDrawable for transparent background
} else {
getOrCreateReactViewBackground().setColor(color);
}