// Copyright 2004-present Facebook. All Rights Reserved.

package com.facebook.react.uimanager.layoutanimation;

import android.view.View;
import android.view.animation.Animation;
import android.view.animation.ScaleAnimation;

import com.facebook.react.uimanager.IllegalViewOperationException;

/**
 * Class responsible for default layout animation, i.e animation of view creation and deletion.
 */
/* package */ abstract class BaseLayoutAnimation extends AbstractLayoutAnimation {

  abstract boolean isReverse();

  @Override
  boolean isValid() {
    return mDurationMs > 0 && mAnimatedProperty != null;
  }

  @Override
  Animation createAnimationImpl(View view, int x, int y, int width, int height) {
    float fromValue = isReverse() ? 1.0f : 0.0f;
    float toValue = isReverse() ? 0.0f : 1.0f;
    if (mAnimatedProperty != null) {
      switch (mAnimatedProperty) {
        case OPACITY:
          return new OpacityAnimation(view, fromValue, toValue);
        case SCALE_XY:
          return new ScaleAnimation(
              fromValue,
              toValue,
              fromValue,
              toValue,
              Animation.RELATIVE_TO_SELF,
              .5f,
              Animation.RELATIVE_TO_SELF,
              .5f);
        default:
          throw new IllegalViewOperationException(
              "Missing animation for property : " + mAnimatedProperty);
      }
    }
    throw new IllegalViewOperationException("Missing animated property from animation config");
  }
}

@@ -695,24 +695,126 @@
 t height) %7B%0A
+    if (mAnimatedProperty != null) %7B%0A      switch (mAnimatedProperty) %7B%0A        case OPACITY: %7B%0A      
     float fr
@@ -837,20 +837,31 @@
 rse() ? 
-1.0f
+view.getAlpha()
  : 0.0f;
@@ -857,24 +857,30 @@
 a() : 0.0f;%0A
+      
     float to
@@ -912,107 +912,24 @@
 f : 
-1.0f;%0A    if (mAnimatedProperty != null) %7B%0A      switch (mAnimatedProperty) %7B%0A        case OPACITY:
+view.getAlpha();
 %0A   
@@ -990,16 +990,26 @@
 Value);%0A
+        %7D%0A
         
@@ -1022,16 +1022,126 @@
 CALE_XY:
+ %7B%0A          float fromValue = isReverse() ? 1.0f : 0.0f;%0A          float toValue = isReverse() ? 0.0f : 1.0f;
 %0A       
@@ -1389,16 +1389,26 @@
   .5f);%0A
+        %7D%0A
         

Let LayoutAnimation respect style opacity on Android. Fix issue #11769