package com.ikea.kompis.stores;

import android.animation.Animator;
import android.animation.Animator.AnimatorListener;
import android.animation.FloatEvaluator;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.content.res.Resources;
import android.location.Location;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.MotionEventCompat;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.ViewPropertyAnimator;
import android.view.ViewTreeObserver;
import android.view.ViewTreeObserver.OnPreDrawListener;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.TextView;
import com.ikea.kompis.WebViewActivity;
import com.ikea.kompis.fragments.BaseFragment;
import com.ikea.kompis.stores.event.FavButtonPressedEvent;
import com.ikea.kompis.stores.event.FavMarkerPositionChangeEvent;
import com.ikea.kompis.stores.event.HeaderDrawnEvent;
import com.ikea.kompis.stores.event.HomeButtonPressedEvent;
import com.ikea.kompis.stores.event.InStoreMapClickedEvent;
import com.ikea.kompis.stores.event.LocationUpdateEvent;
import com.ikea.kompis.stores.event.StoreInfoSelectedEvent;
import com.ikea.kompis.stores.event.StoreInfoStateChangedEvent;
import com.ikea.kompis.stores.event.StoreMarkerSelectedEvent;
import com.ikea.kompis.stores.event.StoreSelectedEvent;
import com.ikea.kompis.util.UiUtil;
import com.ikea.shared.AppError;
import com.ikea.shared.FileService;
import com.ikea.shared.analytics.UsageTracker;
import com.ikea.shared.stores.model.StoreContactMethod;
import com.ikea.shared.stores.model.StoreLocation;
import com.ikea.shared.stores.model.StoreRef;
import com.ikea.shared.stores.model.StoreRefList;
import com.ikea.shared.user.event.FavStoreChangeEvent;
import com.ikea.shared.util.L;
import com.ikea.shared.util.ServiceCallback;
import com.ikea.shared.util.Util;
import com.squareup.otto.Bus;
import com.squareup.otto.Subscribe;
import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class StoreDetailsFragment extends BaseFragment
{
  private static final String KEY_CURRENT_STORE_INDEX = "KEY_CURRENT_STORE_INDEX";
  private static final String KEY_STORE_DETAIL_OPEN = "KEY_STORE_DETAIL_OPEN";
  private static final String PDF_DOWNLOAD_POPUP = "PDF_DOWNLOAD_POPUP";
  private static final String PDF_DOWNLOAD_URL = "PDF_DOWNLOAD_URL";
  private boolean isInfoViewOpen = false;
  private float mActionBarHeight = 0.0F;
  private StorePagerAdapter mAdapter;
  private final Animator.AnimatorListener mAnimListener = new Animator.AnimatorListener()
  {
    public void onAnimationCancel(Animator paramAnonymousAnimator)
    {
    }

    public void onAnimationEnd(Animator paramAnonymousAnimator)
    {
      if (StoreDetailsFragment.this.mStoreInfoLayout != null)
        StoreDetailsFragment.this.mStoreInfoLayout.getParent().requestLayout();
    }

    public void onAnimationRepeat(Animator paramAnonymousAnimator)
    {
      if (StoreDetailsFragment.this.mStoreInfoLayout != null)
        StoreDetailsFragment.this.mStoreInfoLayout.getParent().requestLayout();
    }

    public void onAnimationStart(Animator paramAnonymousAnimator)
    {
      if (StoreDetailsFragment.this.mStoreInfoLayout != null)
        StoreDetailsFragment.this.mStoreInfoLayout.getParent().requestLayout();
    }
  };
  private Location mCurrentLocation;
  private int mCurrentStoreIndex;
  private StoreLocation mCurrentStoreLocation;
  private int mDeviceHight;
  private Animation mFadeInAnimation = null;
  private Animation mFadeOutAnimation = null;
  private View mFavButton = null;
  private StoreRef mFavStore;
  private final ServiceCallback<File> mFileServiceCallack = new ServiceCallback()
  {
    public void done(File paramAnonymousFile, AppError paramAnonymousAppError, Exception paramAnonymousException)
    {
      StoreDetailsFragment.this.hideLoadingDialog();
      if ((paramAnonymousFile != null) && (StoreDetailsFragment.this.mParent != null))
        L.I("Download complted " + paramAnonymousFile.getAbsolutePath());
      try
      {
        UiUtil.launchExternalApplication(StoreDetailsFragment.this.mParent, paramAnonymousFile, "application/pdf");
        return;
      }
      catch (ActivityNotFoundException localActivityNotFoundException)
      {
        localActivityNotFoundException.printStackTrace();
      }
    }
  };
  private boolean mFromFirstUserExp;
  private boolean mFromSL;
  private boolean mFromSettings;
  private boolean mFromTray;
  private boolean mFromWelcome;
  private View mHomeButton = null;
  private boolean mInStoreMapClicked;
  private String mInstoremapUrl;
  private Dialog mPDFLoadingDialog;
  private ViewPager mPager;
  private StoreRef mPreviousStore;
  private View mRootView;
  private StoreRef mSelectedStore;
  private boolean mShowHeader = false;
  private int mStatusBarHeight = 0;
  protected int mStoreInfoButtonsHeight = 0;
  private int mStoreInfoHeaderHeight;
  private int mStoreInfoHeight;
  private View mStoreInfoLayout;
  private StoreRefList mStoreRefList;
  private Object obj = new Object();
  private final View.OnClickListener onClick = new View.OnClickListener()
  {
    public void onClick(View paramAnonymousView)
    {
      switch (paramAnonymousView.getId())
      {
      default:
        return;
      case 2131624449:
        L.I("Header is clicked");
        if (StoreDetailsFragment.this.isInfoViewOpen)
        {
          StoreDetailsFragment.this.animateToCloseStoreInfo();
          return;
        }
        StoreDetailsFragment.this.animateToOpenStoreInfo();
        return;
      case 2131624440:
      case 2131624441:
        StoreDetailsFragment.this.provideStotreContact((StoreContactMethod)paramAnonymousView.getTag());
        return;
      case 2131624454:
      }
      UiUtil.showNavigation(StoreDetailsFragment.this.mParent, StoreDetailsFragment.this.mCurrentLocation, StoreDetailsFragment.this.mCurrentStoreLocation);
    }
  };
  private final View.OnTouchListener onTouchListener = new View.OnTouchListener()
  {
    boolean bOpenedByMove;
    boolean dragStarted = false;
    int movement;
    float x1;
    float x2;
    float x3;
    float y1;
    float y2;
    float y3;

    @SuppressLint({"ClickableViewAccessibility"})
    public boolean onTouch(View paramAnonymousView, MotionEvent paramAnonymousMotionEvent)
    {
      int i = 1;
      switch (MotionEventCompat.getActionMasked(paramAnonymousMotionEvent))
      {
      case 3:
      default:
        L.I("Action was Defalut" + paramAnonymousMotionEvent.getAction());
        i = 0;
      case 0:
      case 2:
      case 1:
        do
        {
          return i;
          this.x1 = paramAnonymousMotionEvent.getRawX();
          this.y1 = paramAnonymousMotionEvent.getRawY();
          this.x3 = this.x1;
          this.y3 = this.y1;
          this.movement = 3;
          this.dragStarted = false;
          this.bOpenedByMove = false;
          paramAnonymousView.getParent().requestDisallowInterceptTouchEvent(i);
          return i;
          this.x2 = paramAnonymousMotionEvent.getRawX();
          this.y2 = paramAnonymousMotionEvent.getRawY();
          if (Math.abs(this.y2 - this.y1) < Math.abs(this.x2 - this.x1))
            paramAnonymousView.getParent().requestDisallowInterceptTouchEvent(false);
          do
          {
            do
            {
              do
              {
                this.x1 = this.x2;
                this.y1 = this.y2;
                return i;
                if ((this.y2 <= this.y1) || (Math.abs(this.y2 - this.y1) <= Math.abs(this.x2 - this.x1)))
                  break;
                paramAnonymousView.getParent().requestDisallowInterceptTouchEvent(i);
                this.dragStarted = i;
                this.movement = 0;
              }
              while (StoreDetailsFragment.this.mStoreInfoLayout == null);
              float f2 = StoreDetailsFragment.this.mStoreInfoLayout.getY() + this.y2 - this.y1;
              if ((StoreDetailsFragment.this.isInfoViewOpen) && (f2 > StoreDetailsFragment.this.mDeviceHight - StoreDetailsFragment.this.mStoreInfoHeaderHeight + StoreDetailsFragment.this.mActionBarHeight))
              {
                f2 = StoreDetailsFragment.this.mDeviceHight - StoreDetailsFragment.this.mStoreInfoHeaderHeight + StoreDetailsFragment.this.mActionBarHeight;
                StoreDetailsFragment.access$402(StoreDetailsFragment.this, false);
                StoreDetailsFragment.this.mBus.post(new StoreInfoStateChangedEvent(false));
              }
              while (true)
              {
                StoreDetailsFragment.this.mStoreInfoLayout.setTranslationY(f2);
                StoreDetailsFragment.this.mStoreInfoLayout.getParent().requestLayout();
                this.movement = 0;
                break;
                if ((!StoreDetailsFragment.this.isInfoViewOpen) && (f2 > StoreDetailsFragment.this.mDeviceHight - StoreDetailsFragment.this.mStoreInfoHeaderHeight + StoreDetailsFragment.this.mActionBarHeight))
                  f2 = StoreDetailsFragment.this.mDeviceHight - StoreDetailsFragment.this.mStoreInfoHeaderHeight + StoreDetailsFragment.this.mActionBarHeight;
              }
            }
            while ((this.y1 <= this.y2) || (Math.abs(this.y2 - this.y1) <= Math.abs(this.x2 - this.x1)));
            paramAnonymousView.getParent().requestDisallowInterceptTouchEvent(i);
            this.dragStarted = i;
            this.movement = i;
          }
          while (StoreDetailsFragment.this.mStoreInfoLayout == null);
          float f1 = StoreDetailsFragment.this.mStoreInfoLayout.getY() + this.y2 - this.y1;
          if ((StoreDetailsFragment.this.isInfoViewOpen) && (f1 < StoreDetailsFragment.this.mDeviceHight - StoreDetailsFragment.this.mStoreInfoHeight))
          {
            f1 = StoreDetailsFragment.this.mDeviceHight - StoreDetailsFragment.this.mStoreInfoHeight;
            if (!this.bOpenedByMove)
              paramAnonymousView.getParent().requestDisallowInterceptTouchEvent(false);
          }
          while (true)
          {
            StoreDetailsFragment.this.mStoreInfoLayout.setTranslationY(f1);
            StoreDetailsFragment.this.mStoreInfoLayout.getParent().requestLayout();
            this.movement = i;
            break;
            if ((!StoreDetailsFragment.this.isInfoViewOpen) && (f1 < StoreDetailsFragment.this.mDeviceHight - StoreDetailsFragment.this.mStoreInfoHeight))
            {
              f1 = StoreDetailsFragment.this.mDeviceHight - StoreDetailsFragment.this.mStoreInfoHeight;
              StoreDetailsFragment.access$402(StoreDetailsFragment.this, i);
              this.bOpenedByMove = i;
              StoreDetailsFragment.this.mBus.post(new StoreInfoStateChangedEvent(i));
            }
          }
          if ((Math.abs(paramAnonymousMotionEvent.getRawX() - this.x3) < ViewConfiguration.get(StoreDetailsFragment.this.getActivity()).getScaledTouchSlop()) && (Math.abs(paramAnonymousMotionEvent.getRawY() - this.y3) < ViewConfiguration.get(StoreDetailsFragment.this.getActivity()).getScaledTouchSlop()))
          {
            paramAnonymousView.performClick();
            return i;
          }
          L.I("Action was UP");
          if ((!this.dragStarted) || (Math.abs(paramAnonymousMotionEvent.getRawY() - this.y3) <= 5.0F) || (Math.abs(paramAnonymousMotionEvent.getRawX() - this.x3) <= 5.0F))
            break;
          if (this.movement == 0)
          {
            StoreDetailsFragment.this.animateToCloseStoreInfo();
            return i;
          }
        }
        while (this.movement != i);
        StoreDetailsFragment.this.animateToOpenStoreInfo();
        return i;
        if (StoreDetailsFragment.this.isInfoViewOpen)
        {
          StoreDetailsFragment.this.animateToCloseStoreInfo();
          return i;
        }
        StoreDetailsFragment.this.animateToOpenStoreInfo();
        return i;
      case 4:
      }
      L.I("Movement occurred outside bounds of current screen element");
      return false;
    }
  };

  private void animateToCloseStoreInfo()
  {
    this.isInfoViewOpen = false;
    if (this.mStoreInfoLayout != null)
    {
      this.mBus.post(new StoreInfoStateChangedEvent(false));
      this.mStoreInfoLayout.animate().setListener(this.mAnimListener).translationY(this.mDeviceHight - this.mStoreInfoHeaderHeight + this.mActionBarHeight);
    }
  }

  private void animateToOpenStoreInfo()
  {
    this.isInfoViewOpen = true;
    if (this.mStoreInfoLayout != null)
    {
      this.mBus.post(new StoreInfoStateChangedEvent(true));
      ensureAnimation(this.mStoreInfoLayout.getTranslationY(), this.mDeviceHight - this.mStoreInfoHeight);
    }
  }

  private void ensureAnimation(final float paramFloat1, final float paramFloat2)
  {
    final FloatEvaluator localFloatEvaluator = new FloatEvaluator();
    ValueAnimator localValueAnimator = ValueAnimator.ofFloat(new float[] { 0.0F, 1.0F });
    localValueAnimator.setDuration(300L);
    localValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener()
    {
      public void onAnimationUpdate(ValueAnimator paramAnonymousValueAnimator)
      {
        float f = localFloatEvaluator.evaluate(paramAnonymousValueAnimator.getAnimatedFraction(), Float.valueOf(paramFloat1), Float.valueOf(paramFloat2)).floatValue();
        StoreDetailsFragment.this.mStoreInfoLayout.setTranslationY(f);
        Log.i("animationopen", "update");
        StoreDetailsFragment.this.mStoreInfoLayout.getParent().requestLayout();
      }
    });
    localValueAnimator.start();
  }

  private void hideLoadingDialog()
  {
    if (this.mPDFLoadingDialog != null)
    {
      this.mPDFLoadingDialog.dismiss();
      this.mPDFLoadingDialog = null;
    }
  }

  private void openImageView(String paramString)
  {
    this.mInStoreMapClicked = true;
    Intent localIntent = new Intent(this.mParent, WebViewActivity.class);
    localIntent.putExtra("title", getString(2131165406));
    localIntent.putExtra("extra_purchase_uri", paramString);
    startActivity(localIntent);
    getActivity().overridePendingTransition(2130968580, 0);
  }

  private void openPDF(String paramString)
  {
    this.mInStoreMapClicked = true;
    showLoadingDialog();
    L.I("Download pdfUrl : " + paramString);
    this.mFileServiceCallack.markValid();
    FileService.i(this.mParent).saveFileInCache(paramString, this.mFileServiceCallack);
  }

  private void provideStotreContact(StoreContactMethod paramStoreContactMethod)
  {
    if (paramStoreContactMethod.getStoreContactMethodType().equalsIgnoreCase("PHONE"))
      UiUtil.handleCall(paramStoreContactMethod.getPhoneNo(), this.mParent);
    do
    {
      return;
      if (paramStoreContactMethod.getStoreContactMethodType().equalsIgnoreCase("EMAIL"))
      {
        UiUtil.handleEmail(paramStoreContactMethod.getEmail(), this.mParent);
        return;
      }
    }
    while (!paramStoreContactMethod.getStoreContactMethodType().equalsIgnoreCase("FAX"));
    UiUtil.handleCall(paramStoreContactMethod.getFax(), this.mParent);
  }

  private void refreshUI(StoreRefList paramStoreRefList, StoreRef paramStoreRef1, Location paramLocation, StoreRef paramStoreRef2, boolean paramBoolean1, boolean paramBoolean2, boolean paramBoolean3)
  {
    if (this.mPager != null)
      if (this.mStoreInfoLayout != null)
      {
        if (!this.mShowHeader)
          break label209;
        if (this.isInfoViewOpen)
          break label189;
        this.mStoreInfoLayout.setTranslationY(this.mDeviceHight - this.mStoreInfoHeaderHeight);
      }
    while (this.mAdapter == null)
      synchronized (this.obj)
      {
        this.mAdapter = new StorePagerAdapter(getActivity(), this.mStoreRefList.getStoreRef(), this.mBus, this.onClick, this.onTouchListener, this.mDeviceHight, this.mStatusBarHeight, this.mFromFirstUserExp, this.mFavStore);
        this.mPager.setAdapter(this.mAdapter);
        if (paramStoreRef2 != null)
        {
          this.mAdapter.setFavorite(this.mFavStore);
          this.mPager.setCurrentItem(this.mAdapter.getStoreIndex(paramStoreRef2));
          this.mCurrentStoreLocation = paramStoreRef2.getStoreLocation();
        }
        label189: label209: 
        while (this.mFavStore == null)
        {
          this.mAdapter.notifyDataSetChanged();
          trackStoreView(paramStoreRefList, paramStoreRef1, paramLocation, paramStoreRef2, paramBoolean1, paramBoolean2, paramBoolean3);
          return;
          this.mStoreInfoLayout.setTranslationY(this.mDeviceHight - this.mStoreInfoHeight);
          break;
          this.mStoreInfoLayout.setTranslationY(this.mDeviceHight);
          break;
        }
        this.mAdapter.setFavorite(this.mFavStore);
        this.mPager.setCurrentItem(this.mAdapter.getStoreIndex(this.mFavStore));
        this.mCurrentStoreLocation = this.mFavStore.getStoreLocation();
      }
    if ((this.mFavStore != null) && (paramStoreRef2 != null))
    {
      this.mAdapter.setFavorite(this.mFavStore);
      this.mPager.setCurrentItem(this.mAdapter.getStoreIndex(paramStoreRef2));
      this.mCurrentStoreLocation = paramStoreRef2.getStoreLocation();
    }
    while (true)
    {
      if (this.mInStoreMapClicked)
      {
        UsageTracker.i().setBackPressed();
        trackStoreView(paramStoreRefList, paramStoreRef1, paramLocation, paramStoreRef2, paramBoolean1, paramBoolean2, paramBoolean3);
        this.mInStoreMapClicked = false;
      }
      synchronized (this.obj)
      {
        this.mAdapter.notifyDataSetChanged();
        return;
      }
      if (this.mFavStore != null)
      {
        this.mAdapter.setFavorite(this.mFavStore);
        this.mPager.setCurrentItem(this.mAdapter.getStoreIndex(this.mFavStore));
        this.mCurrentStoreLocation = this.mFavStore.getStoreLocation();
      }
      else
      {
        this.mCurrentStoreLocation = this.mAdapter.getStoreInfo(0).getStoreLocation();
      }
    }
  }

  @SuppressLint({"InflateParams"})
  private void showLoadingDialog()
  {
    View localView = LayoutInflater.from(this.mParent).inflate(2130903099, null, false);
    localView.findViewById(2131624081).setVisibility(8);
    ((TextView)localView.findViewById(2131624049)).setVisibility(8);
    localView.setBackgroundColor(getResources().getColor(2131492928));
    this.mPDFLoadingDialog = new Dialog(this.mParent, 2131558411);
    this.mPDFLoadingDialog.setContentView(localView);
    this.mPDFLoadingDialog.setCancelable(false);
    this.mPDFLoadingDialog.show();
  }

  private void trackStoreView(StoreRefList paramStoreRefList, StoreRef paramStoreRef1, Location paramLocation, StoreRef paramStoreRef2, boolean paramBoolean1, boolean paramBoolean2, boolean paramBoolean3)
  {
    StoreRef localStoreRef;
    if (paramStoreRef2 != null)
      localStoreRef = paramStoreRef2;
    while (true)
    {
      this.mPreviousStore = localStoreRef;
      UsageTracker.i().viewStorePage(this.mParent, localStoreRef, paramBoolean1, paramBoolean2, this.mFromWelcome, this.mFromSL, this.mFromSettings);
      return;
      if (this.mFavStore != null)
      {
        localStoreRef = this.mFavStore;
      }
      else
      {
        localStoreRef = null;
        if (paramStoreRefList != null)
        {
          List localList = paramStoreRefList.getStoreRef();
          localStoreRef = null;
          if (localList != null)
          {
            boolean bool = paramStoreRefList.getStoreRef().isEmpty();
            localStoreRef = null;
            if (!bool)
              localStoreRef = (StoreRef)paramStoreRefList.getStoreRef().get(0);
          }
        }
      }
    }
  }

  private void updateHomeButton()
  {
    if (this.mHomeButton != null)
    {
      if (this.mCurrentLocation == null)
        this.mHomeButton.setVisibility(4);
    }
    else
      return;
    this.mHomeButton.setVisibility(0);
  }

  protected void adjustInfoHeight()
  {
    if (this.mStoreInfoLayout != null)
    {
      if (!this.mShowHeader)
        break label117;
      if (this.isInfoViewOpen)
        break label75;
      if ((int)this.mStoreInfoLayout.getY() == (int)(this.mDeviceHight - this.mStoreInfoHeaderHeight + this.mActionBarHeight));
    }
    label75: label117: 
    while ((int)this.mStoreInfoLayout.getY() == (int)(this.mDeviceHight + this.mActionBarHeight))
    {
      this.mStoreInfoLayout.animate().translationY(this.mDeviceHight - this.mStoreInfoHeaderHeight + this.mActionBarHeight);
      do
        return;
      while ((int)this.mStoreInfoLayout.getY() == this.mDeviceHight - this.mStoreInfoHeight);
      this.mStoreInfoLayout.animate().translationY(this.mDeviceHight - this.mStoreInfoHeight);
      return;
    }
    this.mStoreInfoLayout.animate().translationY(this.mDeviceHight + this.mActionBarHeight);
  }

  public void closeInfoView()
  {
    if (this.isInfoViewOpen)
      animateToCloseStoreInfo();
  }

  @Subscribe
  public void favoriteStoreChanged(FavStoreChangeEvent paramFavStoreChangeEvent)
  {
    if ((this.mAdapter != null) && (this.mPager != null))
    {
      StoreRef localStoreRef = paramFavStoreChangeEvent.favStore;
      if (localStoreRef != null)
        synchronized (this.obj)
        {
          this.mAdapter.setFavorite(localStoreRef);
          this.mAdapter.notifyDataSetChanged();
          this.mFavButton.setVisibility(0);
          return;
        }
    }
  }

  @Subscribe
  public void handleFavMarkerPositionChange(FavMarkerPositionChangeEvent paramFavMarkerPositionChangeEvent)
  {
    if (paramFavMarkerPositionChangeEvent.favIconOnScreen)
    {
      this.mFadeOutAnimation.setAnimationListener(new Animation.AnimationListener()
      {
        public void onAnimationEnd(Animation paramAnonymousAnimation)
        {
          StoreDetailsFragment.this.mFavButton.setVisibility(8);
        }

        public void onAnimationRepeat(Animation paramAnonymousAnimation)
        {
        }

        public void onAnimationStart(Animation paramAnonymousAnimation)
        {
        }
      });
      if (this.mFavButton.getVisibility() == 0)
        this.mFavButton.startAnimation(this.mFadeOutAnimation);
    }
    do
    {
      return;
      this.mFadeInAnimation.setAnimationListener(new Animation.AnimationListener()
      {
        public void onAnimationEnd(Animation paramAnonymousAnimation)
        {
          StoreDetailsFragment.this.mFavButton.setVisibility(0);
        }

        public void onAnimationRepeat(Animation paramAnonymousAnimation)
        {
        }

        public void onAnimationStart(Animation paramAnonymousAnimation)
        {
        }
      });
    }
    while (this.mFavButton.getVisibility() != 8);
    this.mFavButton.setVisibility(0);
    this.mFavButton.startAnimation(this.mFadeInAnimation);
  }

  @Subscribe
  public void handleHeaderDrawn(HeaderDrawnEvent paramHeaderDrawnEvent)
  {
    if ((this.mPager != null) && (this.mPager.getCurrentItem() == paramHeaderDrawnEvent.index))
    {
      this.mStoreInfoHeaderHeight = (paramHeaderDrawnEvent.headerHeight + this.mStoreInfoButtonsHeight);
      int i = paramHeaderDrawnEvent.infoHeight;
      if (i > 2 * this.mDeviceHight / 3)
        i = 2 * this.mDeviceHight / 3;
      if (i != 0)
        this.mStoreInfoHeight = i;
      adjustInfoHeight();
    }
  }

  @Subscribe
  public void handleInStoreMapClick(InStoreMapClickedEvent paramInStoreMapClickedEvent)
  {
    label118: 
    do
    {
      try
      {
        UsageTracker.i().viewStoreMap(getActivity(), paramInStoreMapClickedEvent.store);
        String str = (String)paramInStoreMapClickedEvent.imageUriList.get(0);
        if ("pdf".equalsIgnoreCase(str.substring(1 + str.lastIndexOf("."), str.length())))
        {
          if (!TextUtils.isEmpty((CharSequence)paramInStoreMapClickedEvent.imageUriList.get(0)))
            if (!((String)paramInStoreMapClickedEvent.imageUriList.get(0)).startsWith("http:"))
              break label118;
          for (this.mInstoremapUrl = ((String)paramInStoreMapClickedEvent.imageUriList.get(0)); ; this.mInstoremapUrl = ("http://www.ikea.com" + (String)paramInStoreMapClickedEvent.imageUriList.get(0)))
          {
            openPDF(this.mInstoremapUrl);
            this.mPreviousStore = null;
            return;
          }
        }
      }
      catch (Exception localException)
      {
        localException.printStackTrace();
        return;
      }
      getActivity().overridePendingTransition(2130968580, 0);
    }
    while (TextUtils.isEmpty((CharSequence)paramInStoreMapClickedEvent.imageUriList.get(0)));
    if (((String)paramInStoreMapClickedEvent.imageUriList.get(0)).startsWith("http:"));
    for (this.mInstoremapUrl = ((String)paramInStoreMapClickedEvent.imageUriList.get(0)); ; this.mInstoremapUrl = ("http://www.ikea.com" + (String)paramInStoreMapClickedEvent.imageUriList.get(0)))
    {
      openImageView(this.mInstoremapUrl);
      break;
    }
  }

  @Subscribe
  public void handleLocationUpdateEvent(LocationUpdateEvent paramLocationUpdateEvent)
  {
    if (getActivity() != null)
    {
      Location localLocation = paramLocationUpdateEvent.currentLocation;
      if ((localLocation != null) && ((this.mCurrentLocation == null) || (!Util.getFormatedDistance(localLocation.getLatitude(), false).equals(Util.getFormatedDistance(this.mCurrentLocation.getLatitude(), false))) || (!Util.getFormatedDistance(localLocation.getLongitude(), false).equals(Util.getFormatedDistance(this.mCurrentLocation.getLongitude(), false)))))
      {
        this.mCurrentLocation = localLocation;
        if ((this.mAdapter != null) && (this.mPager != null))
        {
          if (this.mFavStore == null)
            break label160;
          this.mAdapter.setFavorite(this.mFavStore);
          this.mPager.setCurrentItem(this.mAdapter.getStoreIndex(this.mFavStore));
          this.mCurrentStoreLocation = this.mFavStore.getStoreLocation();
        }
      }
    }
    synchronized (this.obj)
    {
      this.mAdapter.notifyDataSetChanged();
      updateHomeButton();
      return;
      label160: this.mCurrentStoreLocation = this.mAdapter.getStoreInfo(0).getStoreLocation();
    }
  }

  public void onActivityCreated(@Nullable Bundle paramBundle)
  {
    super.onActivityCreated(paramBundle);
    if ((paramBundle != null) && (paramBundle.containsKey("PDF_DOWNLOAD_POPUP")))
    {
      boolean bool = paramBundle.getBoolean("PDF_DOWNLOAD_POPUP", false);
      L.I("isPdfDownloading " + bool);
      if (bool)
        openPDF(paramBundle.getString("PDF_DOWNLOAD_URL"));
    }
  }

  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    this.mFadeInAnimation = AnimationUtils.loadAnimation(this.mParent, 17432576);
    this.mFadeOutAnimation = AnimationUtils.loadAnimation(this.mParent, 17432577);
    this.mStoreInfoHeaderHeight = ((int)getResources().getDimension(2131361918));
    if (paramBundle != null)
    {
      if (paramBundle.containsKey("KEY_CURRENT_STORE_INDEX"))
        this.mCurrentStoreIndex = paramBundle.getInt("KEY_CURRENT_STORE_INDEX");
      if (paramBundle.containsKey("KEY_STORE_DETAIL_OPEN"))
        this.isInfoViewOpen = paramBundle.getBoolean("KEY_STORE_DETAIL_OPEN");
      L.I("onCreate mCurrentStoreIndex :: " + this.mCurrentStoreIndex);
      L.I("onCreate isInfoViewOpen :: " + this.isInfoViewOpen);
    }
  }

  public View onCreateView(LayoutInflater paramLayoutInflater, @Nullable ViewGroup paramViewGroup, @Nullable Bundle paramBundle)
  {
    this.mActionBarHeight = getActivity().getResources().getDimension(2131361870);
    this.mDeviceHight = ((int)(UiUtil.screenHeight(getActivity()) - this.mActionBarHeight));
    this.mStatusBarHeight = UiUtil.getStatusBarHeight(getActivity());
    this.mStoreInfoHeight = (2 * this.mDeviceHight / 3);
    this.mRootView = paramLayoutInflater.inflate(2130903152, paramViewGroup, false);
    this.mStoreInfoLayout = paramViewGroup;
    this.mRootView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener()
    {
      public boolean onPreDraw()
      {
        StoreDetailsFragment.this.mRootView.getViewTreeObserver().removeOnPreDrawListener(this);
        int i = StoreDetailsFragment.this.mRootView.findViewById(2131624443).getHeight();
        if (i != 0)
          StoreDetailsFragment.this.mStoreInfoButtonsHeight = i;
        return true;
      }
    });
    this.mHomeButton = ((ImageView)this.mRootView.findViewById(2131624445));
    this.mHomeButton.setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        StoreDetailsFragment.this.mBus.post(new HomeButtonPressedEvent(StoreDetailsFragment.this.mCurrentLocation));
      }
    });
    updateHomeButton();
    this.mFavButton = ((ImageView)this.mRootView.findViewById(2131624444));
    this.mFavButton.setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        StoreDetailsFragment.this.mBus.post(new FavButtonPressedEvent());
      }
    });
    this.mPager = ((ViewPager)this.mRootView.findViewById(2131624446));
    this.mPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener()
    {
      public void onPageScrollStateChanged(int paramAnonymousInt)
      {
      }

      public void onPageScrolled(int paramAnonymousInt1, float paramAnonymousFloat, int paramAnonymousInt2)
      {
      }

      public void onPageSelected(final int paramAnonymousInt)
      {
        final View localView = StoreDetailsFragment.this.mPager.findViewWithTag("STORE_TAG" + paramAnonymousInt);
        if (localView != null)
        {
          int i = localView.findViewById(2131624448).getHeight();
          if (i > 2 * StoreDetailsFragment.this.mDeviceHight / 3)
            i = 2 * StoreDetailsFragment.this.mDeviceHight / 3;
          if (i == 0)
            break label340;
          StoreDetailsFragment.access$602(StoreDetailsFragment.this, localView.findViewById(2131624449).getHeight() + StoreDetailsFragment.this.mStoreInfoButtonsHeight);
          StoreDetailsFragment.access$902(StoreDetailsFragment.this, i);
          StoreDetailsFragment.this.handleHeaderDrawn(new HeaderDrawnEvent(StoreDetailsFragment.this.mStoreInfoHeaderHeight - StoreDetailsFragment.this.mStoreInfoButtonsHeight, StoreDetailsFragment.this.mStoreInfoHeight, paramAnonymousInt));
        }
        while (true)
        {
          StoreRef localStoreRef = StoreDetailsFragment.this.mAdapter.getStoreInfo(paramAnonymousInt);
          if (((StoreDetailsFragment.this.mPreviousStore == null) && (localStoreRef != null)) || ((localStoreRef != null) && (StoreDetailsFragment.this.mPreviousStore != null) && (!StoreDetailsFragment.this.mPreviousStore.getStoreNo().equals(localStoreRef.getStoreNo()))))
            UsageTracker.i().viewStorePage(StoreDetailsFragment.this.mParent, localStoreRef, StoreDetailsFragment.this.mFromFirstUserExp, StoreDetailsFragment.this.mFromTray, StoreDetailsFragment.this.mFromWelcome, StoreDetailsFragment.this.mFromSL, StoreDetailsFragment.this.mFromSettings);
          StoreDetailsFragment.access$2902(StoreDetailsFragment.this, StoreDetailsFragment.this.mAdapter.getStoreInfo(paramAnonymousInt));
          StoreDetailsFragment.access$3002(StoreDetailsFragment.this, paramAnonymousInt);
          StoreDetailsFragment.this.mBus.post(new StoreInfoSelectedEvent(StoreDetailsFragment.this.mSelectedStore));
          StoreDetailsFragment.access$1602(StoreDetailsFragment.this, StoreDetailsFragment.this.mSelectedStore.getStoreLocation());
          StoreDetailsFragment.access$2202(StoreDetailsFragment.this, localStoreRef);
          return;
          label340: localView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener()
          {
            public boolean onPreDraw()
            {
              localView.getViewTreeObserver().removeOnPreDrawListener(this);
              View localView = localView.findViewById(2131624449);
              int i = localView.findViewById(2131624448).getHeight();
              if (i != 0)
                StoreDetailsFragment.access$902(StoreDetailsFragment.this, i);
              StoreDetailsFragment.access$602(StoreDetailsFragment.this, localView.getHeight());
              if (StoreDetailsFragment.this.mStoreInfoHeaderHeight != 0)
                StoreDetailsFragment.this.handleHeaderDrawn(new HeaderDrawnEvent(StoreDetailsFragment.this.mStoreInfoHeaderHeight, StoreDetailsFragment.this.mStoreInfoHeight, paramAnonymousInt));
              return true;
            }
          });
        }
      }
    });
    return this.mRootView;
  }

  public void onDestroy()
  {
    super.onDestroy();
    this.mPager = null;
    this.mAdapter = null;
  }

  public void onPause()
  {
    super.onPause();
    try
    {
      this.mBus.unregister(this);
      this.mFileServiceCallack.markInvalid();
      return;
    }
    catch (Exception localException)
    {
      while (true)
        L.W("No event handler to unregister");
    }
  }

  public void onResume()
  {
    super.onResume();
    this.mBus.register(this);
    if ((getActivity() != null) && (this.mStoreRefList != null))
      refreshUI(this.mStoreRefList, this.mFavStore, this.mCurrentLocation, this.mSelectedStore, this.mFromFirstUserExp, this.mFromTray, this.mShowHeader);
  }

  public void onSaveInstanceState(Bundle paramBundle)
  {
    super.onSaveInstanceState(paramBundle);
    L.I("onSaveInstanceState mCurrentStoreIndex :: " + this.mCurrentStoreIndex);
    L.I("onSaveInstanceState isInfoViewOpen :: " + this.isInfoViewOpen);
    paramBundle.putInt("KEY_CURRENT_STORE_INDEX", this.mCurrentStoreIndex);
    paramBundle.putBoolean("KEY_STORE_DETAIL_OPEN", this.isInfoViewOpen);
    if ((this.mPDFLoadingDialog != null) && (this.mPDFLoadingDialog.isShowing()) && (this.mInstoremapUrl != null))
    {
      L.I("File need to remove");
      hideLoadingDialog();
      paramBundle.putBoolean("PDF_DOWNLOAD_POPUP", true);
      paramBundle.putString("PDF_DOWNLOAD_URL", this.mInstoremapUrl);
    }
  }

  public void setData(StoreRefList paramStoreRefList, StoreRef paramStoreRef1, Location paramLocation, StoreRef paramStoreRef2, boolean paramBoolean1, boolean paramBoolean2, boolean paramBoolean3, boolean paramBoolean4, boolean paramBoolean5, boolean paramBoolean6)
  {
    this.mCurrentLocation = paramLocation;
    this.mFromFirstUserExp = paramBoolean1;
    this.mFromTray = paramBoolean2;
    this.mFromWelcome = paramBoolean3;
    this.mFromSL = paramBoolean4;
    this.mFromSettings = paramBoolean5;
    this.mShowHeader = paramBoolean6;
    this.mStoreRefList = paramStoreRefList;
    this.mFavStore = paramStoreRef1;
    this.mSelectedStore = paramStoreRef2;
    if (getActivity() != null)
      refreshUI(paramStoreRefList, paramStoreRef1, paramLocation, paramStoreRef2, paramBoolean1, paramBoolean2, paramBoolean6);
  }

  public void setHeaderVisibility(boolean paramBoolean)
  {
    this.mShowHeader = paramBoolean;
    if (paramBoolean)
      if (this.mStoreInfoLayout != null)
      {
        if (this.isInfoViewOpen)
          break label57;
        this.mStoreInfoLayout.animate().translationY(this.mDeviceHight - this.mStoreInfoHeaderHeight + this.mActionBarHeight).setListener(this.mAnimListener);
      }
    label57: 
    while (this.mStoreInfoLayout == null)
    {
      return;
      this.mStoreInfoLayout.animate().translationY(this.mDeviceHight - this.mStoreInfoHeight).setListener(this.mAnimListener);
      return;
    }
    this.mStoreInfoLayout.animate().translationY(this.mDeviceHight + this.mActionBarHeight).setListener(this.mAnimListener);
  }

  @Subscribe
  public void storeChanged(StoreSelectedEvent paramStoreSelectedEvent)
  {
    if ((this.mAdapter != null) && (this.mPager != null))
    {
      StoreRef localStoreRef = paramStoreSelectedEvent.store;
      if ((localStoreRef != null) && (this.mAdapter.getStoreIndex(localStoreRef) != this.mPager.getCurrentItem()))
      {
        this.mPager.setCurrentItem(this.mAdapter.getStoreIndex(localStoreRef));
        this.mCurrentStoreLocation = localStoreRef.getStoreLocation();
      }
    }
  }

  @Subscribe
  public void storeMarkerSelected(StoreMarkerSelectedEvent paramStoreMarkerSelectedEvent)
  {
    if ((this.mAdapter != null) && (this.mPager != null))
    {
      StoreRef localStoreRef = paramStoreMarkerSelectedEvent.store;
      if (localStoreRef != null)
      {
        this.mPager.setCurrentItem(this.mAdapter.getStoreIndex(localStoreRef));
        this.mCurrentStoreLocation = localStoreRef.getStoreLocation();
      }
    }
  }
}

/* Location:           C:\Documents and Settings\Cesar Cabello Cea\Mis documentos\Downloads\apk-downloader\com.ikea.kompis-6_dex2jar.jar
 * Qualified Name:     com.ikea.kompis.stores.StoreDetailsFragment
 * JD-Core Version:    0.6.2
 */