package com.ikea.kompis.view;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.FloatEvaluator;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Handler;
import android.support.v4.view.ViewCompat;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.ViewConfiguration;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewParent;
import android.view.ViewPropertyAnimator;
import android.widget.FrameLayout;
import android.widget.TextView;
import com.ikea.kompis.WelcomeActivity;
import com.ikea.kompis.stores.event.GoToStoreLocatorEvent;
import com.ikea.kompis.util.C.Anim;
import com.ikea.kompis.util.UiUtil;
import com.ikea.shared.AppConfigData;
import com.ikea.shared.AppConfigManager;
import com.ikea.shared.config.model.Country;
import com.ikea.shared.notification.NotificationService;
import com.ikea.shared.notification.WelcomeNotification;
import com.ikea.shared.notification.WelcomeNotification.WELCOME_NOTIFICATION_TYPE;
import com.ikea.shared.store.service.StoreCache;
import com.ikea.shared.stores.model.StoreRef;
import com.ikea.shared.util.L;
import com.squareup.otto.Bus;
import java.util.UnknownFormatConversionException;

public class WelcomeAlertLayout extends FrameLayout
{
  private final Runnable dismissAlertItem = new Runnable()
  {
    public void run()
    {
      WelcomeAlertLayout.this.performDismissALertItem();
    }
  };
  private TextView mAlertText;
  private float mAnimFrom;
  private float mAnimTo;
  private ValueAnimator mAnimator;
  private Bus mBus;
  private View mFrontView;
  private final Handler mHandler = new Handler();
  private WelcomeNotification mItem;
  private final View.OnTouchListener mTouch = new View.OnTouchListener()
  {
    float mDownX;
    float mDownY;
    float mInitialTx;

    @SuppressLint({"ClickableViewAccessibility"})
    public boolean onTouch(View paramAnonymousView, MotionEvent paramAnonymousMotionEvent)
    {
      boolean bool = true;
      switch (paramAnonymousMotionEvent.getActionMasked())
      {
      default:
      case 0:
      case 2:
      case 1:
      case 3:
      }
      while (true)
      {
        bool = false;
        float f2;
        float f4;
        do
        {
          do
          {
            float f3;
            do
            {
              return bool;
              this.mDownX = paramAnonymousMotionEvent.getRawX();
              this.mDownY = paramAnonymousMotionEvent.getRawY();
              this.mInitialTx = WelcomeAlertLayout.this.mFrontView.getTranslationX();
              WelcomeAlertLayout.this.updatePressedState(bool);
              return bool;
              f2 = paramAnonymousMotionEvent.getRawX() - this.mDownX;
              f3 = paramAnonymousMotionEvent.getRawY() - this.mDownY;
              if (Math.abs(f3) > Math.abs(f2) / 2.0F)
              {
                paramAnonymousView.getParent().requestDisallowInterceptTouchEvent(false);
                return false;
              }
              WelcomeAlertLayout.this.getParent().requestDisallowInterceptTouchEvent(bool);
            }
            while (((Math.abs(f2) <= 2 * ViewConfiguration.get(WelcomeAlertLayout.this.getContext()).getScaledTouchSlop()) || (Math.abs(f3) >= Math.abs(f2) / 2.0F)) && (!WelcomeAlertLayout.this.mTracking));
            WelcomeAlertLayout.access$302(WelcomeAlertLayout.this, bool);
            WelcomeAlertLayout.this.getParent().requestDisallowInterceptTouchEvent(bool);
            L.D("tX" + WelcomeAlertLayout.this.mFrontView.getTranslationX() + "   dX " + f2);
            WelcomeAlertLayout.this.updatePressedState(false);
          }
          while ((WelcomeAlertLayout.this.mFrontView.getTranslationX() > 3.0F * WelcomeAlertLayout.this.mWidth / 4.0F) || (WelcomeAlertLayout.this.mFrontView.getTranslationX() < -(3.0F * WelcomeAlertLayout.this.mWidth / 4.0F)));
          f4 = f2 + this.mInitialTx;
          if (f4 > 3.0F * WelcomeAlertLayout.this.mWidth / 4.0F)
          {
            WelcomeAlertLayout.this.removeItem(bool);
            return bool;
          }
          if (f4 < -(3.0F * WelcomeAlertLayout.this.mWidth / 4.0F))
          {
            WelcomeAlertLayout.this.removeItem(false);
            return bool;
          }
        }
        while ((f4 < -(3.0F * WelcomeAlertLayout.this.mWidth / 4.0F)) || (f4 > 3.0F * WelcomeAlertLayout.this.mWidth / 4.0F));
        WelcomeAlertLayout.this.translateTo(f2 + this.mInitialTx);
        return bool;
        WelcomeAlertLayout.this.updatePressedState(false);
        if (WelcomeAlertLayout.this.mTracking)
        {
          WelcomeAlertLayout.access$302(WelcomeAlertLayout.this, false);
          float f1 = WelcomeAlertLayout.this.mFrontView.getTranslationX();
          if (f1 > WelcomeAlertLayout.this.mWidth / 4.0F)
          {
            WelcomeAlertLayout.this.removeItem(bool);
            L.I(this, " Right ");
          }
          while (true)
          {
            WelcomeAlertLayout.this.moveToDefault();
            return bool;
            if (f1 < -(WelcomeAlertLayout.this.mWidth / 4.0F))
            {
              WelcomeAlertLayout.this.removeItem(false);
              L.I(this, " Left ");
            }
          }
        }
        WelcomeAlertLayout.this.handleClick();
        continue;
        WelcomeAlertLayout.this.updatePressedState(false);
      }
    }
  };
  private boolean mTracking;
  private float mWidth;

  public WelcomeAlertLayout(Context paramContext)
  {
    this(paramContext, null, 0);
  }

  public WelcomeAlertLayout(Context paramContext, AttributeSet paramAttributeSet)
  {
    this(paramContext, paramAttributeSet, 0);
  }

  public WelcomeAlertLayout(Context paramContext, AttributeSet paramAttributeSet, int paramInt)
  {
    super(paramContext, paramAttributeSet, paramInt);
    final FloatEvaluator localFloatEvaluator = new FloatEvaluator();
    this.mAnimator = ValueAnimator.ofFloat(new float[] { 0.0F, 1.0F });
    this.mAnimator.setDuration(500L);
    this.mAnimator.setInterpolator(C.Anim.EASE_OUT_QUART_INTERPOLATOR);
    this.mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener()
    {
      public void onAnimationUpdate(ValueAnimator paramAnonymousValueAnimator)
      {
        float f = localFloatEvaluator.evaluate(paramAnonymousValueAnimator.getAnimatedFraction(), Float.valueOf(WelcomeAlertLayout.this.mAnimFrom), Float.valueOf(WelcomeAlertLayout.this.mAnimTo)).floatValue();
        WelcomeAlertLayout.this.translateTo(f);
      }
    });
  }

  private void animateTo(float paramFloat)
  {
    this.mAnimFrom = this.mFrontView.getTranslationX();
    this.mAnimTo = paramFloat;
    this.mAnimator.start();
  }

  private void handleRemoveItemFromSL()
  {
    this.mHandler.post(this.dismissAlertItem);
  }

  private void initWelcomeAlertItem()
  {
    this.mAlertText = ((TextView)findViewById(2131624360));
    this.mFrontView = findViewById(2131624357);
    this.mFrontView.setOnTouchListener(this.mTouch);
  }

  private void moveToDefault()
  {
    L.I("moveToDefault");
    animateTo(0.0F);
  }

  private void performDismissALertItem()
  {
    final ViewGroup.LayoutParams localLayoutParams = getLayoutParams();
    ValueAnimator localValueAnimator = ValueAnimator.ofInt(new int[] { getHeight(), 1 }).setDuration(500L);
    localValueAnimator.addListener(new AnimatorListenerAdapter()
    {
      public void onAnimationEnd(Animator paramAnonymousAnimator)
      {
        WelcomeAlertLayout.this.setVisibility(8);
        WelcomeAlertLayout.this.setViewTransientState(false);
        if (WelcomeAlertLayout.this.mItem.getType().equals(WelcomeNotification.WELCOME_NOTIFICATION_TYPE.OUT_OF_STOCK))
          NotificationService.i(WelcomeAlertLayout.this.getContext()).setOONotificationDismissed(true);
        do
        {
          return;
          if (WelcomeAlertLayout.this.mItem.getType().equals(WelcomeNotification.WELCOME_NOTIFICATION_TYPE.CLOSER_STORE_NOTIFICATION))
          {
            NotificationService.i(WelcomeAlertLayout.this.getContext()).setCSNotificationDismissed(true);
            return;
          }
          if (WelcomeAlertLayout.this.mItem.getType().equals(WelcomeNotification.WELCOME_NOTIFICATION_TYPE.AUTO_STORE_SELECT))
          {
            NotificationService.i(WelcomeAlertLayout.this.getContext()).setASNotificationDismissed(true);
            return;
          }
          if (WelcomeAlertLayout.this.mItem.getType().equals(WelcomeNotification.WELCOME_NOTIFICATION_TYPE.IN_STORE_WIFI))
          {
            NotificationService.i(WelcomeAlertLayout.this.getContext()).setISNotificationDismissed(true);
            return;
          }
        }
        while (!WelcomeAlertLayout.this.mItem.getType().equals(WelcomeNotification.WELCOME_NOTIFICATION_TYPE.OFFLINE_STATUS));
        NotificationService.i(WelcomeAlertLayout.this.getContext()).setOfflineNotificationDismissed(true);
      }
    });
    localValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener()
    {
      public void onAnimationUpdate(ValueAnimator paramAnonymousValueAnimator)
      {
        localLayoutParams.height = ((Integer)paramAnonymousValueAnimator.getAnimatedValue()).intValue();
        WelcomeAlertLayout.this.setLayoutParams(localLayoutParams);
      }
    });
    localValueAnimator.start();
  }

  private void removeItem(boolean paramBoolean)
  {
    if (paramBoolean)
      this.mFrontView.animate().translationXBy(this.mWidth);
    while (true)
    {
      L.D("Remove operation strat");
      setViewTransientState(true);
      handleRemoveItemFromSL();
      return;
      this.mFrontView.animate().translationXBy(-this.mWidth);
    }
  }

  private void setViewTransientState(boolean paramBoolean)
  {
    ViewCompat.setHasTransientState(this, paramBoolean);
  }

  private void translateTo(float paramFloat)
  {
    this.mFrontView.setTranslationX(paramFloat);
    this.mFrontView.setAlpha(1.0F - Math.abs(paramFloat) / this.mWidth);
  }

  private void updatePressedState(boolean paramBoolean)
  {
  }

  private void updateState(boolean paramBoolean)
  {
    View localView = this.mFrontView;
    if (paramBoolean);
    for (int i = 0; ; i = 8)
    {
      localView.setVisibility(i);
      return;
    }
  }

  protected void handleClick()
  {
    if (this.mItem != null)
    {
      if (!this.mItem.getType().equals(WelcomeNotification.WELCOME_NOTIFICATION_TYPE.OUT_OF_STOCK))
        break label28;
      openSL();
    }
    label28: 
    do
    {
      return;
      if ((this.mItem.getType().equals(WelcomeNotification.WELCOME_NOTIFICATION_TYPE.CLOSER_STORE_NOTIFICATION)) || (this.mItem.getType().equals(WelcomeNotification.WELCOME_NOTIFICATION_TYPE.AUTO_STORE_SELECT)))
      {
        this.mBus.post(new GoToStoreLocatorEvent(false, true, false, false));
        return;
      }
    }
    while (!this.mItem.getType().equals(WelcomeNotification.WELCOME_NOTIFICATION_TYPE.IN_STORE_WIFI));
    Intent localIntent = new Intent("android.intent.action.MAIN");
    localIntent.setClassName("com.android.settings", "com.android.settings.wifi.WifiSettings");
    getContext().startActivity(localIntent);
  }

  protected void onFinishInflate()
  {
    super.onFinishInflate();
    initWelcomeAlertItem();
  }

  protected void onSizeChanged(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    super.onSizeChanged(paramInt1, paramInt2, paramInt3, paramInt4);
    this.mWidth = paramInt1;
  }

  public void openSL()
  {
    L.D("open SL");
    ((WelcomeActivity)getContext()).openSL();
  }

  public void updateWelcomeAlertView(WelcomeNotification paramWelcomeNotification, Bus paramBus)
  {
    Context localContext = getContext();
    this.mItem = paramWelcomeNotification;
    this.mBus = paramBus;
    Object localObject3;
    String str14;
    String str15;
    int i;
    if (paramWelcomeNotification.getType().equals(WelcomeNotification.WELCOME_NOTIFICATION_TYPE.OUT_OF_STOCK))
    {
      localObject3 = "";
      str14 = localContext.getResources().getString(2131165450);
      str15 = localContext.getResources().getString(2131165526);
      i = Integer.parseInt(paramWelcomeNotification.getOutOfStockItems());
      if (i != 1);
    }
    do
      while (true)
      {
        try
        {
          Resources localResources2 = localContext.getResources();
          Object[] arrayOfObject2 = new Object[3];
          arrayOfObject2[0] = Integer.valueOf(i);
          arrayOfObject2[1] = str14;
          arrayOfObject2[2] = str15;
          String str17 = localResources2.getString(2131165454, arrayOfObject2);
          localObject3 = str17;
          SpannableString localSpannableString5 = new SpannableString((CharSequence)localObject3);
          if (((String)localObject3).indexOf(str14) > 0)
          {
            localSpannableString5.setSpan(new StyleSpan(1), ((String)localObject3).indexOf(str14), ((String)localObject3).indexOf(str14) + str14.length(), 33);
            localSpannableString5.setSpan(new ForegroundColorSpan(getResources().getColor(2131492918)), ((String)localObject3).indexOf(str14), ((String)localObject3).indexOf(str14) + str14.length(), 33);
          }
          if (((String)localObject3).indexOf(str15) > 0)
          {
            localSpannableString5.setSpan(new StyleSpan(1), ((String)localObject3).indexOf(str15), ((String)localObject3).indexOf(str15) + str15.length(), 33);
            localSpannableString5.setSpan(new ForegroundColorSpan(getResources().getColor(2131492922)), ((String)localObject3).indexOf(str15), ((String)localObject3).indexOf(str15) + str15.length(), 33);
          }
          this.mAlertText.setText(localSpannableString5);
          this.mAlertText.setCompoundDrawablesWithIntrinsicBounds(2130837664, 0, 0, 0);
          updateState(true);
          return;
          Resources localResources1 = localContext.getResources();
          Object[] arrayOfObject1 = new Object[3];
          arrayOfObject1[0] = Integer.valueOf(i);
          arrayOfObject1[1] = str14;
          arrayOfObject1[2] = str15;
          String str16 = localResources1.getString(2131165452, arrayOfObject1);
          localObject3 = str16;
          continue;
        }
        catch (UnknownFormatConversionException localUnknownFormatConversionException3)
        {
          localUnknownFormatConversionException3.printStackTrace();
          continue;
        }
        catch (Exception localException3)
        {
          localException3.printStackTrace();
          continue;
        }
        if (paramWelcomeNotification.getType().equals(WelcomeNotification.WELCOME_NOTIFICATION_TYPE.AUTO_STORE_SELECT))
        {
          String str11 = AppConfigManager.i(localContext).getAppConfigData().getFavStore().getStoreName();
          String str12 = localContext.getResources().getString(2131165332) + " " + UiUtil.getFormatedStoreName(localContext, AppConfigManager.i(localContext).getAppConfigData().getFavStore().getStoreName());
          Object localObject2 = "";
          try
          {
            String str13 = localContext.getResources().getString(2131165728, new Object[] { str11 });
            localObject2 = str13;
            SpannableString localSpannableString4 = new SpannableString((CharSequence)localObject2);
            if (((String)localObject2).indexOf(str12) > 0)
              localSpannableString4.setSpan(new StyleSpan(1), ((String)localObject2).indexOf(str12), ((String)localObject2).indexOf(str12) + str12.length(), 33);
            this.mAlertText.setText(localSpannableString4);
            this.mAlertText.setCompoundDrawablesWithIntrinsicBounds(2130837728, 0, 0, 0);
          }
          catch (UnknownFormatConversionException localUnknownFormatConversionException2)
          {
            while (true)
              localUnknownFormatConversionException2.printStackTrace();
          }
          catch (Exception localException2)
          {
            while (true)
              localException2.printStackTrace();
          }
        }
        else if (paramWelcomeNotification.getType().equals(WelcomeNotification.WELCOME_NOTIFICATION_TYPE.CLOSER_STORE_NOTIFICATION))
        {
          String str6 = UiUtil.getFormatedStoreName(localContext, paramWelcomeNotification.getNearStoreName());
          String str7 = localContext.getResources().getString(2131165332) + " " + str6;
          String str8 = UiUtil.getFormatedStoreName(localContext, AppConfigManager.i(localContext).getAppConfigData().getFavStore().getStoreName());
          String str9 = localContext.getResources().getString(2131165332) + " " + str8;
          Object localObject1 = "";
          try
          {
            String str10 = localContext.getResources().getString(2131165403, new Object[] { str6, str8 });
            localObject1 = str10;
            SpannableString localSpannableString3 = new SpannableString((CharSequence)localObject1);
            if (((String)localObject1).indexOf(str7) >= 0)
              localSpannableString3.setSpan(new StyleSpan(1), ((String)localObject1).indexOf(str7), ((String)localObject1).indexOf(str7) + str7.length(), 33);
            if (((String)localObject1).indexOf(str9) > 0)
              localSpannableString3.setSpan(new StyleSpan(1), ((String)localObject1).indexOf(str9), ((String)localObject1).indexOf(str9) + str9.length(), 33);
            this.mAlertText.setText(localSpannableString3);
            this.mAlertText.setCompoundDrawablesWithIntrinsicBounds(2130837728, 0, 0, 0);
          }
          catch (UnknownFormatConversionException localUnknownFormatConversionException1)
          {
            while (true)
              localUnknownFormatConversionException1.printStackTrace();
          }
          catch (Exception localException1)
          {
            while (true)
              localException1.printStackTrace();
          }
        }
        else
        {
          if (!paramWelcomeNotification.getType().equals(WelcomeNotification.WELCOME_NOTIFICATION_TYPE.IN_STORE_WIFI))
            break;
          String str4 = localContext.getResources().getString(2131165355);
          String str5 = localContext.getResources().getString(2131165359);
          SpannableString localSpannableString2 = new SpannableString(str4);
          if (str4.indexOf(str5) > 0)
            localSpannableString2.setSpan(new StyleSpan(1), str4.indexOf(str5), str4.indexOf(str5) + str5.length(), 33);
          this.mAlertText.setText(localSpannableString2);
          this.mAlertText.setCompoundDrawablesWithIntrinsicBounds(2130837800, 0, 0, 0);
        }
      }
    while (!paramWelcomeNotification.getType().equals(WelcomeNotification.WELCOME_NOTIFICATION_TYPE.OFFLINE_STATUS));
    String str1 = localContext.getResources().getString(2131165751);
    if ((StoreCache.i(localContext).isInStore()) && (AppConfigManager.i(localContext).getAppConfigData() != null) && (AppConfigManager.i(localContext).getAppConfigData().getConfig() != null) && (AppConfigManager.i(localContext).getAppConfigData().getConfig().ismWifiEnabled()));
    for (String str2 = localContext.getResources().getString(2131165509); ; str2 = localContext.getResources().getString(2131165512))
    {
      String str3 = str1 + "\n" + str2;
      SpannableString localSpannableString1 = new SpannableString(str3);
      if (str3.indexOf(str2) > 0)
        localSpannableString1.setSpan(new StyleSpan(1), str3.indexOf(str2), str3.indexOf(str2) + str2.length(), 33);
      this.mAlertText.setText(localSpannableString1);
      this.mAlertText.setCompoundDrawablesWithIntrinsicBounds(2130837735, 0, 0, 0);
      break;
    }
  }
}

/* Location:           C:\Documents and Settings\Cesar Cabello Cea\Mis documentos\Downloads\apk-downloader\com.ikea.kompis-6_dex2jar.jar
 * Qualified Name:     com.ikea.kompis.view.WelcomeAlertLayout
 * JD-Core Version:    0.6.2
 */