package com.ikea.kompis.shopping;

import android.animation.Animator;
import android.animation.Animator.AnimatorListener;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.content.Context;
import android.content.res.Resources;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewGroup.MarginLayoutParams;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.view.animation.RotateAnimation;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.ikea.kompis.util.C.Anim;
import com.ikea.kompis.util.UiUtil;
import com.ikea.shared.util.Constant;
import com.ikea.shared.util.L;

public class ShoppingLayout extends LinearLayout
{
  private static final int ANIMATION_DURATION = 500;
  private boolean isTransitionCompleted = true;
  private final Animation.AnimationListener mAnimationListener = new Animation.AnimationListener()
  {
    public void onAnimationEnd(Animation paramAnonymousAnimation)
    {
      new Handler().post(new Runnable()
      {
        public void run()
        {
          if (ShoppingLayout.this.mEventListener != null)
          {
            if (!ShoppingLayout.this.isMaximized())
              break label92;
            ShoppingLayout.this.mEventListener.onMaximized();
            UiUtil.hideKeyBoard(ShoppingLayout.this.mHeader.getContext(), ShoppingLayout.this.mHeader);
          }
          while (true)
          {
            ShoppingLayout.access$102(ShoppingLayout.this, true);
            ShoppingLayout.this.setLayerType(0, null);
            return;
            label92: ShoppingLayout.this.mEventListener.onMinimized();
          }
        }
      });
    }

    public void onAnimationRepeat(Animation paramAnonymousAnimation)
    {
      L.I(this, "onAnimationRepeat");
    }

    public void onAnimationStart(Animation paramAnonymousAnimation)
    {
      L.I(this, "onAnimationStart");
      ShoppingLayout.this.setLayerType(2, null);
    }
  };
  private RotateAnimation mCloseRotateAnimation;
  private final FrameLayout mContent;
  private final Context mCtx;
  private ShoppingCartMotionEventListener mEventListener;
  private View mHeader;
  private int mHeaderHeight;
  private int mInitialTopMargin;
  private boolean mIsMovingUp;
  private View mMinimize;
  private final View.OnClickListener mOnClickListener = new View.OnClickListener()
  {
    public void onClick(View paramAnonymousView)
    {
      if (paramAnonymousView.getId() == 2131624340);
      do
      {
        do
          return;
        while (((!UiUtil.isTablet(ShoppingLayout.this.getContext())) && (ShoppingLayout.this.mTrayOpened)) || (!ShoppingLayout.this.isTransitionCompleted));
        if (Constant.i().isAddToSL())
          ShoppingLayout.access$102(ShoppingLayout.this, false);
        if (ShoppingLayout.this.isMaximized())
        {
          ShoppingLayout.access$302(ShoppingLayout.this, false);
          ShoppingLayout.this.minimize(ShoppingLayout.this.mIsMovingUp);
          return;
        }
      }
      while (!Constant.i().isAddToSL());
      ShoppingLayout.access$302(ShoppingLayout.this, true);
      ShoppingLayout.this.maximize(ShoppingLayout.this.mIsMovingUp);
    }
  };
  private RotateAnimation mOpenRotateAnimation;
  private int mParentHeight;
  private boolean mSLOpened = false;
  private int mStatusBarHeight;
  private TextView mTitle;
  private boolean mTrayOpened = false;
  private final ValueAnimator mValueAnimator;

  public ShoppingLayout(Context paramContext, AttributeSet paramAttributeSet)
  {
    super(paramContext, paramAttributeSet);
    this.mCtx = paramContext;
    LayoutInflater.from(paramContext).inflate(2130903131, this, true);
    this.mIsMovingUp = true;
    this.mContent = ((FrameLayout)findViewById(2131624340));
    this.mValueAnimator = ValueAnimator.ofFloat(new float[] { 0.0F, 1.0F, 1.0F, 0.0F });
    this.mValueAnimator.setDuration(getResources().getInteger(2131427352));
    this.mValueAnimator.setInterpolator(C.Anim.EASE_OUT_QUART_INTERPOLATOR);
    initHeader();
  }

  private void initHeader()
  {
    this.mHeader = findViewById(2131624336);
    this.mHeader.setOnClickListener(this.mOnClickListener);
    this.mContent.setOnClickListener(this.mOnClickListener);
    this.mMinimize = findViewById(2131624339);
    this.mTitle = ((TextView)findViewById(2131624338));
    findViewById(2131624337).setOnClickListener(this.mOnClickListener);
    this.mOpenRotateAnimation = ((RotateAnimation)AnimationUtils.loadAnimation(getContext(), 2130968579));
    this.mCloseRotateAnimation = ((RotateAnimation)AnimationUtils.loadAnimation(getContext(), 2130968578));
  }

  private boolean isMaximized()
  {
    return ((ViewGroup.MarginLayoutParams)getLayoutParams()).topMargin == this.mStatusBarHeight;
  }

  private void openSL()
  {
    Constant.i().setAddToSL(false);
    ViewGroup.MarginLayoutParams localMarginLayoutParams = (ViewGroup.MarginLayoutParams)getLayoutParams();
    localMarginLayoutParams.topMargin = this.mStatusBarHeight;
    setLayoutParams(localMarginLayoutParams);
    rotate(true, 0);
    this.mIsMovingUp = false;
  }

  private void resetHeaderAfterAnimation()
  {
    this.mHeader.setPadding(this.mHeader.getPaddingLeft(), this.mHeader.getPaddingTop(), this.mHeader.getPaddingRight(), 0);
    this.mHeader.getLayoutParams().height = this.mHeaderHeight;
    setTopMargin(this.mParentHeight - this.mHeaderHeight);
    this.mHeader.requestLayout();
  }

  private void rotate(boolean paramBoolean, int paramInt)
  {
    if (paramBoolean);
    for (RotateAnimation localRotateAnimation = this.mOpenRotateAnimation; ; localRotateAnimation = this.mCloseRotateAnimation)
    {
      localRotateAnimation.setDuration(paramInt / 2);
      localRotateAnimation.setStartOffset(paramInt - 200);
      this.mMinimize.startAnimation(localRotateAnimation);
      return;
    }
  }

  private void setTopMargin(int paramInt)
  {
    ViewGroup.MarginLayoutParams localMarginLayoutParams = (ViewGroup.MarginLayoutParams)getLayoutParams();
    localMarginLayoutParams.topMargin = paramInt;
    setLayoutParams(localMarginLayoutParams);
    this.mInitialTopMargin = localMarginLayoutParams.topMargin;
  }

  private void startMoveAnimation(boolean paramBoolean)
  {
    ViewGroup.MarginLayoutParams localMarginLayoutParams = (ViewGroup.MarginLayoutParams)getLayoutParams();
    int i;
    int j;
    if (paramBoolean)
    {
      i = this.mStatusBarHeight;
      if (!paramBoolean)
        break label106;
      j = (int)(500.0F * (localMarginLayoutParams.topMargin / this.mInitialTopMargin));
    }
    while (true)
    {
      if (j < 0)
        j = 0;
      AnimationVerticalMove localAnimationVerticalMove = new AnimationVerticalMove(this, i, localMarginLayoutParams.topMargin, paramBoolean);
      localAnimationVerticalMove.setDuration(j);
      localAnimationVerticalMove.setInterpolator(C.Anim.EASE_OUT_QUART_INTERPOLATOR);
      localAnimationVerticalMove.setAnimationListener(this.mAnimationListener);
      this.mHeader.startAnimation(localAnimationVerticalMove);
      return;
      i = this.mInitialTopMargin;
      break;
      label106: if (this.mInitialTopMargin == localMarginLayoutParams.topMargin)
        j = 500;
      else
        j = (int)(500.0F * ((this.mInitialTopMargin - localMarginLayoutParams.topMargin) / this.mInitialTopMargin));
    }
  }

  public void bounceHeight()
  {
    final int i = this.mHeaderHeight;
    final int j = this.mHeader.getPaddingLeft();
    final int k = this.mHeader.getPaddingRight();
    final int m = this.mHeader.getPaddingTop();
    final int n = this.mHeader.getPaddingBottom();
    final float f = UiUtil.pxFromDp(getContext(), 40.0F);
    this.mValueAnimator.cancel();
    this.mValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener()
    {
      public void onAnimationUpdate(ValueAnimator paramAnonymousValueAnimator)
      {
        float f = ((Float)paramAnonymousValueAnimator.getAnimatedValue()).floatValue();
        int i = (int)(n + f * f);
        ShoppingLayout.this.mHeader.setPadding(j, m, k, i * 2);
        ShoppingLayout.this.mHeader.getLayoutParams().height = (i + i * 2);
        ShoppingLayout.this.setTopMargin(ShoppingLayout.this.mParentHeight - (i + i));
        ShoppingLayout.this.mHeader.requestLayout();
      }
    });
    this.mValueAnimator.addListener(new Animator.AnimatorListener()
    {
      public void onAnimationCancel(Animator paramAnonymousAnimator)
      {
        ShoppingLayout.this.resetHeaderAfterAnimation();
      }

      public void onAnimationEnd(Animator paramAnonymousAnimator)
      {
        ShoppingLayout.this.resetHeaderAfterAnimation();
      }

      public void onAnimationRepeat(Animator paramAnonymousAnimator)
      {
      }

      public void onAnimationStart(Animator paramAnonymousAnimator)
      {
      }
    });
    this.mValueAnimator.setStartDelay(getResources().getInteger(2131427353));
    this.mValueAnimator.start();
  }

  public boolean isSLOpen()
  {
    return this.mSLOpened;
  }

  public void maximize(boolean paramBoolean)
  {
    Constant.i().setAddToSL(false);
    startMoveAnimation(paramBoolean);
    rotate(paramBoolean, 500);
    this.mIsMovingUp = false;
    if (this.mEventListener != null)
      this.mEventListener.beforeMaximize();
  }

  public void minimize(boolean paramBoolean)
  {
    Constant.i().setAddToSL(true);
    startMoveAnimation(paramBoolean);
    rotate(paramBoolean, 500);
    this.mIsMovingUp = true;
    if (this.mEventListener != null)
      this.mEventListener.beforeMinimize();
  }

  public void setContent(FragmentTransaction paramFragmentTransaction, Fragment paramFragment)
  {
    paramFragmentTransaction.replace(2131624340, paramFragment);
    paramFragmentTransaction.commit();
  }

  public void setContent(FragmentTransaction paramFragmentTransaction, Fragment paramFragment, String paramString)
  {
    paramFragmentTransaction.replace(2131624340, paramFragment, paramString);
    paramFragmentTransaction.commit();
  }

  public void setEventListener(ShoppingCartMotionEventListener paramShoppingCartMotionEventListener)
  {
    this.mEventListener = paramShoppingCartMotionEventListener;
  }

  public void setListEnable(boolean paramBoolean)
  {
    this.mHeader.setClickable(paramBoolean);
  }

  public void setParentHeight(int paramInt1, int paramInt2, boolean paramBoolean)
  {
    this.mHeaderHeight = this.mHeader.getHeight();
    if (this.mHeaderHeight == 0)
      this.mHeaderHeight = ((int)getResources().getDimension(2131361930));
    int i = paramInt1 - this.mHeaderHeight;
    this.mStatusBarHeight = paramInt2;
    this.mParentHeight = paramInt1;
    ViewGroup.LayoutParams localLayoutParams = this.mContent.getLayoutParams();
    localLayoutParams.height = (i - this.mStatusBarHeight);
    this.mContent.setLayoutParams(localLayoutParams);
    setTopMargin(i);
    if ((paramBoolean) && (!isMaximized()))
      openSL();
  }

  public void setTrayOpen(boolean paramBoolean)
  {
    this.mTrayOpened = paramBoolean;
  }

  public void updateTitle()
  {
    this.mTitle.setText(this.mCtx.getString(2131165471));
  }

  public static abstract interface ShoppingCartMotionEventListener
  {
    public abstract void beforeMaximize();

    public abstract void beforeMinimize();

    public abstract void onMaximized();

    public abstract void onMinimized();
  }
}

/* Location:           C:\Documents and Settings\Cesar Cabello Cea\Mis documentos\Downloads\apk-downloader\com.ikea.kompis-6_dex2jar.jar
 * Qualified Name:     com.ikea.kompis.shopping.ShoppingLayout
 * JD-Core Version:    0.6.2
 */